Chromium Code Reviews| 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) { |