Commit 16e2cea4 authored by Jihwan Marc Kim's avatar Jihwan Marc Kim Committed by Commit Bot

[IndexedDB] Switch macro-based error histograms to function-based

Move error histograms in IndexedDB to use function instead to reduce
code size.

Bug: 1012881, 945578
Change-Id: I4f211651bda3437fd956302c9b00fbd422ae769d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857798Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706273}
parent 155f39e0
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_functions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -327,7 +327,7 @@ bool IsPathTooLong(const FilePath& leveldb_dir) { ...@@ -327,7 +327,7 @@ bool IsPathTooLong(const FilePath& leveldb_dir) {
const int min = 140; const int min = 140;
const int max = 300; const int max = 300;
const int num_buckets = 12; const int num_buckets = 12;
UMA_HISTOGRAM_CUSTOM_COUNTS( base::UmaHistogramCustomCounts(
"WebCore.IndexedDB.BackingStore.OverlyLargeOriginLength", "WebCore.IndexedDB.BackingStore.OverlyLargeOriginLength",
component_length, min, max, num_buckets); component_length, min, max, num_buckets);
return true; return true;
...@@ -1591,8 +1591,6 @@ bool IndexedDBBackingStore::WriteBlobFile( ...@@ -1591,8 +1591,6 @@ bool IndexedDBBackingStore::WriteBlobFile(
return false; return false;
bool use_copy_file = descriptor.is_file() && !descriptor.file_path().empty(); bool use_copy_file = descriptor.is_file() && !descriptor.file_path().empty();
UMA_HISTOGRAM_BOOLEAN("Storage.IndexedDB.WriteBlobFileViaCopy",
use_copy_file);
FilePath path = GetBlobFileName(database_id, descriptor.key()); FilePath path = GetBlobFileName(database_id, descriptor.key());
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_functions.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -382,9 +382,8 @@ void IndexedDBContextImpl::CopyOriginData(const Origin& origin, ...@@ -382,9 +382,8 @@ void IndexedDBContextImpl::CopyOriginData(const Origin& origin,
void IndexedDBContextImpl::ForceClose(const Origin origin, void IndexedDBContextImpl::ForceClose(const Origin origin,
ForceCloseReason reason) { ForceCloseReason reason) {
DCHECK(TaskRunner()->RunsTasksInCurrentSequence()); DCHECK(TaskRunner()->RunsTasksInCurrentSequence());
UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Context.ForceCloseReason", base::UmaHistogramEnumeration("WebCore.IndexedDB.Context.ForceCloseReason",
reason, FORCE_CLOSE_REASON_MAX); reason, FORCE_CLOSE_REASON_MAX);
if (!HasOrigin(origin)) if (!HasOrigin(origin))
return; return;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_functions.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
...@@ -466,7 +466,7 @@ void IndexedDBFactoryImpl::HandleBackingStoreCorruption( ...@@ -466,7 +466,7 @@ void IndexedDBFactoryImpl::HandleBackingStoreCorruption(
path_base.Append(indexed_db::GetLevelDBFileName(saved_origin)); path_base.Append(indexed_db::GetLevelDBFileName(saved_origin));
leveldb::Status s = leveldb_factory_->DestroyLevelDB(file_path); leveldb::Status s = leveldb_factory_->DestroyLevelDB(file_path);
DLOG_IF(ERROR, !s.ok()) << "Unable to delete backing store: " << s.ToString(); DLOG_IF(ERROR, !s.ok()) << "Unable to delete backing store: " << s.ToString();
UMA_HISTOGRAM_ENUMERATION( base::UmaHistogramEnumeration(
"WebCore.IndexedDB.DestroyCorruptBackingStoreStatus", "WebCore.IndexedDB.DestroyCorruptBackingStoreStatus",
leveldb_env::GetLevelDBStatusUMAValue(s), leveldb_env::GetLevelDBStatusUMAValue(s),
leveldb_env::LEVELDB_STATUS_MAX); leveldb_env::LEVELDB_STATUS_MAX);
...@@ -827,7 +827,7 @@ IndexedDBFactoryImpl::OpenAndVerifyIndexedDBBackingStore( ...@@ -827,7 +827,7 @@ IndexedDBFactoryImpl::OpenAndVerifyIndexedDBBackingStore(
// This is a special case where we want to make sure the database is // This is a special case where we want to make sure the database is
// deleted, so we try to delete again. // deleted, so we try to delete again.
status = leveldb_factory_->DestroyLevelDB(database_path); status = leveldb_factory_->DestroyLevelDB(database_path);
UMA_HISTOGRAM_ENUMERATION( base::UmaHistogramEnumeration(
"WebCore.IndexedDB.DestroyCorruptBackingStoreStatus", "WebCore.IndexedDB.DestroyCorruptBackingStoreStatus",
leveldb_env::GetLevelDBStatusUMAValue(status), leveldb_env::GetLevelDBStatusUMAValue(status),
leveldb_env::LEVELDB_STATUS_MAX); leveldb_env::LEVELDB_STATUS_MAX);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "base/values.h" #include "base/values.h"
#include "content/browser/indexed_db/indexed_db_data_format_version.h" #include "content/browser/indexed_db/indexed_db_data_format_version.h"
...@@ -126,7 +126,7 @@ bool IsPathTooLong(const base::FilePath& leveldb_dir) { ...@@ -126,7 +126,7 @@ bool IsPathTooLong(const base::FilePath& leveldb_dir) {
const int min = 140; const int min = 140;
const int max = 300; const int max = 300;
const int num_buckets = 12; const int num_buckets = 12;
UMA_HISTOGRAM_CUSTOM_COUNTS( base::UmaHistogramCustomCounts(
"WebCore.IndexedDB.BackingStore.OverlyLargeOriginLength", "WebCore.IndexedDB.BackingStore.OverlyLargeOriginLength",
component_length, min, max, num_buckets); component_length, min, max, num_buckets);
return true; return true;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <string> #include <string>
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
#include "content/browser/indexed_db/indexed_db_leveldb_coding.h" #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
...@@ -63,8 +64,8 @@ void ParseAndReportCorruptionDetails(const std::string& histogram_name, ...@@ -63,8 +64,8 @@ void ParseAndReportCorruptionDetails(const std::string& histogram_name,
void ReportOpenStatus(IndexedDBBackingStoreOpenResult result, void ReportOpenStatus(IndexedDBBackingStoreOpenResult result,
const url::Origin& origin) { const url::Origin& origin) {
UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.BackingStore.OpenStatus", result, base::UmaHistogramEnumeration("WebCore.IndexedDB.BackingStore.OpenStatus",
INDEXED_DB_BACKING_STORE_OPEN_MAX); result, INDEXED_DB_BACKING_STORE_OPEN_MAX);
const std::string suffix = OriginToCustomHistogramSuffix(origin); const std::string suffix = OriginToCustomHistogramSuffix(origin);
// Data from the WebCore.IndexedDB.BackingStore.OpenStatus histogram is used // Data from the WebCore.IndexedDB.BackingStore.OpenStatus histogram is used
// to generate a graph. So as not to alter the meaning of that graph, // to generate a graph. So as not to alter the meaning of that graph,
...@@ -104,7 +105,8 @@ void ReportSchemaVersion(int version, const url::Origin& origin) { ...@@ -104,7 +105,8 @@ void ReportSchemaVersion(int version, const url::Origin& origin) {
} }
void ReportV2Schema(bool has_broken_blobs, const url::Origin& origin) { void ReportV2Schema(bool has_broken_blobs, const url::Origin& origin) {
UMA_HISTOGRAM_BOOLEAN("WebCore.IndexedDB.SchemaV2HasBlobs", has_broken_blobs); base::UmaHistogramBoolean("WebCore.IndexedDB.SchemaV2HasBlobs",
has_broken_blobs);
const std::string suffix = OriginToCustomHistogramSuffix(origin); const std::string suffix = OriginToCustomHistogramSuffix(origin);
if (!suffix.empty()) { if (!suffix.empty()) {
base::BooleanHistogram::FactoryGet( base::BooleanHistogram::FactoryGet(
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -166,9 +167,9 @@ leveldb::Status IndexedDBTransaction::Abort( ...@@ -166,9 +167,9 @@ leveldb::Status IndexedDBTransaction::Abort(
if (state_ == FINISHED) if (state_ == FINISHED)
return leveldb::Status::OK(); return leveldb::Status::OK();
UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.TransactionAbortReason", base::UmaHistogramEnumeration("WebCore.IndexedDB.TransactionAbortReason",
ExceptionCodeToUmaEnum(error.code()), ExceptionCodeToUmaEnum(error.code()),
UmaIDBExceptionExclusiveMaxValue); UmaIDBExceptionExclusiveMaxValue);
aborted_ = true; aborted_ = true;
timeout_timer_.Stop(); timeout_timer_.Stop();
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "content/browser/indexed_db/leveldb/leveldb_env.h" #include "content/browser/indexed_db/leveldb/leveldb_env.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "content/browser/indexed_db/scopes/leveldb_state.h" #include "content/browser/indexed_db/scopes/leveldb_state.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_functions.h"
#include "content/browser/indexed_db/leveldb/leveldb_env.h" #include "content/browser/indexed_db/leveldb/leveldb_env.h"
namespace content { namespace content {
...@@ -65,8 +65,8 @@ LevelDBState::~LevelDBState() { ...@@ -65,8 +65,8 @@ LevelDBState::~LevelDBState() {
return; return;
base::TimeTicks begin_time = base::TimeTicks::Now(); base::TimeTicks begin_time = base::TimeTicks::Now();
const_cast<std::unique_ptr<leveldb::DB>*>(&db_)->reset(); const_cast<std::unique_ptr<leveldb::DB>*>(&db_)->reset();
UMA_HISTOGRAM_MEDIUM_TIMES("WebCore.IndexedDB.LevelDB.CloseTime", base::UmaHistogramMediumTimes("WebCore.IndexedDB.LevelDB.CloseTime",
base::TimeTicks::Now() - begin_time); base::TimeTicks::Now() - begin_time);
} }
} // namespace content } // namespace content
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_functions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "content/browser/child_process_security_policy_impl.h" #include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/indexed_db/indexed_db_callback_helpers.h" #include "content/browser/indexed_db/indexed_db_callback_helpers.h"
...@@ -28,10 +28,6 @@ namespace { ...@@ -28,10 +28,6 @@ namespace {
const char kInvalidBlobUuid[] = "Blob does not exist"; const char kInvalidBlobUuid[] = "Blob does not exist";
const char kInvalidBlobFilePath[] = "Blob file path is invalid"; const char kInvalidBlobFilePath[] = "Blob file path is invalid";
void LogUMAPutBlobCount(size_t blob_count) {
UMA_HISTOGRAM_COUNTS_1000("WebCore.IndexedDB.PutBlobsCount", blob_count);
}
IndexedDBDatabaseError CreateBackendAbortError() { IndexedDBDatabaseError CreateBackendAbortError() {
return IndexedDBDatabaseError(blink::kWebIDBDatabaseExceptionAbortError, return IndexedDBDatabaseError(blink::kWebIDBDatabaseExceptionAbortError,
"Backend aborted error"); "Backend aborted error");
...@@ -171,7 +167,6 @@ void TransactionImpl::Put( ...@@ -171,7 +167,6 @@ void TransactionImpl::Put(
result.code = IOHelper::LoadResultCode::kSuccess; result.code = IOHelper::LoadResultCode::kSuccess;
result.value = std::move(value_ptr); result.value = std::move(value_ptr);
result.blob_info = std::vector<IndexedDBBlobInfo>(); result.blob_info = std::vector<IndexedDBBlobInfo>();
LogUMAPutBlobCount(result.blob_info.size());
} else { } else {
// TODO(crbug.com/932869): Remove IO thread hop entirely. // TODO(crbug.com/932869): Remove IO thread hop entirely.
base::WaitableEvent signal_when_finished( base::WaitableEvent signal_when_finished(
...@@ -242,11 +237,6 @@ void TransactionImpl::Put( ...@@ -242,11 +237,6 @@ void TransactionImpl::Put(
return; return;
} }
// Value size recorded in IDBObjectStore before we can auto-wrap in a
// blob. 1KB to 10MB.
UMA_HISTOGRAM_COUNTS_10000("WebCore.IndexedDB.PutKeySize",
key.size_estimate() / 1024);
uint64_t commit_size = result.value->bits.size() + key.size_estimate(); uint64_t commit_size = result.value->bits.size() + key.size_estimate();
IndexedDBValue value; IndexedDBValue value;
// TODO(crbug.com/902498): Use mojom traits to map directly to // TODO(crbug.com/902498): Use mojom traits to map directly to
...@@ -333,14 +323,11 @@ void TransactionImpl::IOHelper::LoadBlobsOnIOThread( ...@@ -333,14 +323,11 @@ void TransactionImpl::IOHelper::LoadBlobsOnIOThread(
// Due to known issue crbug.com/351753, blobs can die while being passed to // Due to known issue crbug.com/351753, blobs can die while being passed to
// a different process. So this case must be handled gracefully. // a different process. So this case must be handled gracefully.
// TODO(dmurph): Revert back to using mojo::ReportBadMessage once fixed. // TODO(dmurph): Revert back to using mojo::ReportBadMessage once fixed.
UMA_HISTOGRAM_BOOLEAN("Storage.IndexedDB.PutValidBlob",
handle.get() != nullptr);
if (!handle) { if (!handle) {
result->code = LoadResultCode::kAbort; result->code = LoadResultCode::kAbort;
return; return;
} }
uint64_t size = handle->size(); uint64_t size = handle->size();
UMA_HISTOGRAM_MEMORY_KB("Storage.IndexedDB.PutBlobSizeKB", size / 1024ull);
total_blob_size += size; total_blob_size += size;
if (info->file) { if (info->file) {
...@@ -360,13 +347,6 @@ void TransactionImpl::IOHelper::LoadBlobsOnIOThread( ...@@ -360,13 +347,6 @@ void TransactionImpl::IOHelper::LoadBlobsOnIOThread(
IndexedDBBlobInfo(std::move(handle), info->mime_type, info->size); IndexedDBBlobInfo(std::move(handle), info->mime_type, info->size);
} }
} }
LogUMAPutBlobCount(blob_info.size());
uint64_t blob_size = total_blob_size.ValueOrDefault(0U);
if (blob_size != 0) {
// Bytes to kilobytes.
UMA_HISTOGRAM_COUNTS_1M("WebCore.IndexedDB.PutBlobsTotalSize",
blob_size / 1024);
}
result->code = LoadResultCode::kSuccess; result->code = LoadResultCode::kSuccess;
result->value = std::move(value); result->value = std::move(value);
result->blob_info = std::move(blob_info); result->blob_info = std::move(blob_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment