OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/diagnostics/recon_diagnostics.h" | 5 #include "chrome/browser/diagnostics/recon_diagnostics.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 namespace { | 38 namespace { |
39 | 39 |
40 class InstallTypeTest; | 40 class InstallTypeTest; |
41 InstallTypeTest* g_install_type = 0; | 41 InstallTypeTest* g_install_type = 0; |
42 | 42 |
43 // Check that the flavor of the operating system is supported. | 43 // Check that the flavor of the operating system is supported. |
44 class OperatingSystemTest : public DiagnosticTest { | 44 class OperatingSystemTest : public DiagnosticTest { |
45 public: | 45 public: |
46 OperatingSystemTest() : DiagnosticTest(ASCIIToUTF16("Operating System")) {} | 46 OperatingSystemTest() : DiagnosticTest(ASCIIToUTF16("Operating System")) {} |
47 | 47 |
48 virtual int GetId() { return 0; } | 48 virtual int GetId() OVERRIDE { return 0; } |
49 | 49 |
50 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { | 50 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
51 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
52 base::win::Version version = base::win::GetVersion(); | 52 base::win::Version version = base::win::GetVersion(); |
53 if ((version < base::win::VERSION_XP) || | 53 if ((version < base::win::VERSION_XP) || |
54 ((version == base::win::VERSION_XP) && | 54 ((version == base::win::VERSION_XP) && |
55 (base::win::OSInfo::GetInstance()->service_pack().major < 2))) { | 55 (base::win::OSInfo::GetInstance()->service_pack().major < 2))) { |
56 RecordFailure(ASCIIToUTF16("Must have Windows XP SP2 or later")); | 56 RecordFailure(ASCIIToUTF16("Must have Windows XP SP2 or later")); |
57 return false; | 57 return false; |
58 } | 58 } |
59 #else | 59 #else |
60 // TODO(port): define the OS criteria for Linux and Mac. | 60 // TODO(port): define the OS criteria for Linux and Mac. |
61 #endif // defined(OS_WIN) | 61 #endif // defined(OS_WIN) |
62 RecordSuccess(ASCIIToUTF16(base::StringPrintf( | 62 RecordSuccess(ASCIIToUTF16(base::StringPrintf( |
63 "%s %s", | 63 "%s %s", |
64 base::SysInfo::OperatingSystemName().c_str(), | 64 base::SysInfo::OperatingSystemName().c_str(), |
65 base::SysInfo::OperatingSystemVersion().c_str()))); | 65 base::SysInfo::OperatingSystemVersion().c_str()))); |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 DISALLOW_COPY_AND_ASSIGN(OperatingSystemTest); | 70 DISALLOW_COPY_AND_ASSIGN(OperatingSystemTest); |
71 }; | 71 }; |
72 | 72 |
73 // Check if any conflicting DLLs are loaded. | 73 // Check if any conflicting DLLs are loaded. |
74 class ConflictingDllsTest : public DiagnosticTest { | 74 class ConflictingDllsTest : public DiagnosticTest { |
75 public: | 75 public: |
76 ConflictingDllsTest() : DiagnosticTest(ASCIIToUTF16("Conflicting modules")) {} | 76 ConflictingDllsTest() : DiagnosticTest(ASCIIToUTF16("Conflicting modules")) {} |
77 | 77 |
78 virtual int GetId() { return 0; } | 78 virtual int GetId() OVERRIDE { return 0; } |
79 | 79 |
80 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { | 80 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
81 #if defined(OS_WIN) | 81 #if defined(OS_WIN) |
82 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); | 82 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); |
83 model->set_limited_mode(true); | 83 model->set_limited_mode(true); |
84 model->ScanNow(); | 84 model->ScanNow(); |
85 scoped_ptr<ListValue> list(model->GetModuleList()); | 85 scoped_ptr<ListValue> list(model->GetModuleList()); |
86 if (!model->confirmed_bad_modules_detected() && | 86 if (!model->confirmed_bad_modules_detected() && |
87 !model->suspected_bad_modules_detected()) { | 87 !model->suspected_bad_modules_detected()) { |
88 RecordSuccess(ASCIIToUTF16("No conflicting modules found")); | 88 RecordSuccess(ASCIIToUTF16("No conflicting modules found")); |
89 return true; | 89 return true; |
90 } | 90 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 private: | 124 private: |
125 DISALLOW_COPY_AND_ASSIGN(ConflictingDllsTest); | 125 DISALLOW_COPY_AND_ASSIGN(ConflictingDllsTest); |
126 }; | 126 }; |
127 | 127 |
128 // Check if it is system install or per-user install. | 128 // Check if it is system install or per-user install. |
129 class InstallTypeTest : public DiagnosticTest { | 129 class InstallTypeTest : public DiagnosticTest { |
130 public: | 130 public: |
131 InstallTypeTest() : DiagnosticTest(ASCIIToUTF16("Install Type")), | 131 InstallTypeTest() : DiagnosticTest(ASCIIToUTF16("Install Type")), |
132 user_level_(false) {} | 132 user_level_(false) {} |
133 | 133 |
134 virtual int GetId() { return 0; } | 134 virtual int GetId() OVERRIDE { return 0; } |
135 | 135 |
136 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { | 136 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
137 #if defined(OS_WIN) | 137 #if defined(OS_WIN) |
138 FilePath chrome_exe; | 138 FilePath chrome_exe; |
139 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | 139 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
140 RecordFailure(ASCIIToUTF16("Path provider failure")); | 140 RecordFailure(ASCIIToUTF16("Path provider failure")); |
141 return false; | 141 return false; |
142 } | 142 } |
143 user_level_ = InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()); | 143 user_level_ = InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()); |
144 const char* type = user_level_ ? "User Level" : "System Level"; | 144 const char* type = user_level_ ? "User Level" : "System Level"; |
145 string16 install_type(ASCIIToUTF16(type)); | 145 string16 install_type(ASCIIToUTF16(type)); |
146 #else | 146 #else |
147 string16 install_type(ASCIIToUTF16("System Level")); | 147 string16 install_type(ASCIIToUTF16("System Level")); |
148 #endif // defined(OS_WIN) | 148 #endif // defined(OS_WIN) |
149 RecordSuccess(install_type); | 149 RecordSuccess(install_type); |
150 g_install_type = this; | 150 g_install_type = this; |
151 return true; | 151 return true; |
152 } | 152 } |
153 | 153 |
154 bool system_level() const { return !user_level_; } | 154 bool system_level() const { return !user_level_; } |
155 | 155 |
156 private: | 156 private: |
157 bool user_level_; | 157 bool user_level_; |
158 DISALLOW_COPY_AND_ASSIGN(InstallTypeTest); | 158 DISALLOW_COPY_AND_ASSIGN(InstallTypeTest); |
159 }; | 159 }; |
160 | 160 |
161 // Check the version of Chrome. | 161 // Check the version of Chrome. |
162 class VersionTest : public DiagnosticTest { | 162 class VersionTest : public DiagnosticTest { |
163 public: | 163 public: |
164 VersionTest() : DiagnosticTest(ASCIIToUTF16("Browser Version")) {} | 164 VersionTest() : DiagnosticTest(ASCIIToUTF16("Browser Version")) {} |
165 | 165 |
166 virtual int GetId() { return 0; } | 166 virtual int GetId() OVERRIDE { return 0; } |
167 | 167 |
168 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { | 168 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
169 chrome::VersionInfo version_info; | 169 chrome::VersionInfo version_info; |
170 if (!version_info.is_valid()) { | 170 if (!version_info.is_valid()) { |
171 RecordFailure(ASCIIToUTF16("No Version")); | 171 RecordFailure(ASCIIToUTF16("No Version")); |
172 return true; | 172 return true; |
173 } | 173 } |
174 std::string current_version = version_info.Version(); | 174 std::string current_version = version_info.Version(); |
175 if (current_version.empty()) { | 175 if (current_version.empty()) { |
176 RecordFailure(ASCIIToUTF16("Empty Version")); | 176 RecordFailure(ASCIIToUTF16("Empty Version")); |
177 return true; | 177 return true; |
178 } | 178 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 // Check that the user's data directory exists and the paths are writable. | 217 // Check that the user's data directory exists and the paths are writable. |
218 // If it is a systemwide install some paths are not expected to be writable. | 218 // If it is a systemwide install some paths are not expected to be writable. |
219 // This test depends on |InstallTypeTest| having run successfully. | 219 // This test depends on |InstallTypeTest| having run successfully. |
220 class PathTest : public DiagnosticTest { | 220 class PathTest : public DiagnosticTest { |
221 public: | 221 public: |
222 explicit PathTest(const TestPathInfo& path_info) | 222 explicit PathTest(const TestPathInfo& path_info) |
223 : DiagnosticTest(ASCIIToUTF16(path_info.test_name)), | 223 : DiagnosticTest(ASCIIToUTF16(path_info.test_name)), |
224 path_info_(path_info) {} | 224 path_info_(path_info) {} |
225 | 225 |
226 virtual int GetId() { return 0; } | 226 virtual int GetId() OVERRIDE { return 0; } |
227 | 227 |
228 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { | 228 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
229 if (!g_install_type) { | 229 if (!g_install_type) { |
230 RecordStopFailure(ASCIIToUTF16("dependency failure")); | 230 RecordStopFailure(ASCIIToUTF16("dependency failure")); |
231 return false; | 231 return false; |
232 } | 232 } |
233 FilePath dir_or_file; | 233 FilePath dir_or_file; |
234 if (!PathService::Get(path_info_.path_id, &dir_or_file)) { | 234 if (!PathService::Get(path_info_.path_id, &dir_or_file)) { |
235 RecordStopFailure(ASCIIToUTF16("Path provider failure")); | 235 RecordStopFailure(ASCIIToUTF16("Path provider failure")); |
236 return false; | 236 return false; |
237 } | 237 } |
238 if (!file_util::PathExists(dir_or_file)) { | 238 if (!file_util::PathExists(dir_or_file)) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 TestPathInfo path_info_; | 281 TestPathInfo path_info_; |
282 DISALLOW_COPY_AND_ASSIGN(PathTest); | 282 DISALLOW_COPY_AND_ASSIGN(PathTest); |
283 }; | 283 }; |
284 | 284 |
285 // Check that the disk space in the volume where the user data dir normally | 285 // Check that the disk space in the volume where the user data dir normally |
286 // lives is not dangerously low. | 286 // lives is not dangerously low. |
287 class DiskSpaceTest : public DiagnosticTest { | 287 class DiskSpaceTest : public DiagnosticTest { |
288 public: | 288 public: |
289 DiskSpaceTest() : DiagnosticTest(ASCIIToUTF16("Disk Space")) {} | 289 DiskSpaceTest() : DiagnosticTest(ASCIIToUTF16("Disk Space")) {} |
290 | 290 |
291 virtual int GetId() { return 0; } | 291 virtual int GetId() OVERRIDE { return 0; } |
292 | 292 |
293 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { | 293 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
294 FilePath data_dir; | 294 FilePath data_dir; |
295 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) | 295 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) |
296 return false; | 296 return false; |
297 int64 disk_space = base::SysInfo::AmountOfFreeDiskSpace(data_dir); | 297 int64 disk_space = base::SysInfo::AmountOfFreeDiskSpace(data_dir); |
298 if (disk_space < 0) { | 298 if (disk_space < 0) { |
299 RecordFailure(ASCIIToUTF16("Unable to query free space")); | 299 RecordFailure(ASCIIToUTF16("Unable to query free space")); |
300 return true; | 300 return true; |
301 } | 301 } |
302 string16 printable_size = ui::FormatBytes(disk_space); | 302 string16 printable_size = ui::FormatBytes(disk_space); |
303 if (disk_space < 80 * kOneMeg) { | 303 if (disk_space < 80 * kOneMeg) { |
304 RecordFailure(ASCIIToUTF16("Low disk space : ") + printable_size); | 304 RecordFailure(ASCIIToUTF16("Low disk space : ") + printable_size); |
305 return true; | 305 return true; |
306 } | 306 } |
307 RecordSuccess(ASCIIToUTF16("Free space : ") + printable_size); | 307 RecordSuccess(ASCIIToUTF16("Free space : ") + printable_size); |
308 return true; | 308 return true; |
309 } | 309 } |
310 | 310 |
311 private: | 311 private: |
312 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); | 312 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); |
313 }; | 313 }; |
314 | 314 |
315 // Checks that a given json file can be correctly parsed. | 315 // Checks that a given json file can be correctly parsed. |
316 class JSONTest : public DiagnosticTest { | 316 class JSONTest : public DiagnosticTest { |
317 public: | 317 public: |
318 JSONTest(const FilePath& path, const string16& name, int64 max_file_size) | 318 JSONTest(const FilePath& path, const string16& name, int64 max_file_size) |
319 : DiagnosticTest(name), path_(path), max_file_size_(max_file_size) { | 319 : DiagnosticTest(name), path_(path), max_file_size_(max_file_size) { |
320 } | 320 } |
321 | 321 |
322 virtual int GetId() { return 0; } | 322 virtual int GetId() OVERRIDE { return 0; } |
323 | 323 |
324 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { | 324 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
325 if (!file_util::PathExists(path_)) { | 325 if (!file_util::PathExists(path_)) { |
326 RecordFailure(ASCIIToUTF16("File not found")); | 326 RecordFailure(ASCIIToUTF16("File not found")); |
327 return true; | 327 return true; |
328 } | 328 } |
329 int64 file_size; | 329 int64 file_size; |
330 if (!file_util::GetFileSize(path_, &file_size)) { | 330 if (!file_util::GetFileSize(path_, &file_size)) { |
331 RecordFailure(ASCIIToUTF16("Cannot obtain file size")); | 331 RecordFailure(ASCIIToUTF16("Cannot obtain file size")); |
332 return true; | 332 return true; |
333 } | 333 } |
334 | 334 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 path = path.Append(chrome::kBookmarksFileName); | 415 path = path.Append(chrome::kBookmarksFileName); |
416 return new JSONTest(path, ASCIIToUTF16("BookMarks JSON"), 2 * kOneMeg); | 416 return new JSONTest(path, ASCIIToUTF16("BookMarks JSON"), 2 * kOneMeg); |
417 } | 417 } |
418 | 418 |
419 DiagnosticTest* MakeLocalStateTest() { | 419 DiagnosticTest* MakeLocalStateTest() { |
420 FilePath path; | 420 FilePath path; |
421 PathService::Get(chrome::DIR_USER_DATA, &path); | 421 PathService::Get(chrome::DIR_USER_DATA, &path); |
422 path = path.Append(chrome::kLocalStateFilename); | 422 path = path.Append(chrome::kLocalStateFilename); |
423 return new JSONTest(path, ASCIIToUTF16("Local State JSON"), 50 * kOneKilo); | 423 return new JSONTest(path, ASCIIToUTF16("Local State JSON"), 50 * kOneKilo); |
424 } | 424 } |
OLD | NEW |