Commit ac771fb3 authored by gab@chromium.org's avatar gab@chromium.org

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
parent 721532e2
...@@ -9,12 +9,15 @@ ...@@ -9,12 +9,15 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/json/json_file_value_serializer.h" #include "base/json/json_file_value_serializer.h"
#include "base/json/json_string_value_serializer.h" #include "base/json/json_string_value_serializer.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop_proxy.h" #include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_filter.h" #include "base/prefs/pref_filter.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/string_util.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
#include "base/values.h" #include "base/values.h"
...@@ -388,7 +391,27 @@ bool JsonPrefStore::SerializeData(std::string* output) { ...@@ -388,7 +391,27 @@ bool JsonPrefStore::SerializeData(std::string* output) {
JSONStringValueSerializer serializer(output); JSONStringValueSerializer serializer(output);
serializer.set_pretty_print(true); 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, void JsonPrefStore::FinalizeFileRead(bool initialization_successful,
......
...@@ -27065,6 +27065,14 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -27065,6 +27065,14 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </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"> <histogram name="Settings.MigratedHashesFromLocalState" enum="BooleanMigrated">
<owner>csharp@chromium.org</owner> <owner>csharp@chromium.org</owner>
<owner>gab@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. ...@@ -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> <summary>Whether the scroll is executed on main thread.</summary>
</histogram> </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"> <histogram name="UMA.ClientIdMigrated" enum="BooleanMigrated">
<owner>asvitkine@chromium.org</owner> <owner>asvitkine@chromium.org</owner>
<summary> <summary>
...@@ -50563,6 +50581,13 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -50563,6 +50581,13 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<affected-histogram name="Precache.Saved"/> <affected-histogram name="Precache.Saved"/>
</histogram_suffixes> </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"> <histogram_suffixes name="Prefetch">
<suffix name="ContentPrefetchPrefetchOff" <suffix name="ContentPrefetchPrefetchOff"
label="Prefetch is completely disabled."/> label="Prefetch is completely disabled."/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment