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

Side by Side Diff: webkit/fileapi/file_system_directory_database.cc

Issue 9956059: Refine UMA stats for file system databases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | webkit/fileapi/file_system_origin_database.cc » ('j') | 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 "webkit/fileapi/file_system_directory_database.h" 5 #include "webkit/fileapi/file_system_directory_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const char kChildLookupPrefix[] = "CHILD_OF:"; 67 const char kChildLookupPrefix[] = "CHILD_OF:";
68 const char kChildLookupSeparator[] = ":"; 68 const char kChildLookupSeparator[] = ":";
69 const char kLastFileIdKey[] = "LAST_FILE_ID"; 69 const char kLastFileIdKey[] = "LAST_FILE_ID";
70 const char kLastIntegerKey[] = "LAST_INTEGER"; 70 const char kLastIntegerKey[] = "LAST_INTEGER";
71 const int64 kMinimumReportIntervalHours = 1; 71 const int64 kMinimumReportIntervalHours = 1;
72 const char kInitStatusHistogramLabel[] = "FileSystem.DirectoryDatabaseInit"; 72 const char kInitStatusHistogramLabel[] = "FileSystem.DirectoryDatabaseInit";
73 73
74 enum InitStatus { 74 enum InitStatus {
75 INIT_STATUS_OK = 0, 75 INIT_STATUS_OK = 0,
76 INIT_STATUS_CORRUPTION, 76 INIT_STATUS_CORRUPTION,
77 INIT_STATUS_IO_ERROR,
78 INIT_STATUS_UNKNOWN_ERROR,
77 INIT_STATUS_MAX 79 INIT_STATUS_MAX
78 }; 80 };
79 81
80 std::string GetChildLookupKey( 82 std::string GetChildLookupKey(
81 fileapi::FileSystemDirectoryDatabase::FileId parent_id, 83 fileapi::FileSystemDirectoryDatabase::FileId parent_id,
82 const FilePath::StringType& child_name) { 84 const FilePath::StringType& child_name) {
83 std::string name; 85 std::string name;
84 name = fileapi::FilePathToString(FilePath(child_name)); 86 name = fileapi::FilePathToString(FilePath(child_name));
85 return std::string(kChildLookupPrefix) + base::Int64ToString(parent_id) + 87 return std::string(kChildLookupPrefix) + base::Int64ToString(parent_id) +
86 std::string(kChildLookupSeparator) + name; 88 std::string(kChildLookupSeparator) + name;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 base::Time now = base::Time::Now(); 439 base::Time now = base::Time::Now();
438 const base::TimeDelta minimum_interval = 440 const base::TimeDelta minimum_interval =
439 base::TimeDelta::FromHours(kMinimumReportIntervalHours); 441 base::TimeDelta::FromHours(kMinimumReportIntervalHours);
440 if (last_reported_time_ + minimum_interval >= now) 442 if (last_reported_time_ + minimum_interval >= now)
441 return; 443 return;
442 last_reported_time_ = now; 444 last_reported_time_ = now;
443 445
444 if (status.ok()) { 446 if (status.ok()) {
445 UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel, 447 UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel,
446 INIT_STATUS_OK, INIT_STATUS_MAX); 448 INIT_STATUS_OK, INIT_STATUS_MAX);
449 } else if (status.IsCorruption()) {
450 UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel,
451 INIT_STATUS_CORRUPTION, INIT_STATUS_MAX);
452 } else if (status.IsIOError()) {
453 UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel,
454 INIT_STATUS_IO_ERROR, INIT_STATUS_MAX);
447 } else { 455 } else {
448 UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel, 456 UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel,
449 INIT_STATUS_CORRUPTION, INIT_STATUS_MAX); 457 INIT_STATUS_UNKNOWN_ERROR, INIT_STATUS_MAX);
450 } 458 }
451 } 459 }
452 460
453 bool FileSystemDirectoryDatabase::StoreDefaultValues() { 461 bool FileSystemDirectoryDatabase::StoreDefaultValues() {
454 // Verify that this is a totally new database, and initialize it. 462 // Verify that this is a totally new database, and initialize it.
455 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); 463 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions()));
456 iter->SeekToFirst(); 464 iter->SeekToFirst();
457 if (iter->Valid()) { // DB was not empty--we shouldn't have been called. 465 if (iter->Valid()) { // DB was not empty--we shouldn't have been called.
458 LOG(ERROR) << "File system origin database is corrupt!"; 466 LOG(ERROR) << "File system origin database is corrupt!";
459 return false; 467 return false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 568
561 void FileSystemDirectoryDatabase::HandleError( 569 void FileSystemDirectoryDatabase::HandleError(
562 const tracked_objects::Location& from_here, 570 const tracked_objects::Location& from_here,
563 const leveldb::Status& status) { 571 const leveldb::Status& status) {
564 LOG(ERROR) << "FileSystemDirectoryDatabase failed at: " 572 LOG(ERROR) << "FileSystemDirectoryDatabase failed at: "
565 << from_here.ToString() << " with error: " << status.ToString(); 573 << from_here.ToString() << " with error: " << status.ToString();
566 db_.reset(); 574 db_.reset();
567 } 575 }
568 576
569 } // namespace fileapi 577 } // namespace fileapi
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/file_system_origin_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698