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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 private: | 321 private: |
322 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); | 322 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); |
323 }; | 323 }; |
324 | 324 |
325 // Checks that a given json file can be correctly parsed. | 325 // Checks that a given json file can be correctly parsed. |
326 class JSONTest : public DiagnosticsTest { | 326 class JSONTest : public DiagnosticsTest { |
327 public: | 327 public: |
328 JSONTest(const base::FilePath& path, | 328 JSONTest(const base::FilePath& path, |
329 const std::string& id, | 329 const std::string& id, |
330 const std::string& name, | 330 const std::string& name, |
331 int64 max_file_size) | 331 int64 max_file_size, |
332 : DiagnosticsTest(id, name), path_(path), max_file_size_(max_file_size) {} | 332 bool critical) |
333 : DiagnosticsTest(id, name), | |
334 path_(path), | |
335 max_file_size_(max_file_size), | |
336 critical_(critical) {} | |
333 | 337 |
334 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { | 338 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
335 if (!base::PathExists(path_)) { | 339 if (!base::PathExists(path_)) { |
336 RecordFailure(DIAG_RECON_FILE_NOT_FOUND, "File not found"); | 340 if (critical_) { |
341 RecordOutcome(DIAG_RECON_FILE_NOT_FOUND, | |
342 "File not found", | |
343 DiagnosticsModel::TEST_FAIL_CONTINUE); | |
344 } else { | |
345 RecordOutcome(DIAG_RECON_FILE_NOT_FOUND_OK, | |
346 "File not found (but that is OK)", | |
347 DiagnosticsModel::TEST_OK); | |
348 } | |
337 return true; | 349 return true; |
338 } | 350 } |
339 int64 file_size; | 351 int64 file_size; |
340 if (!file_util::GetFileSize(path_, &file_size)) { | 352 if (!file_util::GetFileSize(path_, &file_size)) { |
341 RecordFailure(DIAG_RECON_CANNOT_OBTAIN_FILE_SIZE, | 353 RecordFailure(DIAG_RECON_CANNOT_OBTAIN_FILE_SIZE, |
342 "Cannot obtain file size"); | 354 "Cannot obtain file size"); |
343 return true; | 355 return true; |
344 } | 356 } |
345 | 357 |
346 if (file_size > max_file_size_) { | 358 if (file_size > max_file_size_) { |
(...skipping 20 matching lines...) Expand all Loading... | |
367 return true; | 379 return true; |
368 } | 380 } |
369 | 381 |
370 RecordSuccess("File parsed OK"); | 382 RecordSuccess("File parsed OK"); |
371 return true; | 383 return true; |
372 } | 384 } |
373 | 385 |
374 private: | 386 private: |
375 base::FilePath path_; | 387 base::FilePath path_; |
376 int64 max_file_size_; | 388 int64 max_file_size_; |
389 bool critical_; // Is it required that the file exist? | |
377 DISALLOW_COPY_AND_ASSIGN(JSONTest); | 390 DISALLOW_COPY_AND_ASSIGN(JSONTest); |
378 }; | 391 }; |
379 | 392 |
380 } // namespace | 393 } // namespace |
381 | 394 |
382 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[0]); } | 395 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[0]); } |
383 | 396 |
384 DiagnosticsTest* MakeLocalStateFileTest() { | 397 DiagnosticsTest* MakeLocalStateFileTest() { |
385 return new PathTest(kPathsToTest[1]); | 398 return new PathTest(kPathsToTest[1]); |
386 } | 399 } |
(...skipping 12 matching lines...) Expand all Loading... | |
399 | 412 |
400 DiagnosticsTest* MakeOperatingSystemTest() { return new OperatingSystemTest(); } | 413 DiagnosticsTest* MakeOperatingSystemTest() { return new OperatingSystemTest(); } |
401 | 414 |
402 DiagnosticsTest* MakeConflictingDllsTest() { return new ConflictingDllsTest(); } | 415 DiagnosticsTest* MakeConflictingDllsTest() { return new ConflictingDllsTest(); } |
403 | 416 |
404 DiagnosticsTest* MakeInstallTypeTest() { return new InstallTypeTest(); } | 417 DiagnosticsTest* MakeInstallTypeTest() { return new InstallTypeTest(); } |
405 | 418 |
406 DiagnosticsTest* MakePreferencesTest() { | 419 DiagnosticsTest* MakePreferencesTest() { |
407 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); | 420 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); |
408 path = path.Append(chrome::kPreferencesFilename); | 421 path = path.Append(chrome::kPreferencesFilename); |
409 return new JSONTest( | 422 return new JSONTest(path, |
410 path, kJSONProfileTest, "Profile JSON", 100 * kOneKilobyte); | 423 kJSONProfileTest, |
424 "Profile JSON", | |
425 100 * kOneKilobyte, | |
426 true /* critical */); | |
cpu_(ooo_6.6-7.5)
2013/07/25 19:40:56
please remove /* critical */ and everywhere or use
Greg Spencer (Chromium)
2013/07/26 18:51:30
Done.
| |
411 } | 427 } |
412 | 428 |
413 DiagnosticsTest* MakeBookMarksTest() { | 429 DiagnosticsTest* MakeBookMarksTest() { |
414 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); | 430 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); |
415 path = path.Append(chrome::kBookmarksFileName); | 431 path = path.Append(chrome::kBookmarksFileName); |
416 return new JSONTest( | 432 return new JSONTest(path, |
417 path, kJSONBookmarksTest, "Bookmarks JSON", 2 * kOneMegabyte); | 433 kJSONBookmarksTest, |
434 "Bookmarks JSON", | |
435 2 * kOneMegabyte, | |
436 false /* critical */); | |
418 } | 437 } |
419 | 438 |
420 DiagnosticsTest* MakeLocalStateTest() { | 439 DiagnosticsTest* MakeLocalStateTest() { |
421 base::FilePath path; | 440 base::FilePath path; |
422 PathService::Get(chrome::DIR_USER_DATA, &path); | 441 PathService::Get(chrome::DIR_USER_DATA, &path); |
423 path = path.Append(chrome::kLocalStateFilename); | 442 path = path.Append(chrome::kLocalStateFilename); |
424 return new JSONTest( | 443 return new JSONTest(path, |
425 path, kJSONLocalStateTest, "Local State JSON", 50 * kOneKilobyte); | 444 kJSONLocalStateTest, |
445 "Local State JSON", | |
446 50 * kOneKilobyte, | |
447 true /* critical */); | |
426 } | 448 } |
427 | 449 |
428 } // namespace diagnostics | 450 } // namespace diagnostics |
OLD | NEW |