diff --git a/components/services/storage/dom_storage/local_storage_impl.cc b/components/services/storage/dom_storage/local_storage_impl.cc index 8a4cf174108e..e6269fc09f2e 100644 --- a/components/services/storage/dom_storage/local_storage_impl.cc +++ b/components/services/storage/dom_storage/local_storage_impl.cc @@ -673,6 +673,11 @@ void LocalStorageImpl::OnDatabaseOpened(leveldb::Status status) { if (!status.ok()) { // If we failed to open the database, try to delete and recreate the // database, or ultimately fallback to an in-memory database. +#if BUILDFLAG(IS_COBALT) + base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseOpenError", + leveldb_env::GetLevelDBStatusUMAValue(status), + leveldb_env::LEVELDB_STATUS_MAX); +#endif DeleteAndRecreateDatabase(); return; } @@ -708,6 +713,11 @@ void LocalStorageImpl::OnGotDatabaseVersion(leveldb::Status status, &db_version) || db_version < kMinSchemaVersion || db_version > kCurrentLocalStorageSchemaVersion) { +#if BUILDFLAG(IS_COBALT) + base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseVersionMismatch", + leveldb_env::GetLevelDBStatusUMAValue(status), + leveldb_env::LEVELDB_STATUS_MAX); +#endif DeleteAndRecreateDatabase(); return; } @@ -715,6 +725,11 @@ void LocalStorageImpl::OnGotDatabaseVersion(leveldb::Status status, database_initialized_ = true; } else { // Other read error. Possibly database corruption. +#if BUILDFLAG(IS_COBALT) + base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseReadError", + leveldb_env::GetLevelDBStatusUMAValue(status), + leveldb_env::LEVELDB_STATUS_MAX); +#endif DeleteAndRecreateDatabase(); return; } @@ -971,6 +986,11 @@ void LocalStorageImpl::OnCommitResult(leveldb::Status status) { // Deleting StorageAreas in here could cause more commits (and commit // errors), but those commits won't reach OnCommitResult because the area // will have been deleted before the commit finishes. +#if BUILDFLAG(IS_COBALT) + base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseCommitError", + leveldb_env::GetLevelDBStatusUMAValue(status), + leveldb_env::LEVELDB_STATUS_MAX); +#endif DeleteAndRecreateDatabase(); } } diff --git a/tools/metrics/histograms/metadata/cobalt/histograms.xml b/tools/metrics/histograms/metadata/cobalt/histograms.xml index 1ac3ad94797d..a53db0e6409f 100644 --- a/tools/metrics/histograms/metadata/cobalt/histograms.xml +++ b/tools/metrics/histograms/metadata/cobalt/histograms.xml @@ -81,6 +81,30 @@ Always run the pretty print utility on this file after editing: + + colinliang@google.com + + Records the leveldb error when a commit fails in Local Storage. + + + + + colinliang@google.com + + Records the leveldb error when opening the Local Storage database fails. + + + + + colinliang@google.com + + Records the leveldb error when a read fails in Local Storage. + + + charleykim@google.com @@ -89,6 +113,15 @@ Always run the pretty print utility on this file after editing: + + colinliang@google.com + + Records the leveldb status when a version mismatch is detected in Local + Storage. + + + charleykim@google.com