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

Unified Diff: components/safe_browsing_db/v4_store.cc

Issue 2447443002: Log the size of each of the stores and complete DB on launch and after each (Closed)
Patch Set: Add to histograms.xml 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_store.cc
diff --git a/components/safe_browsing_db/v4_store.cc b/components/safe_browsing_db/v4_store.cc
index 49ec3c51c711aa82d61d27aba9858de31c9c526f..b8882588bfb3f00f0387a3a4a5831ca4840e80f6 100644
--- a/components/safe_browsing_db/v4_store.cc
+++ b/components/safe_browsing_db/v4_store.cc
@@ -196,7 +196,7 @@ void V4Store::Initialize() {
V4Store::V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const base::FilePath& store_path)
- : store_path_(store_path), task_runner_(task_runner) {}
+ : file_size_(0), store_path_(store_path), task_runner_(task_runner) {}
V4Store::~V4Store() {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
@@ -700,11 +700,12 @@ StoreReadResult V4Store::ReadFromDisk() {
return HASH_PREFIX_MAP_GENERATION_FAILURE;
}
RecordApplyUpdateTime(kReadFromDisk, TimeTicks::Now() - before, store_path_);
+ file_size_ = V4ProtocolManagerUtil::GetFileSizeOrZero(store_path_);
Scott Hess - ex-Googler 2016/10/21 23:36:45 Could you get this from contents.size()?
vakh (use Gerrit instead) 2016/10/24 19:39:32 Done.
return READ_SUCCESS;
}
-StoreWriteResult V4Store::WriteToDisk(const Checksum& checksum) const {
+StoreWriteResult V4Store::WriteToDisk(const Checksum& checksum) {
V4StoreFileFormat file_format;
ListUpdateResponse* lur = file_format.mutable_list_update_response();
*(lur->mutable_checksum()) = checksum;
@@ -735,6 +736,8 @@ StoreWriteResult V4Store::WriteToDisk(const Checksum& checksum) const {
return UNABLE_TO_RENAME_FAILURE;
}
+ file_size_ = V4ProtocolManagerUtil::GetFileSizeOrZero(store_path_);
Scott Hess - ex-Googler 2016/10/21 23:36:45 Could this ever be a different value from |written
vakh (use Gerrit instead) 2016/10/24 19:39:32 Done.
+
return WRITE_SUCCESS;
}
@@ -832,4 +835,17 @@ bool V4Store::VerifyChecksum() {
return true;
}
+int V4Store::RecordAndReturnFileSize(const std::string& base_metric) {
+ std::string suffix = GetUmaSuffixForStore(store_path_);
+ // Histogram properties as in UMA_HISTOGRAM_COUNTS macro.
+ base::HistogramBase* histogram = base::Histogram::FactoryGet(
+ base_metric + suffix, 1, 1000000, 50,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ if (histogram) {
+ const int file_size_kilobytes = static_cast<int>(file_size_ / 1024);
+ histogram->Add(file_size_kilobytes);
+ }
+ return file_size_;
+}
+
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698