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

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: nits / format / only log on successful read 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..6cfcbe83c2f8295fcd5f277bf637b6afda809e2a 100644
--- a/base/json/json_file_value_serializer.h
+++ b/base/json/json_file_value_serializer.h
@@ -14,15 +14,13 @@
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) {}
+ explicit JSONFileValueSerializer(const base::FilePath& json_file_path);
- ~JSONFileValueSerializer() override {}
+ ~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
@@ -71,11 +69,16 @@ class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer {
allow_trailing_comma_ = new_value;
}
+ // Returns the syze (in bytes) of JSON string read from disk in the last
+ // successful |Deserialize()| call.
+ size_t get_last_read_size() const { return last_read_size_; }
+
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_;
+ size_t last_read_size_;
// 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