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

Unified Diff: net/extras/sqlite/sqlite_channel_id_store.cc

Issue 2807853002: Log metrics for loading SQLiteChannelIDStore (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/extras/sqlite/sqlite_channel_id_store.cc
diff --git a/net/extras/sqlite/sqlite_channel_id_store.cc b/net/extras/sqlite/sqlite_channel_id_store.cc
index fa2d263f337abf11e7b97c6571249e67fd01faf9..1462eb23da534a15de0382aee35dff9495842d36 100644
--- a/net/extras/sqlite/sqlite_channel_id_store.cc
+++ b/net/extras/sqlite/sqlite_channel_id_store.cc
@@ -36,6 +36,32 @@ namespace {
const int kCurrentVersionNumber = 6;
const int kCompatibleVersionNumber = 6;
+// Used in the DomainBoundCerts.DBLoadStatus histogram to record the status of
+// the Channel ID database when loading it from disk. It reports reasons why the
+// db could fail to load, or that it was loaded successfully.
+// Do not change or re-use values.
+enum DbLoadStatus {
+ // The path for the directory containing the db doesn't exist and couldn't be
+ // created.
+ PATH_DOES_NOT_EXIST = 0,
+ // Unable to open the database.
+ FAILED_TO_OPEN = 1,
+ // Failed to migrate the db to the current version.
+ MIGRATION_FAILED = 2,
+ // Unable to execute SELECT statement to load contents from db.
+ INVALID_SELECT_STATEMENT = 3,
+ // New database successfully created.
+ NEW_DB = 4,
+ // Database successfully loaded.
+ LOADED = 5,
+ DB_LOAD_STATUS_MAX
+};
+
+void RecordDbLoadStatus(DbLoadStatus status) {
+ UMA_HISTOGRAM_ENUMERATION("DomainBoundCerts.DBLoadStatus", status,
+ DB_LOAD_STATUS_MAX);
+}
+
} // namespace
namespace net {
@@ -176,8 +202,10 @@ void SQLiteChannelIDStore::Backend::LoadInBackground(
// Ensure the parent directory for storing certs is created before reading
// from it.
const base::FilePath dir = path_.DirName();
- if (!base::PathExists(dir) && !base::CreateDirectory(dir))
+ if (!base::PathExists(dir) && !base::CreateDirectory(dir)) {
+ RecordDbLoadStatus(PATH_DOES_NOT_EXIST);
return;
+ }
db_.reset(new sql::Connection);
db_->set_histogram_tag("DomainBoundCerts");
@@ -187,11 +215,17 @@ void SQLiteChannelIDStore::Backend::LoadInBackground(
base::Bind(&SQLiteChannelIDStore::Backend::DatabaseErrorCallback,
base::Unretained(this)));
+ bool is_new = false;
+ if (!base::PathExists(path_)) {
+ is_new = true;
+ }
+
if (!db_->Open(path_)) {
NOTREACHED() << "Unable to open cert DB.";
if (corruption_detected_)
KillDatabase();
db_.reset();
+ RecordDbLoadStatus(FAILED_TO_OPEN);
return;
}
@@ -201,6 +235,7 @@ void SQLiteChannelIDStore::Backend::LoadInBackground(
KillDatabase();
meta_table_.Reset();
db_.reset();
+ RecordDbLoadStatus(MIGRATION_FAILED);
return;
}
@@ -214,6 +249,7 @@ void SQLiteChannelIDStore::Backend::LoadInBackground(
KillDatabase();
meta_table_.Reset();
db_.reset();
+ RecordDbLoadStatus(INVALID_SELECT_STATEMENT);
return;
}
@@ -242,6 +278,11 @@ void SQLiteChannelIDStore::Backend::LoadInBackground(
50);
DVLOG(1) << "loaded " << channel_ids->size() << " in "
<< load_time.InMilliseconds() << " ms";
+ if (is_new) {
+ RecordDbLoadStatus(NEW_DB);
+ } else {
+ RecordDbLoadStatus(LOADED);
+ }
}
bool SQLiteChannelIDStore::Backend::EnsureDatabaseVersion() {
@@ -257,6 +298,8 @@ bool SQLiteChannelIDStore::Backend::EnsureDatabaseVersion() {
}
int cur_version = meta_table_.GetVersionNumber();
+ UMA_HISTOGRAM_EXACT_LINEAR("DomainBoundCerts.DBVersion", cur_version,
+ kCurrentVersionNumber + 1);
sql::Transaction transaction(db_.get());
if (!transaction.Begin())
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698