summaryrefslogtreecommitdiffstats
path: root/chrome/browser/diagnostics
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-14 22:12:59 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-14 22:12:59 +0000
commit6d745ac2b40db5df3e3be3d639faef7c3eb1bfaa (patch)
treef94def671c0136d1308da9b488481f56077e09d1 /chrome/browser/diagnostics
parent0149a3e9f9461c9909a6013db39f67eb1648a1f2 (diff)
downloadchromium_src-6d745ac2b40db5df3e3be3d639faef7c3eb1bfaa.zip
chromium_src-6d745ac2b40db5df3e3be3d639faef7c3eb1bfaa.tar.gz
chromium_src-6d745ac2b40db5df3e3be3d639faef7c3eb1bfaa.tar.bz2
Improvements to the diagnostic mode
- bettet banner - init ICU - size checks on the critical paths BUG=none TEST=included Review URL: http://codereview.chromium.org/521050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36278 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/diagnostics')
-rw-r--r--chrome/browser/diagnostics/diagnostics_main.cc18
-rw-r--r--chrome/browser/diagnostics/recon_diagnostics.cc40
2 files changed, 47 insertions, 11 deletions
diff --git a/chrome/browser/diagnostics/diagnostics_main.cc b/chrome/browser/diagnostics/diagnostics_main.cc
index 59a3814..c69172b 100644
--- a/chrome/browser/diagnostics/diagnostics_main.cc
+++ b/chrome/browser/diagnostics/diagnostics_main.cc
@@ -7,7 +7,9 @@
#include "app/app_paths.h"
#include "base/basictypes.h"
#include "base/command_line.h"
+#include "base/i18n/icu_util.h"
#include "base/string_util.h"
+#include "base/time.h"
#include "chrome/browser/diagnostics/diagnostics_model.h"
#include "chrome/common/chrome_paths.h"
@@ -123,6 +125,14 @@ class TestWriter {
DISALLOW_COPY_AND_ASSIGN(TestWriter);
};
+std::wstring PrintableUSCurrentTime() {
+ base::Time::Exploded exploded = {0};
+ base::Time::Now().UTCExplode(&exploded);
+ return StringPrintf(L"%d:%d:%d.%d:%d:%d",
+ exploded.year, exploded.month, exploded.day_of_month,
+ exploded.hour, exploded.minute, exploded.second);
+}
+
// This class is a basic test controller. In this design the view (TestWriter)
// and the model (DiagnosticsModel) do not talk to each other directly but they
// are mediated by the controller. This has a name: 'passive view'.
@@ -135,11 +145,17 @@ class TestController : public DiagnosticsModel::Observer {
// Run all the diagnostics of |model| and invoke the view as the model
// callbacks arrive.
void Run(DiagnosticsModel* model) {
- writer_->WriteInfoText(L"Chrome Diagnostics\n");
+ std::wstring title(L"Chrome Diagnostics Mode (");
+ writer_->WriteInfoText(title.append(PrintableUSCurrentTime()) + L")\n");
if (!model) {
writer_->WriteResult(false, L"Diagnostics start", L"model is null");
return;
}
+ bool icu_result = icu_util::Initialize();
+ if (!icu_result) {
+ writer_->WriteResult(false, L"Diagnostics start", L"ICU failure");
+ return;
+ }
int count = model->GetTestAvailableCount();
writer_->WriteInfoText(StringPrintf(L"%d available test(s)\n\n", count));
model->RunAll(this);
diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc
index 7c6bc9b..19afdb0 100644
--- a/chrome/browser/diagnostics/recon_diagnostics.cc
+++ b/chrome/browser/diagnostics/recon_diagnostics.cc
@@ -110,14 +110,18 @@ struct TestPathInfo {
const char* test_name;
int dir_id;
bool test_writable;
+ int64 max_size;
};
+const int64 kOneKilo = 1024;
+const int64 kOneMeg = 1024 * kOneKilo;
+
const TestPathInfo kPathsToTest[] = {
- {"User data Directory", chrome::DIR_USER_DATA, true},
- {"Local state file", chrome::FILE_LOCAL_STATE, true},
- {"Resources module", chrome::FILE_RESOURCE_MODULE, false},
- {"Dictionaries Directory", chrome::DIR_APP_DICTIONARIES, false},
- {"Inspector Directory", chrome::DIR_INSPECTOR, false}
+ {"User data Directory", chrome::DIR_USER_DATA, true, 250 * kOneMeg},
+ {"Local state file", chrome::FILE_LOCAL_STATE, true, 200 * kOneKilo},
+ {"Resources module", chrome::FILE_RESOURCE_MODULE, false, 0},
+ {"Dictionaries Directory", chrome::DIR_APP_DICTIONARIES, false, 0},
+ {"Inspector Directory", chrome::DIR_INSPECTOR, false, 0}
};
// Check that the user's data directory exists and the paths are writeable.
@@ -136,24 +140,40 @@ class PathTest : public DiagnosticTest {
RecordStopFailure(ASCIIToUTF16("dependency failure"));
return false;
}
- FilePath dir;
- if (!PathService::Get(path_info_.dir_id, &dir)) {
+ FilePath dir_or_file;
+ if (!PathService::Get(path_info_.dir_id, &dir_or_file)) {
RecordStopFailure(ASCIIToUTF16("Path provider failure"));
return false;
}
- if (!file_util::PathExists(dir)) {
+ if (!file_util::PathExists(dir_or_file)) {
RecordFailure(ASCIIToUTF16("Path not found"));
return true;
}
+
+ int64 dir_or_file_size;
+ if (!file_util::GetFileSize(dir_or_file, &dir_or_file_size)) {
+ RecordFailure(ASCIIToUTF16("Cannot obtain size"));
+ return true;
+ }
+ DataUnits units = GetByteDisplayUnits(dir_or_file_size);
+ string16 printable_size =
+ WideToUTF16(FormatBytes(dir_or_file_size, units, true));
+
+ if (path_info_.max_size > 0) {
+ if (dir_or_file_size > path_info_.max_size) {
+ RecordFailure(ASCIIToUTF16("Path is too big: ") + printable_size);
+ return true;
+ }
+ }
if (g_install_type->system_level() && !path_info_.test_writable) {
RecordSuccess(ASCIIToUTF16("Path exists"));
return true;
}
- if (!file_util::PathIsWritable(dir)) {
+ if (!file_util::PathIsWritable(dir_or_file)) {
RecordFailure(ASCIIToUTF16("Path is not writable"));
return true;
}
- RecordSuccess(ASCIIToUTF16("Path exists and is writable"));
+ RecordSuccess(ASCIIToUTF16("Path exists and is writable: ") + printable_size);
return true;
}