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

Unified Diff: base/json/json_file_value_serializer.cc

Issue 891663003: Log pref file size histogram on read rather than on write. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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: base/json/json_file_value_serializer.cc
diff --git a/base/json/json_file_value_serializer.cc b/base/json/json_file_value_serializer.cc
index d60f800cfcfbb9235fc62fc050feb98c87a54740..cdcefef649d8801040a70a57acbd6ff7293964c4 100644
--- a/base/json/json_file_value_serializer.cc
+++ b/base/json/json_file_value_serializer.cc
@@ -7,6 +7,7 @@
#include "base/files/file_util.h"
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
using base::FilePath;
@@ -59,6 +60,21 @@ int JSONFileValueSerializer::ReadFileToString(std::string* json_string) {
else
return JSON_CANNOT_READ_FILE;
}
+
+ if (!histogram_suffix_.empty()) {
+ // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS
+ // macro adapted to allow for a dynamically suffixed histogram name.
+ // Note: The factory creates and owns the histogram.
+ base::HistogramBase* histogram =
+ base::Histogram::FactoryGet(
+ "Settings.JsonDataSizeKilobytes." + histogram_suffix_,
Alexei Svitkine (slow) 2015/01/30 13:49:03 Should be JsonDataReadSizeKilobytes.
gab 2015/01/30 17:33:37 Oops, done.
+ 1,
+ 10000,
+ 50,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ histogram->Add(static_cast<int>(json_string->size()) / 1024);
+ }
+
return JSON_NO_ERROR;
}

Powered by Google App Engine
This is Rietveld 408576698