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

Unified Diff: base/json/json_file_value_serializer.h

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: out-of-line constructor 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
« no previous file with comments | « no previous file | base/json/json_file_value_serializer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_file_value_serializer.h
diff --git a/base/json/json_file_value_serializer.h b/base/json/json_file_value_serializer.h
index f0f556c2dc68a23457ad2aa8ec3db7a8a209947d..fded3f289ff9dc959744b8701fa186ccc005bc8d 100644
--- a/base/json/json_file_value_serializer.h
+++ b/base/json/json_file_value_serializer.h
@@ -14,15 +14,21 @@
class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer {
public:
- // json_file_patch is the path of a file that will be source of the
+ // |json_file_path_| is the path of a file that will be source of the
// deserialization or the destination of the serialization.
// When deserializing, the file should exist, but when serializing, the
// serializer will attempt to create the file at the specified location.
- explicit JSONFileValueSerializer(const base::FilePath& json_file_path)
- : json_file_path_(json_file_path),
- allow_trailing_comma_(false) {}
+ // If |histogram_suffix| is non-empty, will log a
+ // "Settings.JsonDataSizeKilobytes.|histogram_suffix|" UMA histogram with the
+ // size of the content read from disk while deserializing.
+ JSONFileValueSerializer(const base::FilePath& json_file_path,
+ const std::string& histogram_suffix);
Nico 2015/01/30 18:46:28 Why does a json library need to expose histograms
- ~JSONFileValueSerializer() override {}
+ // Constructs a JSONFileValueSerializer as above but with an empty
+ // |histogram_suffix|.
+ explicit JSONFileValueSerializer(const base::FilePath& json_file_path);
+
+ ~JSONFileValueSerializer() override;
// DO NOT USE except in unit tests to verify the file was written properly.
// We should never serialize directly to a file since this will block the
@@ -74,8 +80,9 @@ class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer {
private:
bool SerializeInternal(const base::Value& root, bool omit_binary_values);
- base::FilePath json_file_path_;
+ const base::FilePath json_file_path_;
bool allow_trailing_comma_;
+ const std::string histogram_suffix_;
// A wrapper for ReadFileToString which returns a non-zero JsonFileError if
// there were file errors.
« no previous file with comments | « no previous file | base/json/json_file_value_serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698