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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 namespace diagnostics { | 45 namespace diagnostics { |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 const int64_t kOneKilobyte = 1024; | 49 const int64_t kOneKilobyte = 1024; |
50 const int64_t kOneMegabyte = 1024 * kOneKilobyte; | 50 const int64_t kOneMegabyte = 1024 * kOneKilobyte; |
51 | 51 |
52 class InstallTypeTest; | 52 class InstallTypeTest; |
53 InstallTypeTest* g_install_type = 0; | 53 InstallTypeTest* g_install_type = 0; |
54 | 54 |
55 // Check if any conflicting DLLs are loaded. | |
56 class ConflictingDllsTest : public DiagnosticsTest { | |
57 public: | |
58 ConflictingDllsTest() | |
59 : DiagnosticsTest(DIAGNOSTICS_CONFLICTING_DLLS_TEST) {} | |
60 | |
61 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | |
62 #if defined(OS_WIN) | |
63 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); | |
64 model->set_limited_mode(true); | |
65 model->ScanNow(); | |
66 std::unique_ptr<base::ListValue> list(model->GetModuleList()); | |
67 if (!model->confirmed_bad_modules_detected() && | |
68 !model->suspected_bad_modules_detected()) { | |
69 RecordSuccess("No conflicting modules found"); | |
70 return true; | |
71 } | |
72 | |
73 std::string failures = "Possibly conflicting modules:"; | |
74 base::DictionaryValue* dictionary; | |
75 for (size_t i = 0; i < list->GetSize(); ++i) { | |
76 if (!list->GetDictionary(i, &dictionary)) | |
77 RecordFailure(DIAG_RECON_DICTIONARY_LOOKUP_FAILED, | |
78 "Dictionary lookup failed"); | |
79 int status; | |
80 std::string location; | |
81 std::string name; | |
82 if (!dictionary->GetInteger("status", &status)) | |
83 RecordFailure(DIAG_RECON_NO_STATUS_FIELD, "No 'status' field found"); | |
84 if (status < ModuleEnumerator::SUSPECTED_BAD) | |
85 continue; | |
86 | |
87 if (!dictionary->GetString("location", &location)) { | |
88 RecordFailure(DIAG_RECON_NO_LOCATION_FIELD, | |
89 "No 'location' field found"); | |
90 return true; | |
91 } | |
92 if (!dictionary->GetString("name", &name)) { | |
93 RecordFailure(DIAG_RECON_NO_NAME_FIELD, "No 'name' field found"); | |
94 return true; | |
95 } | |
96 | |
97 failures += "\n" + location + name; | |
98 } | |
99 RecordFailure(DIAG_RECON_CONFLICTING_MODULES, failures); | |
100 return true; | |
101 #else | |
102 RecordFailure(DIAG_RECON_NOT_IMPLEMENTED, "Not implemented"); | |
103 return true; | |
104 #endif // defined(OS_WIN) | |
105 } | |
106 | |
107 private: | |
108 DISALLOW_COPY_AND_ASSIGN(ConflictingDllsTest); | |
109 }; | |
110 | |
111 // Check that the disk space in the volume where the user data directory | 55 // Check that the disk space in the volume where the user data directory |
112 // normally lives is not dangerously low. | 56 // normally lives is not dangerously low. |
113 class DiskSpaceTest : public DiagnosticsTest { | 57 class DiskSpaceTest : public DiagnosticsTest { |
114 public: | 58 public: |
115 DiskSpaceTest() : DiagnosticsTest(DIAGNOSTICS_DISK_SPACE_TEST) {} | 59 DiskSpaceTest() : DiagnosticsTest(DIAGNOSTICS_DISK_SPACE_TEST) {} |
116 | 60 |
117 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { | 61 bool ExecuteImpl(DiagnosticsModel::Observer* observer) override { |
118 base::FilePath data_dir; | 62 base::FilePath data_dir; |
119 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) | 63 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) |
120 return false; | 64 return false; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 RecordSuccess(current_version); | 323 RecordSuccess(current_version); |
380 return true; | 324 return true; |
381 } | 325 } |
382 | 326 |
383 private: | 327 private: |
384 DISALLOW_COPY_AND_ASSIGN(VersionTest); | 328 DISALLOW_COPY_AND_ASSIGN(VersionTest); |
385 }; | 329 }; |
386 | 330 |
387 } // namespace | 331 } // namespace |
388 | 332 |
389 DiagnosticsTest* MakeConflictingDllsTest() { return new ConflictingDllsTest(); } | |
390 | |
391 DiagnosticsTest* MakeDiskSpaceTest() { return new DiskSpaceTest(); } | 333 DiagnosticsTest* MakeDiskSpaceTest() { return new DiskSpaceTest(); } |
392 | 334 |
393 DiagnosticsTest* MakeInstallTypeTest() { return new InstallTypeTest(); } | 335 DiagnosticsTest* MakeInstallTypeTest() { return new InstallTypeTest(); } |
394 | 336 |
395 DiagnosticsTest* MakeBookMarksTest() { | 337 DiagnosticsTest* MakeBookMarksTest() { |
396 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); | 338 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); |
397 path = path.Append(bookmarks::kBookmarksFileName); | 339 path = path.Append(bookmarks::kBookmarksFileName); |
398 return new JSONTest(path, | 340 return new JSONTest(path, |
399 DIAGNOSTICS_JSON_BOOKMARKS_TEST, | 341 DIAGNOSTICS_JSON_BOOKMARKS_TEST, |
400 2 * kOneMegabyte, | 342 2 * kOneMegabyte, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 | 375 |
434 DiagnosticsTest* MakeResourcesFileTest() { | 376 DiagnosticsTest* MakeResourcesFileTest() { |
435 return new PathTest(kPathsToTest[2]); | 377 return new PathTest(kPathsToTest[2]); |
436 } | 378 } |
437 | 379 |
438 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); } | 380 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); } |
439 | 381 |
440 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); } | 382 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); } |
441 | 383 |
442 } // namespace diagnostics | 384 } // namespace diagnostics |
OLD | NEW |