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

Side by Side Diff: chrome/browser/chromeos/gdata/drive_cache_metadata.cc

Issue 10981030: UMA counts for corrupt cache db. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/chromeos/gdata/drive_cache_metadata.h" 5 #include "chrome/browser/chromeos/gdata/drive_cache_metadata.h"
6 6
7 #include <leveldb/db.h> 7 #include <leveldb/db.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/metrics/histogram.h"
11 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
12 #include "chrome/browser/chromeos/gdata/drive.pb.h" 13 #include "chrome/browser/chromeos/gdata/drive.pb.h"
13 #include "chrome/browser/chromeos/gdata/drive_file_system_util.h" 14 #include "chrome/browser/chromeos/gdata/drive_file_system_util.h"
14 15
15 namespace gdata { 16 namespace gdata {
16 17
17 namespace { 18 namespace {
18 19
19 // A map table of resource ID to file path. 20 // A map table of resource ID to file path.
20 typedef std::map<std::string, FilePath> ResourceIdToFilePathMap; 21 typedef std::map<std::string, FilePath> ResourceIdToFilePathMap;
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 leveldb::DB* level_db = NULL; 462 leveldb::DB* level_db = NULL;
462 leveldb::Options options; 463 leveldb::Options options;
463 options.create_if_missing = true; 464 options.create_if_missing = true;
464 leveldb::Status db_status = leveldb::DB::Open(options, db_path.value(), 465 leveldb::Status db_status = leveldb::DB::Open(options, db_path.value(),
465 &level_db); 466 &level_db);
466 467
467 // Delete the db and scan the physical cache. This will fix a corrupt db, but 468 // Delete the db and scan the physical cache. This will fix a corrupt db, but
468 // perhaps not other causes of failed DB::Open. 469 // perhaps not other causes of failed DB::Open.
469 if (!db_status.ok()) { 470 if (!db_status.ok()) {
470 DVLOG(1) << "Detected corrupt db"; 471 DVLOG(1) << "Detected corrupt db";
472 UMA_HISTOGRAM_COUNTS("Drive.CorruptCacheDB", 1);
satorux1 2012/09/25 22:40:50 I think we want to know success/failure ratio and
471 const bool deleted = file_util::Delete(db_path, true); 473 const bool deleted = file_util::Delete(db_path, true);
472 DCHECK(deleted); 474 DCHECK(deleted);
473 db_status = leveldb::DB::Open(options, db_path.value(), &level_db); 475 db_status = leveldb::DB::Open(options, db_path.value(), &level_db);
474 // TODO(satorux): Handle the situation where DB::Open fails because of lack 476 // TODO(satorux): Handle the situation where DB::Open fails because of lack
475 // of disk space, permissions, or other causes. crbug.com/150840. 477 // of disk space, permissions, or other causes. crbug.com/150840.
476 CHECK(db_status.ok()); // Must succeed or we'll crash later. 478 CHECK(db_status.ok()); // Must succeed or we'll crash later.
477 scan_cache = true; 479 scan_cache = true;
478 } 480 }
479 DCHECK(level_db); 481 DCHECK(level_db);
480 level_db_.reset(level_db); 482 level_db_.reset(level_db);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 return scoped_ptr<DriveCacheMetadata>( 614 return scoped_ptr<DriveCacheMetadata>(
613 new FakeDriveCacheMetadata(blocking_task_runner)); 615 new FakeDriveCacheMetadata(blocking_task_runner));
614 } 616 }
615 617
616 void DriveCacheMetadata::AssertOnSequencedWorkerPool() { 618 void DriveCacheMetadata::AssertOnSequencedWorkerPool() {
617 DCHECK(!blocking_task_runner_ || 619 DCHECK(!blocking_task_runner_ ||
618 blocking_task_runner_->RunsTasksOnCurrentThread()); 620 blocking_task_runner_->RunsTasksOnCurrentThread());
619 } 621 }
620 622
621 } // namespace gdata 623 } // namespace gdata
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698