From ac771fb36ba22c29b71877bdd3a9f356944c6ba4 Mon Sep 17 00:00:00 2001 From: "gab@chromium.org" Date: Wed, 16 Jul 2014 06:04:44 +0000 Subject: Track size of files serialized by the JsonPrefStore. In an effort to see what percentage of the population has exceedingly large pref files. BUG=355722 Review URL: https://codereview.chromium.org/391893002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283371 0039d316-1c4b-4281-b951-d872f2087c98 --- base/prefs/json_pref_store.cc | 25 ++++++++++++++++++++++++- tools/metrics/histograms/histograms.xml | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/base/prefs/json_pref_store.cc b/base/prefs/json_pref_store.cc index 9180984..fd95b73 100644 --- a/base/prefs/json_pref_store.cc +++ b/base/prefs/json_pref_store.cc @@ -9,12 +9,15 @@ #include "base/bind.h" #include "base/callback.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_string_value_serializer.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop_proxy.h" +#include "base/metrics/histogram.h" #include "base/prefs/pref_filter.h" #include "base/sequenced_task_runner.h" +#include "base/strings/string_util.h" #include "base/threading/sequenced_worker_pool.h" #include "base/values.h" @@ -388,7 +391,27 @@ bool JsonPrefStore::SerializeData(std::string* output) { JSONStringValueSerializer serializer(output); serializer.set_pretty_print(true); - return serializer.Serialize(*prefs_); + bool result = serializer.Serialize(*prefs_); + + if (result) { + std::string spaceless_basename; + base::ReplaceChars(path_.BaseName().MaybeAsASCII(), " ", "_", + &spaceless_basename); + + // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_10000 + // macro adapted to allow for a dynamically suffixed histogram name. + // Note: The factory creates and owns the histogram. + base::HistogramBase* histogram = + base::LinearHistogram::FactoryGet( + "Settings.JsonDataSizeKilobytes." + spaceless_basename, + 1, + 10000, + 50, + base::HistogramBase::kUmaTargetedHistogramFlag); + histogram->Add(static_cast(output->size()) / 1024); + } + + return result; } void JsonPrefStore::FinalizeFileRead(bool initialization_successful, diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index efc7153d2..d28b478 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -27065,6 +27065,14 @@ Therefore, the affected-histogram name has to have at least one dot in it. + + gab@chromium.org + + The size of the JSON settings content about to be written to disk in + kilobytes. Suffixed with the name of the JSON file being written to disk. + + + csharp@chromium.org gab@chromium.org @@ -32647,6 +32655,16 @@ Therefore, the affected-histogram name has to have at least one dot in it. Whether the scroll is executed on main thread. + + gab@chromium.org + + Recorded when we are somehow missing the client ID stored in Local State yet + are able to recover it from a backup location along with the backed up + installation date. This report carries the age in hours of the recovered + client id. + + + asvitkine@chromium.org @@ -50563,6 +50581,13 @@ Therefore, the affected-histogram name has to have at least one dot in it. + + + + + + + -- cgit v1.1