summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 06:04:44 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 06:04:44 +0000
commitac771fb36ba22c29b71877bdd3a9f356944c6ba4 (patch)
treef821479935b329ca682720e8c616f61c1079385e
parent721532e2b9f182f026ecd31055c133429464adaa (diff)
downloadchromium_src-ac771fb36ba22c29b71877bdd3a9f356944c6ba4.zip
chromium_src-ac771fb36ba22c29b71877bdd3a9f356944c6ba4.tar.gz
chromium_src-ac771fb36ba22c29b71877bdd3a9f356944c6ba4.tar.bz2
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
-rw-r--r--base/prefs/json_pref_store.cc25
-rw-r--r--tools/metrics/histograms/histograms.xml25
2 files changed, 49 insertions, 1 deletions
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<int>(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.
</summary>
</histogram>
+<histogram name="Settings.JsonDataSizeKilobytes" units="KB">
+ <owner>gab@chromium.org</owner>
+ <summary>
+ 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.
+ </summary>
+</histogram>
+
<histogram name="Settings.MigratedHashesFromLocalState" enum="BooleanMigrated">
<owner>csharp@chromium.org</owner>
<owner>gab@chromium.org</owner>
@@ -32647,6 +32655,16 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>Whether the scroll is executed on main thread.</summary>
</histogram>
+<histogram name="UMA.ClientIdBackupRecoveredWithAge" units="hours">
+ <owner>gab@chromium.org</owner>
+ <summary>
+ 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.
+ </summary>
+</histogram>
+
<histogram name="UMA.ClientIdMigrated" enum="BooleanMigrated">
<owner>asvitkine@chromium.org</owner>
<summary>
@@ -50563,6 +50581,13 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<affected-histogram name="Precache.Saved"/>
</histogram_suffixes>
+<histogram_suffixes name="PreferenceFileNames" separator=".">
+ <suffix name="Local_State" label="Local State file"/>
+ <suffix name="Preferences" label="Preferences file"/>
+ <suffix name="Secure_Preferences" label="Secure Preferences file"/>
+ <affected-histogram name="Settings.JsonDataSizeKilobytes"/>
+</histogram_suffixes>
+
<histogram_suffixes name="Prefetch">
<suffix name="ContentPrefetchPrefetchOff"
label="Prefetch is completely disabled."/>