diff options
75 files changed, 311 insertions, 291 deletions
diff --git a/base/json/json_file_value_serializer.cc b/base/json/json_file_value_serializer.cc index 71033f6..72a0970 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); } diff --git a/base/json/json_file_value_serializer.h b/base/json/json_file_value_serializer.h index 6cfcbe83..aab47ee 100644 --- a/base/json/json_file_value_serializer.h +++ b/base/json/json_file_value_serializer.h @@ -14,10 +14,9 @@ class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer { public: - // |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. + // |json_file_path_| is the path of a file that will be destination of the + // serialization. The serializer will attempt to create the file at the + // specified location. explicit JSONFileValueSerializer(const base::FilePath& json_file_path); ~JSONFileValueSerializer() override; @@ -36,6 +35,22 @@ class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer { // output. bool SerializeAndOmitBinaryValues(const base::Value& root); + private: + bool SerializeInternal(const base::Value& root, bool omit_binary_values); + + const base::FilePath json_file_path_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(JSONFileValueSerializer); +}; + +class BASE_EXPORT JSONFileValueDeserializer : public base::ValueDeserializer { + public: + // |json_file_path_| is the path of a file that will be source of the + // deserialization. + explicit JSONFileValueDeserializer(const base::FilePath& json_file_path); + + ~JSONFileValueDeserializer() override; + // Attempt to deserialize the data structure encoded in the file passed // in to the constructor into a structure of Value objects. If the return // value is NULL, and if |error_code| is non-null, |error_code| will @@ -69,22 +84,20 @@ 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 + // Returns the size (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); + // A wrapper for ReadFileToString which returns a non-zero JsonFileError if + // there were file errors. + int ReadFileToString(std::string* json_string); 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. - int ReadFileToString(std::string* json_string); - - DISALLOW_IMPLICIT_CONSTRUCTORS(JSONFileValueSerializer); + DISALLOW_IMPLICIT_CONSTRUCTORS(JSONFileValueDeserializer); }; #endif // BASE_JSON_JSON_FILE_VALUE_SERIALIZER_H_ diff --git a/base/json/json_string_value_serializer.cc b/base/json/json_string_value_serializer.cc index b626640..debf9f0 100644 --- a/base/json/json_string_value_serializer.cc +++ b/base/json/json_string_value_serializer.cc @@ -12,17 +12,7 @@ using base::Value; JSONStringValueSerializer::JSONStringValueSerializer(std::string* json_string) : json_string_(json_string), - json_string_readonly_(*json_string), - pretty_print_(false), - allow_trailing_comma_(false) { -} - -JSONStringValueSerializer::JSONStringValueSerializer( - const base::StringPiece& json_string) - : json_string_(nullptr), - json_string_readonly_(json_string), - pretty_print_(false), - allow_trailing_comma_(false) { + pretty_print_(false) { } JSONStringValueSerializer::~JSONStringValueSerializer() {} @@ -50,9 +40,17 @@ bool JSONStringValueSerializer::SerializeInternal(const Value& root, return base::JSONWriter::WriteWithOptions(&root, options, json_string_); } -Value* JSONStringValueSerializer::Deserialize(int* error_code, - std::string* error_str) { - return base::JSONReader::ReadAndReturnError(json_string_readonly_, +JSONStringValueDeserializer::JSONStringValueDeserializer( + const base::StringPiece& json_string) + : json_string_(json_string), + allow_trailing_comma_(false) { +} + +JSONStringValueDeserializer::~JSONStringValueDeserializer() {} + +Value* JSONStringValueDeserializer::Deserialize(int* error_code, + std::string* error_str) { + return base::JSONReader::ReadAndReturnError(json_string_, allow_trailing_comma_ ? base::JSON_ALLOW_TRAILING_COMMAS : base::JSON_PARSE_RFC, error_code, error_str); diff --git a/base/json/json_string_value_serializer.h b/base/json/json_string_value_serializer.h index 7f99bc9..bc0e66d 100644 --- a/base/json/json_string_value_serializer.h +++ b/base/json/json_string_value_serializer.h @@ -15,16 +15,11 @@ class BASE_EXPORT JSONStringValueSerializer : public base::ValueSerializer { public: - // |json_string| is the string that will be source of the deserialization - // or the destination of the serialization. The caller of the constructor - // retains ownership of the string. |json_string| must not be null. + // |json_string| is the string that will be the destination of the + // serialization. The caller of the constructor retains ownership of the + // string. |json_string| must not be null. explicit JSONStringValueSerializer(std::string* json_string); - // This version allows initialization with a StringPiece for deserialization - // only. Retains a reference to the contents of |json_string|, so the data - // must outlive the JSONStringValueSerializer. - explicit JSONStringValueSerializer(const base::StringPiece& json_string); - ~JSONStringValueSerializer() override; // Attempt to serialize the data structure represented by Value into @@ -36,6 +31,27 @@ class BASE_EXPORT JSONStringValueSerializer : public base::ValueSerializer { // output. bool SerializeAndOmitBinaryValues(const base::Value& root); + void set_pretty_print(bool new_value) { pretty_print_ = new_value; } + bool pretty_print() { return pretty_print_; } + + private: + bool SerializeInternal(const base::Value& root, bool omit_binary_values); + + // Owned by the caller of the constructor. + std::string* json_string_; + bool pretty_print_; // If true, serialization will span multiple lines. + + DISALLOW_COPY_AND_ASSIGN(JSONStringValueSerializer); +}; + +class BASE_EXPORT JSONStringValueDeserializer : public base::ValueDeserializer { + public: + // This retains a reference to the contents of |json_string|, so the data + // must outlive the JSONStringValueDeserializer. + explicit JSONStringValueDeserializer(const base::StringPiece& json_string); + + ~JSONStringValueDeserializer() override; + // Attempt to deserialize the data structure encoded in the string passed // in to the constructor into a structure of Value objects. If the return // value is null, and if |error_code| is non-null, |error_code| will @@ -46,28 +62,17 @@ class BASE_EXPORT JSONStringValueSerializer : public base::ValueSerializer { base::Value* Deserialize(int* error_code, std::string* error_message) override; - void set_pretty_print(bool new_value) { pretty_print_ = new_value; } - bool pretty_print() { return pretty_print_; } - void set_allow_trailing_comma(bool new_value) { allow_trailing_comma_ = new_value; } private: - bool SerializeInternal(const base::Value& root, bool omit_binary_values); - - // String for writing. Owned by the caller of the constructor. Will be null if - // the serializer was initialized with a const string. - std::string* json_string_; - // String for reading. Data is owned by the caller of the constructor. If - // |json_string_| is non-null, this is a view onto |json_string_|. - base::StringPiece json_string_readonly_; - bool pretty_print_; // If true, serialization will span multiple lines. + // Data is owned by the caller of the constructor. + base::StringPiece json_string_; // If true, deserialization will allow trailing commas. bool allow_trailing_comma_; - DISALLOW_COPY_AND_ASSIGN(JSONStringValueSerializer); + DISALLOW_COPY_AND_ASSIGN(JSONStringValueDeserializer); }; #endif // BASE_JSON_JSON_STRING_VALUE_SERIALIZER_H_ - diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc index d2a84de..225ee67 100644 --- a/base/json/json_value_serializer_unittest.cc +++ b/base/json/json_value_serializer_unittest.cc @@ -86,28 +86,10 @@ void ValidateJsonList(const std::string& json) { ASSERT_EQ(1, value); } -// Test proper JSON [de]serialization from string is working. -TEST(JSONValueSerializerTest, ReadProperJSONFromString) { +// Test proper JSON deserialization from string is working. +TEST(JSONValueDeserializerTest, ReadProperJSONFromString) { // Try to deserialize it through the serializer. - JSONStringValueSerializer str_deserializer(kProperJSON); - - int error_code = 0; - std::string error_message; - scoped_ptr<Value> value( - str_deserializer.Deserialize(&error_code, &error_message)); - ASSERT_TRUE(value.get()); - ASSERT_EQ(0, error_code); - ASSERT_TRUE(error_message.empty()); - // Verify if the same JSON is still there. - CheckJSONIsStillTheSame(*value); -} - -// Test proper JSON deserialization from a string pointer is working. -TEST(JSONValueSerializerTest, ReadProperJSONFromStringPointer) { - // Try to deserialize a string pointer through the serializer. (This exercises - // a separate code path to passing a StringPiece.) - std::string proper_json(kProperJSON); - JSONStringValueSerializer str_deserializer(&proper_json); + JSONStringValueDeserializer str_deserializer(kProperJSON); int error_code = 0; std::string error_message; @@ -121,12 +103,12 @@ TEST(JSONValueSerializerTest, ReadProperJSONFromStringPointer) { } // Test proper JSON deserialization from a StringPiece substring. -TEST(JSONValueSerializerTest, ReadProperJSONFromStringPiece) { +TEST(JSONValueDeserializerTest, ReadProperJSONFromStringPiece) { // Create a StringPiece for the substring of kProperJSONPadded that matches // kProperJSON. base::StringPiece proper_json(kProperJSONPadded); proper_json = proper_json.substr(5, proper_json.length() - 10); - JSONStringValueSerializer str_deserializer(proper_json); + JSONStringValueDeserializer str_deserializer(proper_json); int error_code = 0; std::string error_message; @@ -141,9 +123,9 @@ TEST(JSONValueSerializerTest, ReadProperJSONFromStringPiece) { // Test that trialing commas are only properly deserialized from string when // the proper flag for that is set. -TEST(JSONValueSerializerTest, ReadJSONWithTrailingCommasFromString) { +TEST(JSONValueDeserializerTest, ReadJSONWithTrailingCommasFromString) { // Try to deserialize it through the serializer. - JSONStringValueSerializer str_deserializer(kProperJSONWithCommas); + JSONStringValueDeserializer str_deserializer(kProperJSONWithCommas); int error_code = 0; std::string error_message; @@ -161,8 +143,8 @@ TEST(JSONValueSerializerTest, ReadJSONWithTrailingCommasFromString) { CheckJSONIsStillTheSame(*value); } -// Test proper JSON [de]serialization from file is working. -TEST(JSONValueSerializerTest, ReadProperJSONFromFile) { +// Test proper JSON deserialization from file is working. +TEST(JSONValueDeserializerTest, ReadProperJSONFromFile) { ScopedTempDir tempdir; ASSERT_TRUE(tempdir.CreateUniqueTempDir()); // Write it down in the file. @@ -171,7 +153,7 @@ TEST(JSONValueSerializerTest, ReadProperJSONFromFile) { WriteFile(temp_file, kProperJSON, strlen(kProperJSON))); // Try to deserialize it through the serializer. - JSONFileValueSerializer file_deserializer(temp_file); + JSONFileValueDeserializer file_deserializer(temp_file); int error_code = 0; std::string error_message; @@ -186,7 +168,7 @@ TEST(JSONValueSerializerTest, ReadProperJSONFromFile) { // Test that trialing commas are only properly deserialized from file when // the proper flag for that is set. -TEST(JSONValueSerializerTest, ReadJSONWithCommasFromFile) { +TEST(JSONValueDeserializerTest, ReadJSONWithCommasFromFile) { ScopedTempDir tempdir; ASSERT_TRUE(tempdir.CreateUniqueTempDir()); // Write it down in the file. @@ -196,7 +178,7 @@ TEST(JSONValueSerializerTest, ReadJSONWithCommasFromFile) { strlen(kProperJSONWithCommas))); // Try to deserialize it through the serializer. - JSONFileValueSerializer file_deserializer(temp_file); + JSONFileValueDeserializer file_deserializer(temp_file); // This must fail without the proper flag. int error_code = 0; std::string error_message; @@ -214,11 +196,27 @@ TEST(JSONValueSerializerTest, ReadJSONWithCommasFromFile) { CheckJSONIsStillTheSame(*value); } +TEST(JSONValueDeserializerTest, AllowTrailingComma) { + scoped_ptr<Value> root; + scoped_ptr<Value> root_expected; + static const char kTestWithCommas[] = "{\"key\": [true,],}"; + static const char kTestNoCommas[] = "{\"key\": [true]}"; + + JSONStringValueDeserializer deserializer(kTestWithCommas); + deserializer.set_allow_trailing_comma(true); + JSONStringValueDeserializer deserializer_expected(kTestNoCommas); + root.reset(deserializer.Deserialize(NULL, NULL)); + ASSERT_TRUE(root.get()); + root_expected.reset(deserializer_expected.Deserialize(NULL, NULL)); + ASSERT_TRUE(root_expected.get()); + ASSERT_TRUE(root->Equals(root_expected.get())); +} + TEST(JSONValueSerializerTest, Roundtrip) { static const char kOriginalSerialization[] = "{\"bool\":true,\"double\":3.14,\"int\":42,\"list\":[1,2],\"null\":null}"; - JSONStringValueSerializer serializer(kOriginalSerialization); - scoped_ptr<Value> root(serializer.Deserialize(NULL, NULL)); + JSONStringValueDeserializer deserializer(kOriginalSerialization); + scoped_ptr<Value> root(deserializer.Deserialize(NULL, NULL)); ASSERT_TRUE(root.get()); ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); @@ -241,10 +239,6 @@ TEST(JSONValueSerializerTest, Roundtrip) { ASSERT_TRUE(root_dict->GetDouble("double", &double_value)); ASSERT_DOUBLE_EQ(3.14, double_value); - // We shouldn't be able to write using this serializer, since it was - // initialized with a const string. - ASSERT_FALSE(serializer.Serialize(*root_dict)); - std::string test_serialization; JSONStringValueSerializer mutable_serializer(&test_serialization); ASSERT_TRUE(mutable_serializer.Serialize(*root_dict)); @@ -331,7 +325,7 @@ TEST(JSONValueSerializerTest, UnicodeStrings) { ASSERT_EQ(kExpected, actual); // escaped ascii text -> json - JSONStringValueSerializer deserializer(kExpected); + JSONStringValueDeserializer deserializer(kExpected); scoped_ptr<Value> deserial_root(deserializer.Deserialize(NULL, NULL)); ASSERT_TRUE(deserial_root.get()); DictionaryValue* dict_root = @@ -355,7 +349,7 @@ TEST(JSONValueSerializerTest, HexStrings) { ASSERT_EQ(kExpected, actual); // escaped ascii text -> json - JSONStringValueSerializer deserializer(kExpected); + JSONStringValueDeserializer deserializer(kExpected); scoped_ptr<Value> deserial_root(deserializer.Deserialize(NULL, NULL)); ASSERT_TRUE(deserial_root.get()); DictionaryValue* dict_root = @@ -366,7 +360,7 @@ TEST(JSONValueSerializerTest, HexStrings) { // Test converting escaped regular chars static const char kEscapedChars[] = "{\"test\":\"\\u0067\\u006f\"}"; - JSONStringValueSerializer deserializer2(kEscapedChars); + JSONStringValueDeserializer deserializer2(kEscapedChars); deserial_root.reset(deserializer2.Deserialize(NULL, NULL)); ASSERT_TRUE(deserial_root.get()); dict_root = static_cast<DictionaryValue*>(deserial_root.get()); @@ -374,22 +368,6 @@ TEST(JSONValueSerializerTest, HexStrings) { ASSERT_EQ(ASCIIToUTF16("go"), test_value); } -TEST(JSONValueSerializerTest, AllowTrailingComma) { - scoped_ptr<Value> root; - scoped_ptr<Value> root_expected; - static const char kTestWithCommas[] = "{\"key\": [true,],}"; - static const char kTestNoCommas[] = "{\"key\": [true]}"; - - JSONStringValueSerializer serializer(kTestWithCommas); - serializer.set_allow_trailing_comma(true); - JSONStringValueSerializer serializer_expected(kTestNoCommas); - root.reset(serializer.Deserialize(NULL, NULL)); - ASSERT_TRUE(root.get()); - root_expected.reset(serializer_expected.Deserialize(NULL, NULL)); - ASSERT_TRUE(root_expected.get()); - ASSERT_TRUE(root->Equals(root_expected.get())); -} - TEST(JSONValueSerializerTest, JSONReaderComments) { ValidateJsonList("[ // 2, 3, ignore me ] \n1 ]"); ValidateJsonList("[ /* 2, \n3, ignore me ]*/ \n1 ]"); @@ -435,7 +413,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { ASSERT_TRUE(PathExists(original_file_path)); - JSONFileValueSerializer deserializer(original_file_path); + JSONFileValueDeserializer deserializer(original_file_path); scoped_ptr<Value> root; root.reset(deserializer.Deserialize(NULL, NULL)); @@ -483,7 +461,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { ASSERT_TRUE(PathExists(original_file_path)); - JSONFileValueSerializer deserializer(original_file_path); + JSONFileValueDeserializer deserializer(original_file_path); scoped_ptr<Value> root; root.reset(deserializer.Deserialize(NULL, NULL)); ASSERT_TRUE(root.get()); @@ -508,9 +486,9 @@ TEST_F(JSONFileValueSerializerTest, NoWhitespace) { source_file_path = source_file_path.Append( FILE_PATH_LITERAL("serializer_test_nowhitespace.json")); ASSERT_TRUE(PathExists(source_file_path)); - JSONFileValueSerializer serializer(source_file_path); + JSONFileValueDeserializer deserializer(source_file_path); scoped_ptr<Value> root; - root.reset(serializer.Deserialize(NULL, NULL)); + root.reset(deserializer.Deserialize(NULL, NULL)); ASSERT_TRUE(root.get()); } diff --git a/base/prefs/json_pref_store.cc b/base/prefs/json_pref_store.cc index 0522a45a..2e34b50 100644 --- a/base/prefs/json_pref_store.cc +++ b/base/prefs/json_pref_store.cc @@ -58,16 +58,16 @@ PersistentPrefStore::PrefReadError HandleReadErrors( DVLOG(1) << "Error while loading JSON file: " << error_msg << ", file: " << path.value(); switch (error_code) { - case JSONFileValueSerializer::JSON_ACCESS_DENIED: + case JSONFileValueDeserializer::JSON_ACCESS_DENIED: return PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED; break; - case JSONFileValueSerializer::JSON_CANNOT_READ_FILE: + case JSONFileValueDeserializer::JSON_CANNOT_READ_FILE: return PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER; break; - case JSONFileValueSerializer::JSON_FILE_LOCKED: + case JSONFileValueDeserializer::JSON_FILE_LOCKED: return PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED; break; - case JSONFileValueSerializer::JSON_NO_SUCH_FILE: + case JSONFileValueDeserializer::JSON_NO_SUCH_FILE: return PersistentPrefStore::PREF_READ_ERROR_NO_FILE; break; default: @@ -121,14 +121,14 @@ scoped_ptr<JsonPrefStore::ReadResult> ReadPrefsFromDisk( std::string error_msg; scoped_ptr<JsonPrefStore::ReadResult> read_result( new JsonPrefStore::ReadResult); - JSONFileValueSerializer serializer(path); - read_result->value.reset(serializer.Deserialize(&error_code, &error_msg)); + JSONFileValueDeserializer deserializer(path); + read_result->value.reset(deserializer.Deserialize(&error_code, &error_msg)); read_result->error = HandleReadErrors(read_result->value.get(), path, error_code, error_msg); read_result->no_dir = !base::PathExists(path.DirName()); if (read_result->error == PersistentPrefStore::PREF_READ_ERROR_NONE) - RecordJsonDataSizeHistogram(path, serializer.get_last_read_size()); + RecordJsonDataSizeHistogram(path, deserializer.get_last_read_size()); return read_result.Pass(); } diff --git a/base/test/gtest_util.cc b/base/test/gtest_util.cc index c0bc04a..b811194 100644 --- a/base/test/gtest_util.cc +++ b/base/test/gtest_util.cc @@ -47,7 +47,7 @@ bool WriteCompiledInTestsToFile(const FilePath& path) { bool ReadTestNamesFromFile(const FilePath& path, std::vector<SplitTestName>* output) { - JSONFileValueSerializer deserializer(path); + JSONFileValueDeserializer deserializer(path); int error_code = 0; std::string error_message; scoped_ptr<base::Value> value( @@ -80,4 +80,4 @@ bool ReadTestNamesFromFile(const FilePath& path, return true; } -} // namespace +} // namespace base diff --git a/base/values.cc b/base/values.cc index 061b7a1..52876cf 100644 --- a/base/values.cc +++ b/base/values.cc @@ -1143,6 +1143,9 @@ bool ListValue::Equals(const Value* other) const { ValueSerializer::~ValueSerializer() { } +ValueDeserializer::~ValueDeserializer() { +} + std::ostream& operator<<(std::ostream& out, const Value& value) { std::string json; JSONWriter::WriteWithOptions(&value, diff --git a/base/values.h b/base/values.h index 4648283..1e1cae3 100644 --- a/base/values.h +++ b/base/values.h @@ -492,13 +492,20 @@ class BASE_EXPORT ListValue : public Value { DISALLOW_COPY_AND_ASSIGN(ListValue); }; -// This interface is implemented by classes that know how to serialize and -// deserialize Value objects. +// This interface is implemented by classes that know how to serialize +// Value objects. class BASE_EXPORT ValueSerializer { public: virtual ~ValueSerializer(); virtual bool Serialize(const Value& root) = 0; +}; + +// This interface is implemented by classes that know how to deserialize Value +// objects. +class BASE_EXPORT ValueDeserializer { + public: + virtual ~ValueDeserializer(); // This method deserializes the subclass-specific format into a Value object. // If the return value is non-NULL, the caller takes ownership of returned diff --git a/chrome/browser/chromeos/app_mode/kiosk_external_updater.cc b/chrome/browser/chromeos/app_mode/kiosk_external_updater.cc index 1617cc8..4fcc1ff 100644 --- a/chrome/browser/chromeos/app_mode/kiosk_external_updater.cc +++ b/chrome/browser/chromeos/app_mode/kiosk_external_updater.cc @@ -42,9 +42,9 @@ void ParseExternalUpdateManifest( return; } - JSONFileValueSerializer serializer(manifest); + JSONFileValueDeserializer deserializer(manifest); std::string error_msg; - base::Value* extensions = serializer.Deserialize(NULL, &error_msg); + base::Value* extensions = deserializer.Deserialize(NULL, &error_msg); if (!extensions) { *error_code = KioskExternalUpdater::ERROR_INVALID_MANIFEST; return; diff --git a/chrome/browser/chromeos/app_mode/startup_app_launcher.cc b/chrome/browser/chromeos/app_mode/startup_app_launcher.cc index d43781d..0046295 100644 --- a/chrome/browser/chromeos/app_mode/startup_app_launcher.cc +++ b/chrome/browser/chromeos/app_mode/startup_app_launcher.cc @@ -125,17 +125,17 @@ void StartupAppLauncher::StartLoadingOAuthFile() { // static. void StartupAppLauncher::LoadOAuthFileOnBlockingPool( KioskOAuthParams* auth_params) { - int error_code = JSONFileValueSerializer::JSON_NO_ERROR; + int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; std::string error_msg; base::FilePath user_data_dir; CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); base::FilePath auth_file = user_data_dir.Append(kOAuthFileName); - scoped_ptr<JSONFileValueSerializer> serializer( - new JSONFileValueSerializer(user_data_dir.Append(kOAuthFileName))); + scoped_ptr<JSONFileValueDeserializer> deserializer( + new JSONFileValueDeserializer(user_data_dir.Append(kOAuthFileName))); scoped_ptr<base::Value> value( - serializer->Deserialize(&error_code, &error_msg)); + deserializer->Deserialize(&error_code, &error_msg)); base::DictionaryValue* dict = NULL; - if (error_code != JSONFileValueSerializer::JSON_NO_ERROR || + if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !value.get() || !value->GetAsDictionary(&dict)) { LOG(WARNING) << "Can't find auth file at " << auth_file.value(); return; diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc index 88ed4c2..60c81da 100644 --- a/chrome/browser/chromeos/drive/file_system_util.cc +++ b/chrome/browser/chromeos/drive/file_system_util.cc @@ -58,7 +58,7 @@ std::string ReadStringFromGDocFile(const base::FilePath& file_path, return std::string(); } - JSONFileValueSerializer reader(file_path); + JSONFileValueDeserializer reader(file_path); std::string error_message; scoped_ptr<base::Value> root_value(reader.Deserialize(NULL, &error_message)); if (!root_value) { diff --git a/chrome/browser/chromeos/extensions/default_app_order.cc b/chrome/browser/chromeos/extensions/default_app_order.cc index 71c3874..9b6246f 100644 --- a/chrome/browser/chromeos/extensions/default_app_order.cc +++ b/chrome/browser/chromeos/extensions/default_app_order.cc @@ -63,9 +63,9 @@ base::ListValue* ReadExternalOrdinalFile(const base::FilePath& path) { if (!base::PathExists(path)) return NULL; - JSONFileValueSerializer serializer(path); + JSONFileValueDeserializer deserializer(path); std::string error_msg; - base::Value* value = serializer.Deserialize(NULL, &error_msg); + base::Value* value = deserializer.Deserialize(NULL, &error_msg); if (!value) { LOG(WARNING) << "Unable to deserialize default app ordinals json data:" << error_msg << ", file=" << path.value(); diff --git a/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc b/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc index 9883f07..cc0c287 100644 --- a/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc +++ b/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc @@ -322,8 +322,8 @@ void ComponentExtensionIMEManagerImpl::Unload(Profile* profile, scoped_ptr<base::DictionaryValue> ComponentExtensionIMEManagerImpl::GetManifest( const std::string& manifest_string) { std::string error; - JSONStringValueSerializer serializer(manifest_string); - scoped_ptr<base::Value> manifest(serializer.Deserialize(NULL, &error)); + JSONStringValueDeserializer deserializer(manifest_string); + scoped_ptr<base::Value> manifest(deserializer.Deserialize(NULL, &error)); if (!manifest.get()) LOG(ERROR) << "Failed at getting manifest"; diff --git a/chrome/browser/chromeos/login/supervised/supervised_user_authentication.cc b/chrome/browser/chromeos/login/supervised/supervised_user_authentication.cc index bd65b30..c2ea24d 100644 --- a/chrome/browser/chromeos/login/supervised/supervised_user_authentication.cc +++ b/chrome/browser/chromeos/login/supervised/supervised_user_authentication.cc @@ -55,12 +55,13 @@ std::string BuildRawHMACKey() { } base::DictionaryValue* LoadPasswordData(base::FilePath profile_dir) { - JSONFileValueSerializer serializer(profile_dir.Append(kPasswordUpdateFile)); + JSONFileValueDeserializer deserializer( + profile_dir.Append(kPasswordUpdateFile)); std::string error_message; - int error_code = JSONFileValueSerializer::JSON_NO_ERROR; + int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; scoped_ptr<base::Value> value( - serializer.Deserialize(&error_code, &error_message)); - if (JSONFileValueSerializer::JSON_NO_ERROR != error_code) { + deserializer.Deserialize(&error_code, &error_message)); + if (JSONFileValueDeserializer::JSON_NO_ERROR != error_code) { LOG(ERROR) << "Could not deserialize password data, error = " << error_code << " / " << error_message; return NULL; diff --git a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc index 9a0c708..3e42ead 100644 --- a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc +++ b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc @@ -125,9 +125,9 @@ bool GetLatestPnaclDirectory(const scoped_refptr<PnaclComponentInstaller>& pci, // Read a manifest file in. base::DictionaryValue* ReadJSONManifest(const base::FilePath& manifest_path) { - JSONFileValueSerializer serializer(manifest_path); + JSONFileValueDeserializer deserializer(manifest_path); std::string error; - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error)); if (!root.get()) return NULL; if (!root->IsType(base::Value::TYPE_DICTIONARY)) diff --git a/chrome/browser/component_updater/recovery_component_installer.cc b/chrome/browser/component_updater/recovery_component_installer.cc index 2089805..34e5303 100644 --- a/chrome/browser/component_updater/recovery_component_installer.cc +++ b/chrome/browser/component_updater/recovery_component_installer.cc @@ -90,9 +90,9 @@ bool SimulatingElevatedRecovery() { #if defined(OS_WIN) scoped_ptr<base::DictionaryValue> ReadManifest(const base::FilePath& manifest) { - JSONFileValueSerializer serializer(manifest); + JSONFileValueDeserializer deserializer(manifest); std::string error; - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error)); if (root.get() && root->IsType(base::Value::TYPE_DICTIONARY)) { return scoped_ptr<base::DictionaryValue>( static_cast<base::DictionaryValue*>(root.release())); diff --git a/chrome/browser/component_updater/test/component_installers_unittest.cc b/chrome/browser/component_updater/test/component_installers_unittest.cc index e94ccb7..8cb58d0 100644 --- a/chrome/browser/component_updater/test/component_installers_unittest.cc +++ b/chrome/browser/component_updater/test/component_installers_unittest.cc @@ -73,10 +73,10 @@ TEST(ComponentInstallerTest, PepperFlashCheck) { return; } - JSONFileValueSerializer serializer(manifest); + JSONFileValueDeserializer deserializer(manifest); std::string error; scoped_ptr<base::DictionaryValue> root(static_cast<base::DictionaryValue*>( - serializer.Deserialize(NULL, &error))); + deserializer.Deserialize(NULL, &error))); ASSERT_TRUE(root); ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc index 7b09d86..a0575db 100644 --- a/chrome/browser/diagnostics/recon_diagnostics.cc +++ b/chrome/browser/diagnostics/recon_diagnostics.cc @@ -210,7 +210,7 @@ class JSONTest : public DiagnosticsTest { return true; } - JSONStringValueSerializer json(json_data); + JSONStringValueDeserializer json(json_data); int error_code = base::JSONReader::JSON_NO_ERROR; std::string error_message; scoped_ptr<base::Value> json_root( diff --git a/chrome/browser/drive/fake_drive_service.cc b/chrome/browser/drive/fake_drive_service.cc index f34c0d6..7f9b585 100644 --- a/chrome/browser/drive/fake_drive_service.cc +++ b/chrome/browser/drive/fake_drive_service.cc @@ -280,7 +280,7 @@ void FakeDriveService::AddApp(const std::string& app_id, ReplaceSubstringsAfterOffset( &app_json, 0, "$Removable", is_removable ? "true" : "false"); - JSONStringValueSerializer json(app_json); + JSONStringValueDeserializer json(app_json); std::string error_message; scoped_ptr<base::Value> value(json.Deserialize(NULL, &error_message)); CHECK_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); diff --git a/chrome/browser/extensions/api/messaging/native_messaging_host_manifest.cc b/chrome/browser/extensions/api/messaging/native_messaging_host_manifest.cc index 5366620..8479b13 100644 --- a/chrome/browser/extensions/api/messaging/native_messaging_host_manifest.cc +++ b/chrome/browser/extensions/api/messaging/native_messaging_host_manifest.cc @@ -43,8 +43,8 @@ scoped_ptr<NativeMessagingHostManifest> NativeMessagingHostManifest::Load( std::string* error_message) { DCHECK(error_message); - JSONFileValueSerializer serializer(file_path); - scoped_ptr<base::Value> parsed(serializer.Deserialize(NULL, error_message)); + JSONFileValueDeserializer deserializer(file_path); + scoped_ptr<base::Value> parsed(deserializer.Deserialize(NULL, error_message)); if (!parsed) { return scoped_ptr<NativeMessagingHostManifest>(); } diff --git a/chrome/browser/extensions/chrome_info_map_unittest.cc b/chrome/browser/extensions/chrome_info_map_unittest.cc index 4a3eb1c..5ee4a1f 100644 --- a/chrome/browser/extensions/chrome_info_map_unittest.cc +++ b/chrome/browser/extensions/chrome_info_map_unittest.cc @@ -24,8 +24,8 @@ scoped_refptr<Extension> LoadManifest(const std::string& dir, PathService::Get(chrome::DIR_TEST_DATA, &path); path = path.AppendASCII("extensions").AppendASCII(dir).AppendASCII(test_file); - JSONFileValueSerializer serializer(path); - scoped_ptr<base::Value> result(serializer.Deserialize(NULL, NULL)); + JSONFileValueDeserializer deserializer(path); + scoped_ptr<base::Value> result(deserializer.Deserialize(NULL, NULL)); if (!result) return NULL; diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc index 3c40959..ed34824 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -144,8 +144,8 @@ void ComponentLoader::LoadAll() { base::DictionaryValue* ComponentLoader::ParseManifest( const std::string& manifest_contents) const { - JSONStringValueSerializer serializer(manifest_contents); - scoped_ptr<base::Value> manifest(serializer.Deserialize(NULL, NULL)); + JSONStringValueDeserializer deserializer(manifest_contents); + scoped_ptr<base::Value> manifest(deserializer.Deserialize(NULL, NULL)); if (!manifest.get() || !manifest->IsType(base::Value::TYPE_DICTIONARY)) { LOG(ERROR) << "Failed to parse extension manifest."; diff --git a/chrome/browser/extensions/extension_action_icon_factory_unittest.cc b/chrome/browser/extensions/extension_action_icon_factory_unittest.cc index 4292ed4..3d45e15 100644 --- a/chrome/browser/extensions/extension_action_icon_factory_unittest.cc +++ b/chrome/browser/extensions/extension_action_icon_factory_unittest.cc @@ -107,10 +107,12 @@ class ExtensionActionIconFactoryTest test_file = test_file.AppendASCII("extensions/api_test").AppendASCII(name); int error_code = 0; std::string error; - JSONFileValueSerializer serializer(test_file.AppendASCII("manifest.json")); + JSONFileValueDeserializer deserializer( + test_file.AppendASCII("manifest.json")); scoped_ptr<base::DictionaryValue> valid_value( - static_cast<base::DictionaryValue*>(serializer.Deserialize(&error_code, - &error))); + static_cast<base::DictionaryValue*>( + deserializer.Deserialize(&error_code, + &error))); EXPECT_EQ(0, error_code) << error; if (error_code != 0) return NULL; diff --git a/chrome/browser/extensions/extension_icon_manager_unittest.cc b/chrome/browser/extensions/extension_icon_manager_unittest.cc index 36dbf5a..004c196 100644 --- a/chrome/browser/extensions/extension_icon_manager_unittest.cc +++ b/chrome/browser/extensions/extension_icon_manager_unittest.cc @@ -108,9 +108,10 @@ TEST_F(ExtensionIconManagerTest, LoadRemoveLoad) { base::FilePath manifest_path = test_dir.AppendASCII( "extensions/image_loading_tracker/app.json"); - JSONFileValueSerializer serializer(manifest_path); + JSONFileValueDeserializer deserializer(manifest_path); scoped_ptr<base::DictionaryValue> manifest( - static_cast<base::DictionaryValue*>(serializer.Deserialize(NULL, NULL))); + static_cast<base::DictionaryValue*>(deserializer.Deserialize(NULL, + NULL))); ASSERT_TRUE(manifest.get() != NULL); std::string error; @@ -150,9 +151,10 @@ TEST_F(ExtensionIconManagerTest, LoadComponentExtensionResource) { base::FilePath manifest_path = test_dir.AppendASCII( "extensions/file_manager/app.json"); - JSONFileValueSerializer serializer(manifest_path); + JSONFileValueDeserializer deserializer(manifest_path); scoped_ptr<base::DictionaryValue> manifest( - static_cast<base::DictionaryValue*>(serializer.Deserialize(NULL, NULL))); + static_cast<base::DictionaryValue*>(deserializer.Deserialize(NULL, + NULL))); ASSERT_TRUE(manifest.get() != NULL); std::string error; diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index a3ad60b..39d6514 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -353,8 +353,8 @@ class MockProviderVisitor // We also parse the file into a dictionary to compare what we get back // from the provider. - JSONStringValueSerializer serializer(json_data); - base::Value* json_value = serializer.Deserialize(NULL, NULL); + JSONStringValueDeserializer deserializer(json_data); + base::Value* json_value = deserializer.Deserialize(NULL, NULL); if (!json_value || !json_value->IsType(base::Value::TYPE_DICTIONARY)) { NOTREACHED() << "Unable to deserialize json data"; diff --git a/chrome/browser/extensions/extension_ui_unittest.cc b/chrome/browser/extensions/extension_ui_unittest.cc index 76d643d..0b6c17d 100644 --- a/chrome/browser/extensions/extension_ui_unittest.cc +++ b/chrome/browser/extensions/extension_ui_unittest.cc @@ -70,8 +70,8 @@ class ExtensionUITest : public testing::Test { std::string *error) { base::Value* value; - JSONFileValueSerializer serializer(path); - value = serializer.Deserialize(NULL, error); + JSONFileValueDeserializer deserializer(path); + value = deserializer.Deserialize(NULL, error); return static_cast<base::DictionaryValue*>(value); } diff --git a/chrome/browser/extensions/external_pref_loader.cc b/chrome/browser/extensions/external_pref_loader.cc index 9e052d0..8e9a1336 100644 --- a/chrome/browser/extensions/external_pref_loader.cc +++ b/chrome/browser/extensions/external_pref_loader.cc @@ -70,10 +70,11 @@ std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( // occurs). An empty dictionary is returned in case of failure (e.g. invalid // path or json content). // Caller takes ownership of the returned dictionary. -base::DictionaryValue* ExtractExtensionPrefs(base::ValueSerializer* serializer, - const base::FilePath& path) { +base::DictionaryValue* ExtractExtensionPrefs( + base::ValueDeserializer* deserializer, + const base::FilePath& path) { std::string error_msg; - base::Value* extensions = serializer->Deserialize(NULL, &error_msg); + base::Value* extensions = deserializer->Deserialize(NULL, &error_msg); if (!extensions) { LOG(WARNING) << "Unable to deserialize json data: " << error_msg << " in file " << path.value() << "."; @@ -254,9 +255,9 @@ void ExternalPrefLoader::ReadExternalExtensionPrefFile( #endif // defined(OS_MACOSX) } - JSONFileValueSerializer serializer(json_file); + JSONFileValueDeserializer deserializer(json_file); scoped_ptr<base::DictionaryValue> ext_prefs( - ExtractExtensionPrefs(&serializer, json_file)); + ExtractExtensionPrefs(&deserializer, json_file)); if (ext_prefs) prefs->MergeDictionary(ext_prefs.get()); } @@ -292,9 +293,9 @@ void ExternalPrefLoader::ReadStandaloneExtensionPrefFiles( DVLOG(1) << "Reading json file: " << extension_candidate_path.LossyDisplayName(); - JSONFileValueSerializer serializer(extension_candidate_path); + JSONFileValueDeserializer deserializer(extension_candidate_path); scoped_ptr<base::DictionaryValue> ext_prefs( - ExtractExtensionPrefs(&serializer, extension_candidate_path)); + ExtractExtensionPrefs(&deserializer, extension_candidate_path)); if (ext_prefs) { DVLOG(1) << "Adding extension with id: " << id; prefs->Set(id, ext_prefs.release()); @@ -307,9 +308,9 @@ ExternalTestingLoader::ExternalTestingLoader( const base::FilePath& fake_base_path) : fake_base_path_(fake_base_path) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - JSONStringValueSerializer serializer(json_data); + JSONStringValueDeserializer deserializer(json_data); base::FilePath fake_json_path = fake_base_path.AppendASCII("fake.json"); - testing_prefs_.reset(ExtractExtensionPrefs(&serializer, fake_json_path)); + testing_prefs_.reset(ExtractExtensionPrefs(&deserializer, fake_json_path)); } void ExternalTestingLoader::StartLoading() { diff --git a/chrome/browser/extensions/user_script_listener_unittest.cc b/chrome/browser/extensions/user_script_listener_unittest.cc index a8269f3..40a4406 100644 --- a/chrome/browser/extensions/user_script_listener_unittest.cc +++ b/chrome/browser/extensions/user_script_listener_unittest.cc @@ -77,9 +77,9 @@ class SimpleTestJob : public net::URLRequestTestJob { base::DictionaryValue* LoadManifestFile(const base::FilePath path, std::string* error) { EXPECT_TRUE(base::PathExists(path)); - JSONFileValueSerializer serializer(path); + JSONFileValueDeserializer deserializer(path); return static_cast<base::DictionaryValue*>( - serializer.Deserialize(NULL, error)); + deserializer.Deserialize(NULL, error)); } scoped_refptr<Extension> LoadExtension(const std::string& filename, diff --git a/chrome/browser/prefs/leveldb_pref_store.cc b/chrome/browser/prefs/leveldb_pref_store.cc index 86666b1..f397b08 100644 --- a/chrome/browser/prefs/leveldb_pref_store.cc +++ b/chrome/browser/prefs/leveldb_pref_store.cc @@ -167,7 +167,7 @@ scoped_ptr<LevelDBPrefStore::ReadingResults> LevelDBPrefStore::DoReading( // TODO(dgrogan): Is it really necessary to check it->status() each iteration? for (it->SeekToFirst(); it->Valid() && it->status().ok(); it->Next()) { const std::string value_string = it->value().ToString(); - JSONStringValueSerializer deserializer(value_string); + JSONStringValueDeserializer deserializer(value_string); std::string error_message; int error_code; base::Value* json_value = diff --git a/chrome/browser/prefs/pref_service_browsertest.cc b/chrome/browser/prefs/pref_service_browsertest.cc index 1a87b04..47e1007 100644 --- a/chrome/browser/prefs/pref_service_browsertest.cc +++ b/chrome/browser/prefs/pref_service_browsertest.cc @@ -101,7 +101,7 @@ IN_PROC_BROWSER_TEST_F(PreferenceServiceTest, Test) { // The window should open with the new reference profile, with window // placement values stored in the user data directory. - JSONFileValueSerializer deserializer(original_pref_file_); + JSONFileValueDeserializer deserializer(original_pref_file_); scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); ASSERT_TRUE(root.get()); diff --git a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc index 5a8e5ce..3608606 100644 --- a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc +++ b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc @@ -85,12 +85,12 @@ int GetTrackedPrefHistogramCount(const char* histogram_name, scoped_ptr<base::DictionaryValue> ReadPrefsDictionary( const base::FilePath& pref_file) { - JSONFileValueSerializer serializer(pref_file); - int error_code = JSONFileValueSerializer::JSON_NO_ERROR; + JSONFileValueDeserializer deserializer(pref_file); + int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; std::string error_str; scoped_ptr<base::Value> prefs( - serializer.Deserialize(&error_code, &error_str)); - if (!prefs || error_code != JSONFileValueSerializer::JSON_NO_ERROR) { + deserializer.Deserialize(&error_code, &error_str)); + if (!prefs || error_code != JSONFileValueDeserializer::JSON_NO_ERROR) { ADD_FAILURE() << "Error #" << error_code << ": " << error_str; return scoped_ptr<base::DictionaryValue>(); } diff --git a/chrome/browser/profile_resetter/brandcoded_default_settings.cc b/chrome/browser/profile_resetter/brandcoded_default_settings.cc index 7d7f2cc..20145fb 100644 --- a/chrome/browser/profile_resetter/brandcoded_default_settings.cc +++ b/chrome/browser/profile_resetter/brandcoded_default_settings.cc @@ -16,7 +16,7 @@ BrandcodedDefaultSettings::BrandcodedDefaultSettings() { BrandcodedDefaultSettings::BrandcodedDefaultSettings(const std::string& prefs) { if (!prefs.empty()) { - JSONStringValueSerializer json(prefs); + JSONStringValueDeserializer json(prefs); std::string error; scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); if (!root.get()) { diff --git a/chrome/browser/profile_resetter/profile_resetter_unittest.cc b/chrome/browser/profile_resetter/profile_resetter_unittest.cc index 7baa510..3804d1d 100644 --- a/chrome/browser/profile_resetter/profile_resetter_unittest.cc +++ b/chrome/browser/profile_resetter/profile_resetter_unittest.cc @@ -960,7 +960,7 @@ TEST_F(ProfileResetterTest, FeedbackSerializationTest) { for (int field_mask = 0; field_mask <= ResettableSettingsSnapshot::ALL_FIELDS; ++field_mask) { std::string report = SerializeSettingsReport(nonorganic_snap, field_mask); - JSONStringValueSerializer json(report); + JSONStringValueDeserializer json(report); std::string error; scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); ASSERT_TRUE(root) << error; diff --git a/chrome/browser/supervised_user/supervised_user_site_list.cc b/chrome/browser/supervised_user/supervised_user_site_list.cc index b74af9f..90c31e1 100644 --- a/chrome/browser/supervised_user/supervised_user_site_list.cc +++ b/chrome/browser/supervised_user/supervised_user_site_list.cc @@ -140,9 +140,9 @@ void SupervisedUserSiteList::ParseJson( const SupervisedUserSiteList::LoadedCallback& callback, const std::string& json) { if (g_load_in_process) { - JSONFileValueSerializer serializer(path); + JSONFileValueDeserializer deserializer(path); std::string error; - scoped_ptr<base::Value> value(serializer.Deserialize(nullptr, &error)); + scoped_ptr<base::Value> value(deserializer.Deserialize(nullptr, &error)); if (!value) { HandleError(path, error); return; diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc index 6b7ff7d5..67af484 100644 --- a/chrome/browser/themes/browser_theme_pack_unittest.cc +++ b/chrome/browser/themes/browser_theme_pack_unittest.cc @@ -154,10 +154,10 @@ class BrowserThemePackTest : public ::testing::Test { base::FilePath manifest_path = extension_path.AppendASCII("manifest.json"); std::string error; - JSONFileValueSerializer serializer(manifest_path); + JSONFileValueDeserializer deserializer(manifest_path); scoped_ptr<base::DictionaryValue> valid_value( static_cast<base::DictionaryValue*>( - serializer.Deserialize(NULL, &error))); + deserializer.Deserialize(NULL, &error))); EXPECT_EQ("", error); ASSERT_TRUE(valid_value.get()); scoped_refptr<Extension> extension( diff --git a/chrome/browser/ui/app_list/start_page_service.cc b/chrome/browser/ui/app_list/start_page_service.cc index 25338e4..8af8b47 100644 --- a/chrome/browser/ui/app_list/start_page_service.cc +++ b/chrome/browser/ui/app_list/start_page_service.cc @@ -661,7 +661,7 @@ void StartPageService::OnURLFetchComplete(const net::URLFetcher* source) { if (json_start_index != std::string::npos) json_data_substr.remove_prefix(json_start_index); - JSONStringValueSerializer deserializer(json_data_substr); + JSONStringValueDeserializer deserializer(json_data_substr); deserializer.set_allow_trailing_comma(true); int error_code = 0; scoped_ptr<base::Value> doodle_json( diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.mm b/chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.mm index cb77cb9..bbfc886 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.mm @@ -35,9 +35,9 @@ scoped_refptr<extensions::Extension> LoadInstallPromptExtension( .AppendASCII(manifest_file); std::string error; - JSONFileValueSerializer serializer(path); + JSONFileValueDeserializer deserializer(path); scoped_ptr<base::DictionaryValue> value(static_cast<base::DictionaryValue*>( - serializer.Deserialize(NULL, &error))); + deserializer.Deserialize(NULL, &error))); if (!value.get()) { LOG(ERROR) << error; return extension; diff --git a/chrome/browser/ui/webui/nacl_ui.cc b/chrome/browser/ui/webui/nacl_ui.cc index d844a40..26482c7 100644 --- a/chrome/browser/ui/webui/nacl_ui.cc +++ b/chrome/browser/ui/webui/nacl_ui.cc @@ -328,9 +328,9 @@ void NaClDomHandler::DidCheckPathAndVersion(const std::string* version, void CheckVersion(const base::FilePath& pnacl_path, std::string* version) { base::FilePath pnacl_json_path = pnacl_path.AppendASCII("pnacl_public_pnacl_json"); - JSONFileValueSerializer serializer(pnacl_json_path); + JSONFileValueDeserializer deserializer(pnacl_json_path); std::string error; - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error)); if (!root || !root->IsType(base::Value::TYPE_DICTIONARY)) return; diff --git a/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc b/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc index 7fb2c96..785b2a6 100644 --- a/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc +++ b/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc @@ -165,7 +165,7 @@ void RecordPrintResult(size_t* call_count, scoped_ptr<base::ListValue> GetJSONAsListValue(const std::string& json, std::string* error) { scoped_ptr<base::Value> deserialized( - JSONStringValueSerializer(json).Deserialize(NULL, error)); + JSONStringValueDeserializer(json).Deserialize(NULL, error)); if (!deserialized) return scoped_ptr<base::ListValue>(); base::ListValue* list = nullptr; @@ -182,7 +182,7 @@ scoped_ptr<base::DictionaryValue> GetJSONAsDictionaryValue( const std::string& json, std::string* error) { scoped_ptr<base::Value> deserialized( - JSONStringValueSerializer(json).Deserialize(NULL, error)); + JSONStringValueDeserializer(json).Deserialize(NULL, error)); if (!deserialized) return scoped_ptr<base::DictionaryValue>(); base::DictionaryValue* dictionary; diff --git a/chrome/common/extensions/extension_test_util.cc b/chrome/common/extensions/extension_test_util.cc index e30dd15..ec223f6 100644 --- a/chrome/common/extensions/extension_test_util.cc +++ b/chrome/common/extensions/extension_test_util.cc @@ -30,8 +30,8 @@ scoped_refptr<Extension> LoadManifestUnchecked(const std::string& dir, .AppendASCII(dir) .AppendASCII(test_file); - JSONFileValueSerializer serializer(path); - scoped_ptr<base::Value> result(serializer.Deserialize(NULL, error)); + JSONFileValueDeserializer deserializer(path); + scoped_ptr<base::Value> result(deserializer.Deserialize(NULL, error)); if (!result) return NULL; const base::DictionaryValue* dict; diff --git a/chrome/common/extensions/manifest_handlers/settings_overrides_handler_unittest.cc b/chrome/common/extensions/manifest_handlers/settings_overrides_handler_unittest.cc index 9d60a63..82bda5a 100644 --- a/chrome/common/extensions/manifest_handlers/settings_overrides_handler_unittest.cc +++ b/chrome/common/extensions/manifest_handlers/settings_overrides_handler_unittest.cc @@ -74,7 +74,7 @@ class OverrideSettingsTest : public testing::Test { TEST_F(OverrideSettingsTest, ParseManifest) { std::string manifest(kManifest); - JSONStringValueSerializer json(&manifest); + JSONStringValueDeserializer json(manifest); std::string error; scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); ASSERT_TRUE(root); @@ -117,7 +117,7 @@ TEST_F(OverrideSettingsTest, ParseManifest) { TEST_F(OverrideSettingsTest, ParsePrepopulatedId) { std::string manifest(kPrepopulatedManifest); - JSONStringValueSerializer json(&manifest); + JSONStringValueDeserializer json(manifest); std::string error; scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); ASSERT_TRUE(root); @@ -150,7 +150,7 @@ TEST_F(OverrideSettingsTest, ParsePrepopulatedId) { TEST_F(OverrideSettingsTest, ParseBrokenManifest) { std::string manifest(kBrokenManifest); - JSONStringValueSerializer json(&manifest); + JSONStringValueDeserializer json(manifest); std::string error; scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); ASSERT_TRUE(root); diff --git a/chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc b/chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc index 007d102..75a6857 100644 --- a/chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc +++ b/chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc @@ -50,7 +50,7 @@ TEST_F(UIOverrideTest, ParseManifest) { base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( "--enable-override-bookmarks-ui", "1"); std::string manifest(kManifest); - JSONStringValueSerializer json(&manifest); + JSONStringValueDeserializer json(manifest); std::string error; scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); ASSERT_TRUE(root); @@ -78,7 +78,7 @@ TEST_F(UIOverrideTest, ParseBrokenManifest) { base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( "--enable-override-bookmarks-ui", "1"); std::string manifest(kBrokenManifest); - JSONStringValueSerializer json(&manifest); + JSONStringValueDeserializer json(manifest); std::string error; scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); ASSERT_TRUE(root); diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc index bcb6b8b..ec71d23 100644 --- a/chrome/installer/util/master_preferences.cc +++ b/chrome/installer/util/master_preferences.cc @@ -51,7 +51,7 @@ std::vector<std::string> GetNamedList(const char* name, base::DictionaryValue* ParseDistributionPreferences( const std::string& json_data) { - JSONStringValueSerializer json(json_data); + JSONStringValueDeserializer json(json_data); std::string error; scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); if (!root.get()) { diff --git a/chrome/installer/util/uninstall_metrics.cc b/chrome/installer/util/uninstall_metrics.cc index da8ca03..fe2ee43 100644 --- a/chrome/installer/util/uninstall_metrics.cc +++ b/chrome/installer/util/uninstall_metrics.cc @@ -74,10 +74,10 @@ bool ExtractUninstallMetrics(const base::DictionaryValue& root, bool ExtractUninstallMetricsFromFile(const base::FilePath& file_path, base::string16* uninstall_metrics_string) { - JSONFileValueSerializer json_serializer(file_path); + JSONFileValueDeserializer json_deserializer(file_path); std::string json_error_string; - scoped_ptr<base::Value> root(json_serializer.Deserialize(NULL, NULL)); + scoped_ptr<base::Value> root(json_deserializer.Deserialize(NULL, NULL)); if (!root.get()) return false; diff --git a/chrome/installer/util/uninstall_metrics_unittest.cc b/chrome/installer/util/uninstall_metrics_unittest.cc index 621b0db..aa0ff15 100644 --- a/chrome/installer/util/uninstall_metrics_unittest.cc +++ b/chrome/installer/util/uninstall_metrics_unittest.cc @@ -43,7 +43,7 @@ TEST(UninstallMetricsTest, TestExtractUninstallMetrics) { L"&launch_count=11&page_load_count=68" L"&uptime_sec=809"); - JSONStringValueSerializer json_deserializer(pref_string); + JSONStringValueDeserializer json_deserializer(pref_string); std::string error_message; scoped_ptr<base::Value> root( diff --git a/chrome/utility/importer/firefox_importer.cc b/chrome/utility/importer/firefox_importer.cc index 8e4aa72..97c530a 100644 --- a/chrome/utility/importer/firefox_importer.cc +++ b/chrome/utility/importer/firefox_importer.cc @@ -538,9 +538,9 @@ void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( // file exists only if the user has set keywords for search engines. base::FilePath search_metadata_json_file = source_path_.AppendASCII("search-metadata.json"); - JSONFileValueSerializer metadata_serializer(search_metadata_json_file); + JSONFileValueDeserializer metadata_deserializer(search_metadata_json_file); scoped_ptr<base::Value> metadata_root( - metadata_serializer.Deserialize(NULL, NULL)); + metadata_deserializer.Deserialize(NULL, NULL)); const base::DictionaryValue* search_metadata_root = NULL; if (metadata_root) metadata_root->GetAsDictionary(&search_metadata_root); @@ -550,8 +550,8 @@ void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( if (!base::PathExists(search_json_file)) return; - JSONFileValueSerializer serializer(search_json_file); - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, NULL)); + JSONFileValueDeserializer deserializer(search_json_file); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); const base::DictionaryValue* search_root = NULL; if (!root || !root->GetAsDictionary(&search_root)) return; diff --git a/chromeos/app_mode/kiosk_oem_manifest_parser.cc b/chromeos/app_mode/kiosk_oem_manifest_parser.cc index 77d79fb..f13d1a8 100644 --- a/chromeos/app_mode/kiosk_oem_manifest_parser.cc +++ b/chromeos/app_mode/kiosk_oem_manifest_parser.cc @@ -28,14 +28,14 @@ KioskOemManifestParser::Manifest::Manifest() bool KioskOemManifestParser::Load( const base::FilePath& kiosk_oem_file, KioskOemManifestParser::Manifest* manifest) { - int error_code = JSONFileValueSerializer::JSON_NO_ERROR; + int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; std::string error_msg; - scoped_ptr<JSONFileValueSerializer> serializer( - new JSONFileValueSerializer(kiosk_oem_file)); + scoped_ptr<JSONFileValueDeserializer> deserializer( + new JSONFileValueDeserializer(kiosk_oem_file)); scoped_ptr<base::Value> value( - serializer->Deserialize(&error_code, &error_msg)); + deserializer->Deserialize(&error_code, &error_msg)); base::DictionaryValue* dict = NULL; - if (error_code != JSONFileValueSerializer::JSON_NO_ERROR || + if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !value.get() || !value->GetAsDictionary(&dict)) { return false; diff --git a/chromeos/dbus/fake_easy_unlock_client.cc b/chromeos/dbus/fake_easy_unlock_client.cc index ee741fb..7744188 100644 --- a/chromeos/dbus/fake_easy_unlock_client.cc +++ b/chromeos/dbus/fake_easy_unlock_client.cc @@ -20,8 +20,8 @@ const char kEc256PublicKeyKey[] = "ec_p256_public_key"; // Extracts key pair index from a key in format "<key_type>: <key_pair_index>}". int ExtractKeyPairIndexFromKey(const std::string& key, const std::string& key_type) { - JSONStringValueSerializer serializer(key); - scoped_ptr<base::Value> json_value(serializer.Deserialize(NULL, NULL)); + JSONStringValueDeserializer deserializer(key); + scoped_ptr<base::Value> json_value(deserializer.Deserialize(NULL, NULL)); if (!json_value) return -1; diff --git a/chromeos/network/onc/onc_test_utils.cc b/chromeos/network/onc/onc_test_utils.cc index 56e5bc6..522a9ed 100644 --- a/chromeos/network/onc/onc_test_utils.cc +++ b/chromeos/network/onc/onc_test_utils.cc @@ -48,11 +48,11 @@ scoped_ptr<base::DictionaryValue> ReadTestDictionary( return make_scoped_ptr(dict); } - JSONFileValueSerializer serializer(path); - serializer.set_allow_trailing_comma(true); + JSONFileValueDeserializer deserializer(path); + deserializer.set_allow_trailing_comma(true); std::string error_message; - base::Value* content = serializer.Deserialize(NULL, &error_message); + base::Value* content = deserializer.Deserialize(NULL, &error_message); CHECK(content != NULL) << "Couldn't json-deserialize file '" << filename << "': " << error_message; diff --git a/chromeos/tools/onc_validator/onc_validator.cc b/chromeos/tools/onc_validator/onc_validator.cc index d47597e..84a9220 100644 --- a/chromeos/tools/onc_validator/onc_validator.cc +++ b/chromeos/tools/onc_validator/onc_validator.cc @@ -84,13 +84,13 @@ void PrintHelp() { scoped_ptr<base::DictionaryValue> ReadDictionary(std::string filename) { base::FilePath path(filename); - JSONFileValueSerializer serializer(path); - serializer.set_allow_trailing_comma(true); + JSONFileValueDeserializer deserializer(path); + deserializer.set_allow_trailing_comma(true); base::DictionaryValue* dict = NULL; std::string json_error; - base::Value* value = serializer.Deserialize(NULL, &json_error); + base::Value* value = deserializer.Deserialize(NULL, &json_error); if (!value) { LOG(ERROR) << "Couldn't json-deserialize file '" << filename << "': " << json_error; diff --git a/components/bookmarks/browser/bookmark_codec.cc b/components/bookmarks/browser/bookmark_codec.cc index 0392c47..9ea5ae4 100644 --- a/components/bookmarks/browser/bookmark_codec.cc +++ b/components/bookmarks/browser/bookmark_codec.cc @@ -386,8 +386,8 @@ bool BookmarkCodec::DecodeMetaInfo(const base::DictionaryValue& value, if (meta_info->IsType(base::Value::TYPE_STRING)) { std::string meta_info_str; meta_info->GetAsString(&meta_info_str); - JSONStringValueSerializer serializer(meta_info_str); - deserialized_holder.reset(serializer.Deserialize(nullptr, nullptr)); + JSONStringValueDeserializer deserializer(meta_info_str); + deserialized_holder.reset(deserializer.Deserialize(nullptr, nullptr)); if (!deserialized_holder) return false; meta_info = deserialized_holder.get(); diff --git a/components/bookmarks/browser/bookmark_codec_unittest.cc b/components/bookmarks/browser/bookmark_codec_unittest.cc index 9d529f8..8c45aea 100644 --- a/components/bookmarks/browser/bookmark_codec_unittest.cc +++ b/components/bookmarks/browser/bookmark_codec_unittest.cc @@ -359,8 +359,8 @@ TEST_F(BookmarkCodecTest, CanDecodeModelWithoutMobileBookmarks) { GetTestDataDir().AppendASCII("bookmarks/model_without_sync.json"); ASSERT_TRUE(base::PathExists(test_file)); - JSONFileValueSerializer serializer(test_file); - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, NULL)); + JSONFileValueDeserializer deserializer(test_file); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); scoped_ptr<BookmarkModel> decoded_model(client_.CreateModel()); BookmarkCodec decoder; @@ -445,8 +445,8 @@ TEST_F(BookmarkCodecTest, CanDecodeMetaInfoAsString) { GetTestDataDir().AppendASCII("bookmarks/meta_info_as_string.json"); ASSERT_TRUE(base::PathExists(test_file)); - JSONFileValueSerializer serializer(test_file); - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, NULL)); + JSONFileValueDeserializer deserializer(test_file); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); scoped_ptr<BookmarkModel> model(client_.CreateModel()); BookmarkCodec decoder; diff --git a/components/bookmarks/browser/bookmark_storage.cc b/components/bookmarks/browser/bookmark_storage.cc index b377069..daafdbe 100644 --- a/components/bookmarks/browser/bookmark_storage.cc +++ b/components/bookmarks/browser/bookmark_storage.cc @@ -56,8 +56,8 @@ void LoadCallback(const base::FilePath& path, bool load_index = false; bool bookmark_file_exists = base::PathExists(path); if (bookmark_file_exists) { - JSONFileValueSerializer serializer(path); - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, NULL)); + JSONFileValueDeserializer deserializer(path); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); if (root.get()) { // Building the index can take a while, so we do it on the background diff --git a/components/json_schema/json_schema_validator_unittest_base.cc b/components/json_schema/json_schema_validator_unittest_base.cc index 8d2859e..6a5f853 100644 --- a/components/json_schema/json_schema_validator_unittest_base.cc +++ b/components/json_schema/json_schema_validator_unittest_base.cc @@ -36,8 +36,8 @@ base::Value* LoadValue(const std::string& filename) { EXPECT_TRUE(base::PathExists(path)); std::string error_message; - JSONFileValueSerializer serializer(path); - base::Value* result = serializer.Deserialize(NULL, &error_message); + JSONFileValueDeserializer deserializer(path); + base::Value* result = deserializer.Deserialize(NULL, &error_message); if (!result) ADD_FAILURE() << "Could not parse JSON: " << error_message; return result; diff --git a/components/omnibox/search_suggestion_parser.cc b/components/omnibox/search_suggestion_parser.cc index a382c6b..27cc63b 100644 --- a/components/omnibox/search_suggestion_parser.cc +++ b/components/omnibox/search_suggestion_parser.cc @@ -351,7 +351,7 @@ scoped_ptr<base::Value> SearchSuggestionParser::DeserializeJsonData( // Remove any XSSI guards to allow for JSON parsing. json_data.remove_prefix(response_start_index); - JSONStringValueSerializer deserializer(json_data); + JSONStringValueDeserializer deserializer(json_data); deserializer.set_allow_trailing_comma(true); int error_code = 0; scoped_ptr<base::Value> data(deserializer.Deserialize(&error_code, NULL)); diff --git a/components/policy/core/common/config_dir_policy_loader.cc b/components/policy/core/common/config_dir_policy_loader.cc index c754190..b39d838 100644 --- a/components/policy/core/common/config_dir_policy_loader.cc +++ b/components/policy/core/common/config_dir_policy_loader.cc @@ -31,11 +31,11 @@ const base::FilePath::CharType kRecommendedConfigDir[] = PolicyLoadStatus JsonErrorToPolicyLoadStatus(int status) { switch (status) { - case JSONFileValueSerializer::JSON_ACCESS_DENIED: - case JSONFileValueSerializer::JSON_CANNOT_READ_FILE: - case JSONFileValueSerializer::JSON_FILE_LOCKED: + case JSONFileValueDeserializer::JSON_ACCESS_DENIED: + case JSONFileValueDeserializer::JSON_CANNOT_READ_FILE: + case JSONFileValueDeserializer::JSON_FILE_LOCKED: return POLICY_LOAD_STATUS_READ_ERROR; - case JSONFileValueSerializer::JSON_NO_SUCH_FILE: + case JSONFileValueDeserializer::JSON_NO_SUCH_FILE: return POLICY_LOAD_STATUS_MISSING; case base::JSONReader::JSON_INVALID_ESCAPE: case base::JSONReader::JSON_SYNTAX_ERROR: @@ -138,7 +138,7 @@ void ConfigDirPolicyLoader::LoadFromPath(const base::FilePath& path, for (std::set<base::FilePath>::reverse_iterator config_file_iter = files.rbegin(); config_file_iter != files.rend(); ++config_file_iter) { - JSONFileValueSerializer deserializer(*config_file_iter); + JSONFileValueDeserializer deserializer(*config_file_iter); deserializer.set_allow_trailing_comma(true); int error_code = 0; std::string error_msg; diff --git a/components/update_client/component_patcher.cc b/components/update_client/component_patcher.cc index 3077bc4..29ce774 100644 --- a/components/update_client/component_patcher.cc +++ b/components/update_client/component_patcher.cc @@ -30,8 +30,8 @@ base::ListValue* ReadCommands(const base::FilePath& unpack_path) { if (!base::PathExists(commands)) return NULL; - JSONFileValueSerializer serializer(commands); - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, NULL)); + JSONFileValueDeserializer deserializer(commands); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); return (root.get() && root->IsType(base::Value::TYPE_LIST)) ? static_cast<base::ListValue*>(root.release()) diff --git a/components/update_client/component_unpacker.cc b/components/update_client/component_unpacker.cc index eb1b2d8..efde910 100644 --- a/components/update_client/component_unpacker.cc +++ b/components/update_client/component_unpacker.cc @@ -125,9 +125,9 @@ scoped_ptr<base::DictionaryValue> ReadManifest( unpack_path.Append(FILE_PATH_LITERAL("manifest.json")); if (!base::PathExists(manifest)) return scoped_ptr<base::DictionaryValue>(); - JSONFileValueSerializer serializer(manifest); + JSONFileValueDeserializer deserializer(manifest); std::string error; - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error)); if (!root.get()) return scoped_ptr<base::DictionaryValue>(); if (!root->IsType(base::Value::TYPE_DICTIONARY)) diff --git a/extensions/browser/api/printer_provider/printer_provider_api.cc b/extensions/browser/api/printer_provider/printer_provider_api.cc index a74838d..9074942 100644 --- a/extensions/browser/api/printer_provider/printer_provider_api.cc +++ b/extensions/browser/api/printer_provider/printer_provider_api.cc @@ -471,8 +471,8 @@ void PrinterProviderAPIImpl::DispatchPrintRequested( core_api::printer_provider::PrintJob print_job; print_job.printer_id = internal_printer_id; - JSONStringValueSerializer serializer(job.ticket_json); - scoped_ptr<base::Value> ticket_value(serializer.Deserialize(NULL, NULL)); + JSONStringValueDeserializer deserializer(job.ticket_json); + scoped_ptr<base::Value> ticket_value(deserializer.Deserialize(NULL, NULL)); if (!ticket_value || !core_api::printer_provider::PrintJob::Ticket::Populate( *ticket_value, &print_job.ticket)) { diff --git a/extensions/browser/api/printer_provider/printer_provider_apitest.cc b/extensions/browser/api/printer_provider/printer_provider_apitest.cc index 0a4662a..84e47f7 100644 --- a/extensions/browser/api/printer_provider/printer_provider_apitest.cc +++ b/extensions/browser/api/printer_provider/printer_provider_apitest.cc @@ -212,10 +212,10 @@ class PrinterProviderApiTest : public extensions::ShellApiTest { const std::vector<std::string>& expected_printers) { ASSERT_EQ(expected_printers.size(), printers.GetSize()); for (size_t i = 0; i < expected_printers.size(); ++i) { - JSONStringValueSerializer serializer(expected_printers[i]); + JSONStringValueDeserializer deserializer(expected_printers[i]); int error_code; scoped_ptr<base::Value> printer_value( - serializer.Deserialize(&error_code, NULL)); + deserializer.Deserialize(&error_code, NULL)); ASSERT_TRUE(printer_value) << "Failed to deserialize " << expected_printers[i] << ": " << "error code " << error_code; diff --git a/extensions/browser/extension_icon_image_unittest.cc b/extensions/browser/extension_icon_image_unittest.cc index 24d0ac2..3fb4e69 100644 --- a/extensions/browser/extension_icon_image_unittest.cc +++ b/extensions/browser/extension_icon_image_unittest.cc @@ -150,10 +150,11 @@ class ExtensionIconImageTest : public ExtensionsTest, test_file = test_file.AppendASCII(name); int error_code = 0; std::string error; - JSONFileValueSerializer serializer(test_file.AppendASCII("manifest.json")); + JSONFileValueDeserializer deserializer( + test_file.AppendASCII("manifest.json")); scoped_ptr<base::DictionaryValue> valid_value( - static_cast<base::DictionaryValue*>(serializer.Deserialize(&error_code, - &error))); + static_cast<base::DictionaryValue*>( + deserializer.Deserialize(&error_code, &error))); EXPECT_EQ(0, error_code) << error; if (error_code != 0) return NULL; diff --git a/extensions/browser/image_loader_unittest.cc b/extensions/browser/image_loader_unittest.cc index 06763805..f1f2aad 100644 --- a/extensions/browser/image_loader_unittest.cc +++ b/extensions/browser/image_loader_unittest.cc @@ -81,11 +81,11 @@ class ImageLoaderTest : public ExtensionsTest { extension_dir = extension_dir.AppendASCII(dir_name); int error_code = 0; std::string error; - JSONFileValueSerializer serializer( + JSONFileValueDeserializer deserializer( extension_dir.AppendASCII("manifest.json")); scoped_ptr<base::DictionaryValue> valid_value( - static_cast<base::DictionaryValue*>(serializer.Deserialize(&error_code, - &error))); + static_cast<base::DictionaryValue*>( + deserializer.Deserialize(&error_code, &error))); EXPECT_EQ(0, error_code) << error; if (error_code != 0) return NULL; diff --git a/extensions/common/extension_l10n_util.cc b/extensions/common/extension_l10n_util.cc index e60e2ec7..dbdd5d9 100644 --- a/extensions/common/extension_l10n_util.cc +++ b/extensions/common/extension_l10n_util.cc @@ -38,8 +38,8 @@ base::DictionaryValue* LoadMessageFile(const base::FilePath& locale_path, std::string* error) { base::FilePath file = locale_path.AppendASCII(locale).Append(extensions::kMessagesFilename); - JSONFileValueSerializer messages_serializer(file); - base::Value* dictionary = messages_serializer.Deserialize(NULL, error); + JSONFileValueDeserializer messages_deserializer(file); + base::Value* dictionary = messages_deserializer.Deserialize(NULL, error); if (!dictionary) { if (error->empty()) { // JSONFileValueSerializer just returns NULL if file cannot be found. It diff --git a/extensions/common/file_util.cc b/extensions/common/file_util.cc index e0ce339..399b6e7 100644 --- a/extensions/common/file_util.cc +++ b/extensions/common/file_util.cc @@ -168,8 +168,8 @@ base::DictionaryValue* LoadManifest( return NULL; } - JSONFileValueSerializer serializer(manifest_path); - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, error)); + JSONFileValueDeserializer deserializer(manifest_path); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, error)); if (!root.get()) { if (error->empty()) { // If |error| is empty, than the file could not be read. diff --git a/extensions/common/file_util_unittest.cc b/extensions/common/file_util_unittest.cc index 7e2f51d..750f598 100644 --- a/extensions/common/file_util_unittest.cc +++ b/extensions/common/file_util_unittest.cc @@ -43,8 +43,8 @@ scoped_refptr<Extension> LoadExtensionManifest( Manifest::Location location, int extra_flags, std::string* error) { - JSONStringValueSerializer serializer(manifest_value); - scoped_ptr<base::Value> result(serializer.Deserialize(NULL, error)); + JSONStringValueDeserializer deserializer(manifest_value); + scoped_ptr<base::Value> result(deserializer.Deserialize(NULL, error)); if (!result.get()) return NULL; CHECK_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); diff --git a/extensions/common/manifest_test.cc b/extensions/common/manifest_test.cc index 14e0aef..a3712d0 100644 --- a/extensions/common/manifest_test.cc +++ b/extensions/common/manifest_test.cc @@ -26,9 +26,9 @@ base::DictionaryValue* LoadManifestFile(const base::FilePath& manifest_path, EXPECT_TRUE(base::PathExists(manifest_path)) << "Couldn't find " << manifest_path.value(); - JSONFileValueSerializer serializer(manifest_path); - base::DictionaryValue* manifest = - static_cast<base::DictionaryValue*>(serializer.Deserialize(NULL, error)); + JSONFileValueDeserializer deserializer(manifest_path); + base::DictionaryValue* manifest = static_cast<base::DictionaryValue*>( + deserializer.Deserialize(NULL, error)); // Most unit tests don't need localization, and they'll fail if we try to // localize them, since their manifests don't have a default_locale key. diff --git a/extensions/utility/unpacker.cc b/extensions/utility/unpacker.cc index d244ba5..c61faa2 100644 --- a/extensions/utility/unpacker.cc +++ b/extensions/utility/unpacker.cc @@ -118,9 +118,9 @@ base::DictionaryValue* Unpacker::ReadManifest() { return NULL; } - JSONFileValueSerializer serializer(manifest_path); + JSONFileValueDeserializer deserializer(manifest_path); std::string error; - scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); + scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error)); if (!root.get()) { SetError(error); return NULL; @@ -270,9 +270,9 @@ bool Unpacker::AddDecodedImage(const base::FilePath& path) { bool Unpacker::ReadMessageCatalog(const base::FilePath& message_path) { std::string error; - JSONFileValueSerializer serializer(message_path); + JSONFileValueDeserializer deserializer(message_path); scoped_ptr<base::DictionaryValue> root(static_cast<base::DictionaryValue*>( - serializer.Deserialize(NULL, &error))); + deserializer.Deserialize(NULL, &error))); if (!root.get()) { base::string16 messages_file = message_path.LossyDisplayName(); if (error.empty()) { diff --git a/google_apis/drive/test_util.cc b/google_apis/drive/test_util.cc index ea193c4..db14c9d 100644 --- a/google_apis/drive/test_util.cc +++ b/google_apis/drive/test_util.cc @@ -81,8 +81,8 @@ scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path) { base::FilePath path = GetTestFilePath(relative_path); std::string error; - JSONFileValueSerializer serializer(path); - scoped_ptr<base::Value> value(serializer.Deserialize(NULL, &error)); + JSONFileValueDeserializer deserializer(path); + scoped_ptr<base::Value> value(deserializer.Deserialize(NULL, &error)); LOG_IF(WARNING, !value.get()) << "Failed to parse " << path.value() << ": " << error; return value.Pass(); diff --git a/remoting/host/pairing_registry_delegate_linux.cc b/remoting/host/pairing_registry_delegate_linux.cc index 5082317..7b22721 100644 --- a/remoting/host/pairing_registry_delegate_linux.cc +++ b/remoting/host/pairing_registry_delegate_linux.cc @@ -46,11 +46,11 @@ scoped_ptr<base::ListValue> PairingRegistryDelegateLinux::LoadAll() { for (base::FilePath pairing_file = enumerator.Next(); !pairing_file.empty(); pairing_file = enumerator.Next()) { // Read the JSON containing pairing data. - JSONFileValueSerializer serializer(pairing_file); + JSONFileValueDeserializer deserializer(pairing_file); int error_code; std::string error_message; scoped_ptr<base::Value> pairing_json( - serializer.Deserialize(&error_code, &error_message)); + deserializer.Deserialize(&error_code, &error_message)); if (!pairing_json) { LOG(WARNING) << "Failed to load '" << pairing_file.value() << "' (" << error_code << ")."; @@ -85,11 +85,11 @@ PairingRegistry::Pairing PairingRegistryDelegateLinux::Load( base::FilePath pairing_file = registry_path.Append( base::StringPrintf(kPairingFilenameFormat, client_id.c_str())); - JSONFileValueSerializer serializer(pairing_file); + JSONFileValueDeserializer deserializer(pairing_file); int error_code; std::string error_message; scoped_ptr<base::Value> pairing( - serializer.Deserialize(&error_code, &error_message)); + deserializer.Deserialize(&error_code, &error_message)); if (!pairing) { LOG(WARNING) << "Failed to load pairing information: " << error_message << " (" << error_code << ")."; diff --git a/remoting/host/pairing_registry_delegate_win.cc b/remoting/host/pairing_registry_delegate_win.cc index 1beac2f..a714e31 100644 --- a/remoting/host/pairing_registry_delegate_win.cc +++ b/remoting/host/pairing_registry_delegate_win.cc @@ -49,10 +49,10 @@ scoped_ptr<base::DictionaryValue> ReadValue(const base::win::RegKey& key, // Parse the value. std::string value_json_utf8 = base::WideToUTF8(value_json); - JSONStringValueSerializer serializer(&value_json_utf8); + JSONStringValueDeserializer deserializer(value_json_utf8); int error_code; std::string error_message; - scoped_ptr<base::Value> value(serializer.Deserialize(&error_code, + scoped_ptr<base::Value> value(deserializer.Deserialize(&error_code, &error_message)); if (!value) { LOG(ERROR) << "Failed to parse '" << value_name << "': " << error_message diff --git a/rlz/chromeos/lib/rlz_value_store_chromeos.cc b/rlz/chromeos/lib/rlz_value_store_chromeos.cc index 2232b5a..45f2500 100644 --- a/rlz/chromeos/lib/rlz_value_store_chromeos.cc +++ b/rlz/chromeos/lib/rlz_value_store_chromeos.cc @@ -211,14 +211,14 @@ void RlzValueStoreChromeOS::CollectGarbage() { void RlzValueStoreChromeOS::ReadStore() { int error_code = 0; std::string error_msg; - JSONFileValueSerializer serializer(store_path_); + JSONFileValueDeserializer deserializer(store_path_); scoped_ptr<base::Value> value( - serializer.Deserialize(&error_code, &error_msg)); + deserializer.Deserialize(&error_code, &error_msg)); switch (error_code) { - case JSONFileValueSerializer::JSON_NO_SUCH_FILE: + case JSONFileValueDeserializer::JSON_NO_SUCH_FILE: read_only_ = false; break; - case JSONFileValueSerializer::JSON_NO_ERROR: + case JSONFileValueDeserializer::JSON_NO_ERROR: read_only_ = false; rlz_store_.reset(static_cast<base::DictionaryValue*>(value.release())); break; diff --git a/sync/internal_api/sync_encryption_handler_impl.cc b/sync/internal_api/sync_encryption_handler_impl.cc index 709b38d..4bf559f 100644 --- a/sync/internal_api/sync_encryption_handler_impl.cc +++ b/sync/internal_api/sync_encryption_handler_impl.cc @@ -174,7 +174,8 @@ bool UnpackKeystoreBootstrapToken( &decrypted_keystore_bootstrap)) { return false; } - JSONStringValueSerializer json(&decrypted_keystore_bootstrap); + + JSONStringValueDeserializer json(decrypted_keystore_bootstrap); scoped_ptr<base::Value> deserialized_keystore_keys( json.Deserialize(NULL, NULL)); if (!deserialized_keystore_keys) diff --git a/sync/internal_api/sync_encryption_handler_impl_unittest.cc b/sync/internal_api/sync_encryption_handler_impl_unittest.cc index 9fbfcfe..829ecd2 100644 --- a/sync/internal_api/sync_encryption_handler_impl_unittest.cc +++ b/sync/internal_api/sync_encryption_handler_impl_unittest.cc @@ -665,7 +665,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetKeystoreMigratesAndUpdatesBootstrap) { ASSERT_TRUE( GetCryptographer()->encryptor()->DecryptString(decoded_bootstrap, &decrypted_bootstrap)); - JSONStringValueSerializer json(decrypted_bootstrap); + JSONStringValueDeserializer json(decrypted_bootstrap); scoped_ptr<base::Value> deserialized_keystore_keys( json.Deserialize(NULL, NULL)); ASSERT_TRUE(deserialized_keystore_keys.get()); diff --git a/ui/app_list/search/dictionary_data_store.cc b/ui/app_list/search/dictionary_data_store.cc index b867be4..45f53ca 100644 --- a/ui/app_list/search/dictionary_data_store.cc +++ b/ui/app_list/search/dictionary_data_store.cc @@ -64,12 +64,12 @@ void DictionaryDataStore::ScheduleWrite() { scoped_ptr<base::DictionaryValue> DictionaryDataStore::LoadOnBlockingPool() { DCHECK(worker_pool_->RunsTasksOnCurrentThread()); - int error_code = JSONFileValueSerializer::JSON_NO_ERROR; + int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; std::string error_message; - JSONFileValueSerializer serializer(data_file_); - base::Value* value = serializer.Deserialize(&error_code, &error_message); + JSONFileValueDeserializer deserializer(data_file_); + base::Value* value = deserializer.Deserialize(&error_code, &error_message); base::DictionaryValue* dict_value = NULL; - if (error_code != JSONFileValueSerializer::JSON_NO_ERROR || !value || + if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !value || !value->GetAsDictionary(&dict_value) || !dict_value) { return nullptr; } |