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/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 class InstallTypeTest; | 45 class InstallTypeTest; |
46 InstallTypeTest* g_install_type = 0; | 46 InstallTypeTest* g_install_type = 0; |
47 | 47 |
48 // Check if any conflicting DLLs are loaded. | 48 // Check if any conflicting DLLs are loaded. |
49 class ConflictingDllsTest : public DiagnosticsTest { | 49 class ConflictingDllsTest : public DiagnosticsTest { |
50 public: | 50 public: |
51 ConflictingDllsTest() | 51 ConflictingDllsTest() |
52 : DiagnosticsTest(DIAGNOSTICS_CONFLICTING_DLLS_TEST) {} | 52 : DiagnosticsTest(DIAGNOSTICS_CONFLICTING_DLLS_TEST) {} |
53 | 53 |
54 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | 54 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { |
55 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
56 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); | 56 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); |
57 model->set_limited_mode(true); | 57 model->set_limited_mode(true); |
58 model->ScanNow(); | 58 model->ScanNow(); |
59 scoped_ptr<base::ListValue> list(model->GetModuleList()); | 59 scoped_ptr<base::ListValue> list(model->GetModuleList()); |
60 if (!model->confirmed_bad_modules_detected() && | 60 if (!model->confirmed_bad_modules_detected() && |
61 !model->suspected_bad_modules_detected()) { | 61 !model->suspected_bad_modules_detected()) { |
62 RecordSuccess("No conflicting modules found"); | 62 RecordSuccess("No conflicting modules found"); |
63 return true; | 63 return true; |
64 } | 64 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 private: | 100 private: |
101 DISALLOW_COPY_AND_ASSIGN(ConflictingDllsTest); | 101 DISALLOW_COPY_AND_ASSIGN(ConflictingDllsTest); |
102 }; | 102 }; |
103 | 103 |
104 // Check that the disk space in the volume where the user data directory | 104 // Check that the disk space in the volume where the user data directory |
105 // normally lives is not dangerously low. | 105 // normally lives is not dangerously low. |
106 class DiskSpaceTest : public DiagnosticsTest { | 106 class DiskSpaceTest : public DiagnosticsTest { |
107 public: | 107 public: |
108 DiskSpaceTest() : DiagnosticsTest(DIAGNOSTICS_DISK_SPACE_TEST) {} | 108 DiskSpaceTest() : DiagnosticsTest(DIAGNOSTICS_DISK_SPACE_TEST) {} |
109 | 109 |
110 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | 110 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { |
111 base::FilePath data_dir; | 111 base::FilePath data_dir; |
112 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) | 112 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) |
113 return false; | 113 return false; |
114 int64 disk_space = base::SysInfo::AmountOfFreeDiskSpace(data_dir); | 114 int64 disk_space = base::SysInfo::AmountOfFreeDiskSpace(data_dir); |
115 if (disk_space < 0) { | 115 if (disk_space < 0) { |
116 RecordFailure(DIAG_RECON_UNABLE_TO_QUERY, "Unable to query free space"); | 116 RecordFailure(DIAG_RECON_UNABLE_TO_QUERY, "Unable to query free space"); |
117 return true; | 117 return true; |
118 } | 118 } |
119 std::string printable_size = base::Int64ToString(disk_space); | 119 std::string printable_size = base::Int64ToString(disk_space); |
120 if (disk_space < 80 * kOneMegabyte) { | 120 if (disk_space < 80 * kOneMegabyte) { |
121 RecordFailure(DIAG_RECON_LOW_DISK_SPACE, | 121 RecordFailure(DIAG_RECON_LOW_DISK_SPACE, |
122 "Low disk space: " + printable_size); | 122 "Low disk space: " + printable_size); |
123 return true; | 123 return true; |
124 } | 124 } |
125 RecordSuccess("Free space: " + printable_size); | 125 RecordSuccess("Free space: " + printable_size); |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 private: | 129 private: |
130 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); | 130 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); |
131 }; | 131 }; |
132 | 132 |
133 // Check if it is system install or per-user install. | 133 // Check if it is system install or per-user install. |
134 class InstallTypeTest : public DiagnosticsTest { | 134 class InstallTypeTest : public DiagnosticsTest { |
135 public: | 135 public: |
136 InstallTypeTest() | 136 InstallTypeTest() |
137 : DiagnosticsTest(DIAGNOSTICS_INSTALL_TYPE_TEST), user_level_(false) {} | 137 : DiagnosticsTest(DIAGNOSTICS_INSTALL_TYPE_TEST), user_level_(false) {} |
138 | 138 |
139 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | 139 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { |
140 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
141 base::FilePath chrome_exe; | 141 base::FilePath chrome_exe; |
142 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | 142 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
143 RecordFailure(DIAG_RECON_INSTALL_PATH_PROVIDER, "Path provider failure"); | 143 RecordFailure(DIAG_RECON_INSTALL_PATH_PROVIDER, "Path provider failure"); |
144 return false; | 144 return false; |
145 } | 145 } |
146 user_level_ = InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()); | 146 user_level_ = InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()); |
147 const char* type = user_level_ ? "User Level" : "System Level"; | 147 const char* type = user_level_ ? "User Level" : "System Level"; |
148 std::string install_type(type); | 148 std::string install_type(type); |
149 #else | 149 #else |
(...skipping 21 matching lines...) Expand all Loading... |
171 | 171 |
172 JSONTest(const base::FilePath& path, | 172 JSONTest(const base::FilePath& path, |
173 DiagnosticsTestId id, | 173 DiagnosticsTestId id, |
174 int64 max_file_size, | 174 int64 max_file_size, |
175 FileImportance importance) | 175 FileImportance importance) |
176 : DiagnosticsTest(id), | 176 : DiagnosticsTest(id), |
177 path_(path), | 177 path_(path), |
178 max_file_size_(max_file_size), | 178 max_file_size_(max_file_size), |
179 importance_(importance) {} | 179 importance_(importance) {} |
180 | 180 |
181 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | 181 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { |
182 if (!base::PathExists(path_)) { | 182 if (!base::PathExists(path_)) { |
183 if (importance_ == CRITICAL) { | 183 if (importance_ == CRITICAL) { |
184 RecordOutcome(DIAG_RECON_FILE_NOT_FOUND, | 184 RecordOutcome(DIAG_RECON_FILE_NOT_FOUND, |
185 "File not found", | 185 "File not found", |
186 DiagnosticsModel::TEST_FAIL_CONTINUE); | 186 DiagnosticsModel::TEST_FAIL_CONTINUE); |
187 } else { | 187 } else { |
188 RecordOutcome(DIAG_RECON_FILE_NOT_FOUND_OK, | 188 RecordOutcome(DIAG_RECON_FILE_NOT_FOUND_OK, |
189 "File not found (but that is OK)", | 189 "File not found (but that is OK)", |
190 DiagnosticsModel::TEST_OK); | 190 DiagnosticsModel::TEST_OK); |
191 } | 191 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 FileImportance importance_; | 233 FileImportance importance_; |
234 DISALLOW_COPY_AND_ASSIGN(JSONTest); | 234 DISALLOW_COPY_AND_ASSIGN(JSONTest); |
235 }; | 235 }; |
236 | 236 |
237 // Check that the flavor of the operating system is supported. | 237 // Check that the flavor of the operating system is supported. |
238 class OperatingSystemTest : public DiagnosticsTest { | 238 class OperatingSystemTest : public DiagnosticsTest { |
239 public: | 239 public: |
240 OperatingSystemTest() | 240 OperatingSystemTest() |
241 : DiagnosticsTest(DIAGNOSTICS_OPERATING_SYSTEM_TEST) {} | 241 : DiagnosticsTest(DIAGNOSTICS_OPERATING_SYSTEM_TEST) {} |
242 | 242 |
243 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | 243 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { |
244 #if defined(OS_WIN) | 244 #if defined(OS_WIN) |
245 base::win::Version version = base::win::GetVersion(); | 245 base::win::Version version = base::win::GetVersion(); |
246 if ((version < base::win::VERSION_XP) || | 246 if ((version < base::win::VERSION_XP) || |
247 ((version == base::win::VERSION_XP) && | 247 ((version == base::win::VERSION_XP) && |
248 (base::win::OSInfo::GetInstance()->service_pack().major < 2))) { | 248 (base::win::OSInfo::GetInstance()->service_pack().major < 2))) { |
249 RecordFailure(DIAG_RECON_PRE_WINDOW_XP_SP2, | 249 RecordFailure(DIAG_RECON_PRE_WINDOW_XP_SP2, |
250 "Must have Windows XP SP2 or later"); | 250 "Must have Windows XP SP2 or later"); |
251 return false; | 251 return false; |
252 } | 252 } |
253 #else | 253 #else |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 286 |
287 // Check that the user's data directory exists and the paths are writable. | 287 // Check that the user's data directory exists and the paths are writable. |
288 // If it is a system-wide install some paths are not expected to be writable. | 288 // If it is a system-wide install some paths are not expected to be writable. |
289 // This test depends on |InstallTypeTest| having run successfully. | 289 // This test depends on |InstallTypeTest| having run successfully. |
290 class PathTest : public DiagnosticsTest { | 290 class PathTest : public DiagnosticsTest { |
291 public: | 291 public: |
292 explicit PathTest(const TestPathInfo& path_info) | 292 explicit PathTest(const TestPathInfo& path_info) |
293 : DiagnosticsTest(path_info.test_id), | 293 : DiagnosticsTest(path_info.test_id), |
294 path_info_(path_info) {} | 294 path_info_(path_info) {} |
295 | 295 |
296 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | 296 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { |
297 if (!g_install_type) { | 297 if (!g_install_type) { |
298 RecordStopFailure(DIAG_RECON_DEPENDENCY, "Install dependency failure"); | 298 RecordStopFailure(DIAG_RECON_DEPENDENCY, "Install dependency failure"); |
299 return false; | 299 return false; |
300 } | 300 } |
301 base::FilePath dir_or_file; | 301 base::FilePath dir_or_file; |
302 if (!PathService::Get(path_info_.path_id, &dir_or_file)) { | 302 if (!PathService::Get(path_info_.path_id, &dir_or_file)) { |
303 RecordStopFailure(DIAG_RECON_PATH_PROVIDER, "Path provider failure"); | 303 RecordStopFailure(DIAG_RECON_PATH_PROVIDER, "Path provider failure"); |
304 return false; | 304 return false; |
305 } | 305 } |
306 if (!base::PathExists(dir_or_file)) { | 306 if (!base::PathExists(dir_or_file)) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 private: | 350 private: |
351 TestPathInfo path_info_; | 351 TestPathInfo path_info_; |
352 DISALLOW_COPY_AND_ASSIGN(PathTest); | 352 DISALLOW_COPY_AND_ASSIGN(PathTest); |
353 }; | 353 }; |
354 | 354 |
355 // Check the version of Chrome. | 355 // Check the version of Chrome. |
356 class VersionTest : public DiagnosticsTest { | 356 class VersionTest : public DiagnosticsTest { |
357 public: | 357 public: |
358 VersionTest() : DiagnosticsTest(DIAGNOSTICS_VERSION_TEST) {} | 358 VersionTest() : DiagnosticsTest(DIAGNOSTICS_VERSION_TEST) {} |
359 | 359 |
360 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | 360 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { |
361 chrome::VersionInfo version_info; | 361 chrome::VersionInfo version_info; |
362 std::string current_version = version_info.Version(); | 362 std::string current_version = version_info.Version(); |
363 if (current_version.empty()) { | 363 if (current_version.empty()) { |
364 RecordFailure(DIAG_RECON_EMPTY_VERSION, "Empty Version"); | 364 RecordFailure(DIAG_RECON_EMPTY_VERSION, "Empty Version"); |
365 return true; | 365 return true; |
366 } | 366 } |
367 std::string version_modifier = | 367 std::string version_modifier = |
368 chrome::VersionInfo::GetVersionStringModifier(); | 368 chrome::VersionInfo::GetVersionStringModifier(); |
369 if (!version_modifier.empty()) | 369 if (!version_modifier.empty()) |
370 current_version += " " + version_modifier; | 370 current_version += " " + version_modifier; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 DiagnosticsTest* MakeResourcesFileTest() { | 429 DiagnosticsTest* MakeResourcesFileTest() { |
430 return new PathTest(kPathsToTest[2]); | 430 return new PathTest(kPathsToTest[2]); |
431 } | 431 } |
432 | 432 |
433 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); } | 433 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); } |
434 | 434 |
435 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); } | 435 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); } |
436 | 436 |
437 } // namespace diagnostics | 437 } // namespace diagnostics |
OLD | NEW |