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

Unified 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: satorux feedback Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/drive_cache_metadata.cc
===================================================================
--- chrome/browser/chromeos/gdata/drive_cache_metadata.cc (revision 158657)
+++ chrome/browser/chromeos/gdata/drive_cache_metadata.cc (working copy)
@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "base/file_util.h"
+#include "base/metrics/histogram.h"
#include "base/sequenced_task_runner.h"
#include "chrome/browser/chromeos/gdata/drive.pb.h"
#include "chrome/browser/chromeos/gdata/drive_file_system_util.h"
@@ -16,6 +17,13 @@
namespace {
+enum DBOpenStatus {
+ DB_OPEN_SUCCESS,
+ DB_OPEN_FAILURE_CORRUPTION,
+ DB_OPEN_FAILURE_OTHER,
+ DB_OPEN_MAX_VALUE,
+};
+
// A map table of resource ID to file path.
typedef std::map<std::string, FilePath> ResourceIdToFilePathMap;
@@ -466,8 +474,11 @@
// Delete the db and scan the physical cache. This will fix a corrupt db, but
// perhaps not other causes of failed DB::Open.
+ DBOpenStatus uma_status = DB_OPEN_SUCCESS;
if (!db_status.ok()) {
- DVLOG(1) << "Detected corrupt db";
+ LOG(WARNING) << "Cache db failed to open: " << db_status.ToString();
satorux1 2012/09/25 23:09:03 ToString() is neat!
+ uma_status = db_status.IsCorruption() ?
+ DB_OPEN_FAILURE_CORRUPTION : DB_OPEN_FAILURE_OTHER;
const bool deleted = file_util::Delete(db_path, true);
DCHECK(deleted);
db_status = leveldb::DB::Open(options, db_path.value(), &level_db);
@@ -479,6 +490,9 @@
DCHECK(level_db);
level_db_.reset(level_db);
+ UMA_HISTOGRAM_ENUMERATION(
+ "Drive.CacheMetadataDBOpen", uma_status, DB_OPEN_MAX_VALUE);
+
// We scan the cache directories to initialize the cache database if we
// were previously using the cache map.
if (scan_cache) {
« 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