Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: chrome/browser/diagnostics/recon_diagnostics.cc

Issue 16948012: This adds a recovery mode to the diagnostics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload after merge Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 return true; 318 return true;
319 } 319 }
320 320
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 enum FileImportance {
329 NON_CRITICAL,
330 CRITICAL
331 };
332
328 JSONTest(const base::FilePath& path, 333 JSONTest(const base::FilePath& path,
329 const std::string& id, 334 const std::string& id,
330 const std::string& name, 335 const std::string& name,
331 int64 max_file_size) 336 int64 max_file_size,
332 : DiagnosticsTest(id, name), path_(path), max_file_size_(max_file_size) {} 337 FileImportance importance)
338 : DiagnosticsTest(id, name),
339 path_(path),
340 max_file_size_(max_file_size),
341 importance_(importance) {}
333 342
334 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { 343 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE {
335 if (!base::PathExists(path_)) { 344 if (!base::PathExists(path_)) {
336 RecordFailure(DIAG_RECON_FILE_NOT_FOUND, "File not found"); 345 if (importance_ == CRITICAL) {
346 RecordOutcome(DIAG_RECON_FILE_NOT_FOUND,
347 "File not found",
348 DiagnosticsModel::TEST_FAIL_CONTINUE);
349 } else {
350 RecordOutcome(DIAG_RECON_FILE_NOT_FOUND_OK,
351 "File not found (but that is OK)",
352 DiagnosticsModel::TEST_OK);
353 }
337 return true; 354 return true;
338 } 355 }
339 int64 file_size; 356 int64 file_size;
340 if (!file_util::GetFileSize(path_, &file_size)) { 357 if (!file_util::GetFileSize(path_, &file_size)) {
341 RecordFailure(DIAG_RECON_CANNOT_OBTAIN_FILE_SIZE, 358 RecordFailure(DIAG_RECON_CANNOT_OBTAIN_FILE_SIZE,
342 "Cannot obtain file size"); 359 "Cannot obtain file size");
343 return true; 360 return true;
344 } 361 }
345 362
346 if (file_size > max_file_size_) { 363 if (file_size > max_file_size_) {
(...skipping 20 matching lines...) Expand all
367 return true; 384 return true;
368 } 385 }
369 386
370 RecordSuccess("File parsed OK"); 387 RecordSuccess("File parsed OK");
371 return true; 388 return true;
372 } 389 }
373 390
374 private: 391 private:
375 base::FilePath path_; 392 base::FilePath path_;
376 int64 max_file_size_; 393 int64 max_file_size_;
394 FileImportance importance_;
377 DISALLOW_COPY_AND_ASSIGN(JSONTest); 395 DISALLOW_COPY_AND_ASSIGN(JSONTest);
378 }; 396 };
379 397
380 } // namespace 398 } // namespace
381 399
382 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[0]); } 400 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[0]); }
383 401
384 DiagnosticsTest* MakeLocalStateFileTest() { 402 DiagnosticsTest* MakeLocalStateFileTest() {
385 return new PathTest(kPathsToTest[1]); 403 return new PathTest(kPathsToTest[1]);
386 } 404 }
(...skipping 12 matching lines...) Expand all
399 417
400 DiagnosticsTest* MakeOperatingSystemTest() { return new OperatingSystemTest(); } 418 DiagnosticsTest* MakeOperatingSystemTest() { return new OperatingSystemTest(); }
401 419
402 DiagnosticsTest* MakeConflictingDllsTest() { return new ConflictingDllsTest(); } 420 DiagnosticsTest* MakeConflictingDllsTest() { return new ConflictingDllsTest(); }
403 421
404 DiagnosticsTest* MakeInstallTypeTest() { return new InstallTypeTest(); } 422 DiagnosticsTest* MakeInstallTypeTest() { return new InstallTypeTest(); }
405 423
406 DiagnosticsTest* MakePreferencesTest() { 424 DiagnosticsTest* MakePreferencesTest() {
407 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); 425 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir();
408 path = path.Append(chrome::kPreferencesFilename); 426 path = path.Append(chrome::kPreferencesFilename);
409 return new JSONTest( 427 return new JSONTest(path,
410 path, kJSONProfileTest, "Profile JSON", 100 * kOneKilobyte); 428 kJSONProfileTest,
429 "Profile JSON",
430 100 * kOneKilobyte,
431 JSONTest::CRITICAL);
411 } 432 }
412 433
413 DiagnosticsTest* MakeBookMarksTest() { 434 DiagnosticsTest* MakeBookMarksTest() {
414 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); 435 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir();
415 path = path.Append(chrome::kBookmarksFileName); 436 path = path.Append(chrome::kBookmarksFileName);
416 return new JSONTest( 437 return new JSONTest(path,
417 path, kJSONBookmarksTest, "Bookmarks JSON", 2 * kOneMegabyte); 438 kJSONBookmarksTest,
439 "Bookmarks JSON",
440 2 * kOneMegabyte,
441 JSONTest::NON_CRITICAL);
418 } 442 }
419 443
420 DiagnosticsTest* MakeLocalStateTest() { 444 DiagnosticsTest* MakeLocalStateTest() {
421 base::FilePath path; 445 base::FilePath path;
422 PathService::Get(chrome::DIR_USER_DATA, &path); 446 PathService::Get(chrome::DIR_USER_DATA, &path);
423 path = path.Append(chrome::kLocalStateFilename); 447 path = path.Append(chrome::kLocalStateFilename);
424 return new JSONTest( 448 return new JSONTest(path,
425 path, kJSONLocalStateTest, "Local State JSON", 50 * kOneKilobyte); 449 kJSONLocalStateTest,
450 "Local State JSON",
451 50 * kOneKilobyte,
452 JSONTest::CRITICAL);
426 } 453 }
427 454
428 } // namespace diagnostics 455 } // namespace diagnostics
OLDNEW
« no previous file with comments | « chrome/browser/diagnostics/recon_diagnostics.h ('k') | chrome/browser/diagnostics/sqlite_diagnostics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698