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

Unified Diff: components/safe_browsing_db/v4_database.cc

Issue 2447443002: Log the size of each of the stores and complete DB on launch and after each (Closed)
Patch Set: shess@'s review Created 4 years, 2 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
Index: components/safe_browsing_db/v4_database.cc
diff --git a/components/safe_browsing_db/v4_database.cc b/components/safe_browsing_db/v4_database.cc
index 4b43498c5abf4bd2139d42ca51ef8528738694ef..460995f2cbc527552d0b6e86d5e8e6b3e7e39059 100644
--- a/components/safe_browsing_db/v4_database.cc
+++ b/components/safe_browsing_db/v4_database.cc
@@ -8,6 +8,7 @@
#include "base/debug/leak_annotations.h"
#include "base/files/file_util.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/safe_browsing_db/v4_database.h"
#include "content/public/browser/browser_thread.h"
@@ -16,6 +17,12 @@ using content::BrowserThread;
namespace safe_browsing {
+namespace {
+
+const char kV4DatabaseSizeMetric[] = "SafeBrowsing.V4Database.Size";
+
+} // namespace
+
// static
V4StoreFactory* V4Database::factory_ = NULL;
@@ -214,6 +221,17 @@ void V4Database::VerifyChecksumOnTaskRunner(
FROM_HERE, base::Bind(db_ready_for_updates_callback, stores_to_reset));
}
+void V4Database::RecordFileSizeHistograms() {
+ int64_t db_size = 0;
+ for (const auto& store_map_iter : *store_map_) {
+ const int64_t size =
+ store_map_iter.second->RecordAndReturnFileSize(kV4DatabaseSizeMetric);
+ db_size += size;
+ }
+ const int db_size_kilobytes = static_cast<int>(db_size / 1024);
+ UMA_HISTOGRAM_COUNTS(kV4DatabaseSizeMetric, db_size_kilobytes);
+}
+
ListInfo::ListInfo(const bool fetch_updates,
const std::string& filename,
const ListIdentifier& list_id,

Powered by Google App Engine
This is Rietveld 408576698