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

Unified Diff: base/json/json_file_value_serializer.cc

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 10 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 | « base/json/json_file_value_serializer.h ('k') | base/json/json_string_value_serializer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_file_value_serializer.cc
diff --git a/base/json/json_file_value_serializer.cc b/base/json/json_file_value_serializer.cc
index 71033f638200fbff9ce7dcbd247bf91e1a7597a3..72a09700161776760a00c73e99f57b613f26df11 100644
--- a/base/json/json_file_value_serializer.cc
+++ b/base/json/json_file_value_serializer.cc
@@ -10,16 +10,14 @@
using base::FilePath;
-const char JSONFileValueSerializer::kAccessDenied[] = "Access denied.";
-const char JSONFileValueSerializer::kCannotReadFile[] = "Can't read file.";
-const char JSONFileValueSerializer::kFileLocked[] = "File locked.";
-const char JSONFileValueSerializer::kNoSuchFile[] = "File doesn't exist.";
+const char JSONFileValueDeserializer::kAccessDenied[] = "Access denied.";
+const char JSONFileValueDeserializer::kCannotReadFile[] = "Can't read file.";
+const char JSONFileValueDeserializer::kFileLocked[] = "File locked.";
+const char JSONFileValueDeserializer::kNoSuchFile[] = "File doesn't exist.";
JSONFileValueSerializer::JSONFileValueSerializer(
const base::FilePath& json_file_path)
- : json_file_path_(json_file_path),
- allow_trailing_comma_(false),
- last_read_size_(0U) {
+ : json_file_path_(json_file_path) {
}
JSONFileValueSerializer::~JSONFileValueSerializer() {
@@ -53,7 +51,17 @@ bool JSONFileValueSerializer::SerializeInternal(const base::Value& root,
return true;
}
-int JSONFileValueSerializer::ReadFileToString(std::string* json_string) {
+JSONFileValueDeserializer::JSONFileValueDeserializer(
+ const base::FilePath& json_file_path)
+ : json_file_path_(json_file_path),
+ allow_trailing_comma_(false),
+ last_read_size_(0U) {
+}
+
+JSONFileValueDeserializer::~JSONFileValueDeserializer() {
+}
+
+int JSONFileValueDeserializer::ReadFileToString(std::string* json_string) {
DCHECK(json_string);
if (!base::ReadFileToString(json_file_path_, json_string)) {
#if defined(OS_WIN)
@@ -74,7 +82,7 @@ int JSONFileValueSerializer::ReadFileToString(std::string* json_string) {
return JSON_NO_ERROR;
}
-const char* JSONFileValueSerializer::GetErrorMessageForCode(int error_code) {
+const char* JSONFileValueDeserializer::GetErrorMessageForCode(int error_code) {
switch (error_code) {
case JSON_NO_ERROR:
return "";
@@ -92,8 +100,8 @@ const char* JSONFileValueSerializer::GetErrorMessageForCode(int error_code) {
}
}
-base::Value* JSONFileValueSerializer::Deserialize(int* error_code,
- std::string* error_str) {
+base::Value* JSONFileValueDeserializer::Deserialize(int* error_code,
+ std::string* error_str) {
std::string json_string;
int error = ReadFileToString(&json_string);
if (error != JSON_NO_ERROR) {
@@ -104,7 +112,7 @@ base::Value* JSONFileValueSerializer::Deserialize(int* error_code,
return NULL;
}
- JSONStringValueSerializer serializer(json_string);
- serializer.set_allow_trailing_comma(allow_trailing_comma_);
- return serializer.Deserialize(error_code, error_str);
+ JSONStringValueDeserializer deserializer(json_string);
+ deserializer.set_allow_trailing_comma(allow_trailing_comma_);
+ return deserializer.Deserialize(error_code, error_str);
}
« no previous file with comments | « base/json/json_file_value_serializer.h ('k') | base/json/json_string_value_serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698