diff options
67 files changed, 171 insertions, 168 deletions
diff --git a/base/json/json_file_value_serializer.cc b/base/json/json_file_value_serializer.cc index 72a0970..9862703 100644 --- a/base/json/json_file_value_serializer.cc +++ b/base/json/json_file_value_serializer.cc @@ -100,8 +100,9 @@ const char* JSONFileValueDeserializer::GetErrorMessageForCode(int error_code) { } } -base::Value* JSONFileValueDeserializer::Deserialize(int* error_code, - std::string* error_str) { +scoped_ptr<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) { diff --git a/base/json/json_file_value_serializer.h b/base/json/json_file_value_serializer.h index aab47ee..4e5e09c 100644 --- a/base/json/json_file_value_serializer.h +++ b/base/json/json_file_value_serializer.h @@ -58,8 +58,8 @@ class BASE_EXPORT JSONFileValueDeserializer : public base::ValueDeserializer { // If |error_message| is non-null, it will be filled in with a formatted // error message including the location of the error if appropriate. // The caller takes ownership of the returned value. - base::Value* Deserialize(int* error_code, - std::string* error_message) override; + scoped_ptr<base::Value> Deserialize(int* error_code, + std::string* error_message) override; // This enum is designed to safely overlap with JSONReader::JsonParseError. enum JsonFileError { diff --git a/base/json/json_string_value_serializer.cc b/base/json/json_string_value_serializer.cc index f2d078f..af7e010 100644 --- a/base/json/json_string_value_serializer.cc +++ b/base/json/json_string_value_serializer.cc @@ -48,12 +48,11 @@ JSONStringValueDeserializer::JSONStringValueDeserializer( JSONStringValueDeserializer::~JSONStringValueDeserializer() {} -Value* JSONStringValueDeserializer::Deserialize(int* error_code, - std::string* error_str) { +scoped_ptr<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) - .release(); + 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 bc0e66d..90f697d 100644 --- a/base/json/json_string_value_serializer.h +++ b/base/json/json_string_value_serializer.h @@ -59,8 +59,8 @@ class BASE_EXPORT JSONStringValueDeserializer : public base::ValueDeserializer { // If |error_message| is non-null, it will be filled in with a formatted // error message including the location of the error if appropriate. // The caller takes ownership of the returned value. - base::Value* Deserialize(int* error_code, - std::string* error_message) override; + scoped_ptr<base::Value> Deserialize(int* error_code, + std::string* error_message) override; void set_allow_trailing_comma(bool new_value) { allow_trailing_comma_ = new_value; diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc index 3164d10..7da11cf 100644 --- a/base/json/json_value_serializer_unittest.cc +++ b/base/json/json_value_serializer_unittest.cc @@ -93,8 +93,8 @@ TEST(JSONValueDeserializerTest, ReadProperJSONFromString) { int error_code = 0; std::string error_message; - scoped_ptr<Value> value( - str_deserializer.Deserialize(&error_code, &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()); @@ -112,8 +112,8 @@ TEST(JSONValueDeserializerTest, ReadProperJSONFromStringPiece) { int error_code = 0; std::string error_message; - scoped_ptr<Value> value( - str_deserializer.Deserialize(&error_code, &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()); @@ -129,14 +129,14 @@ TEST(JSONValueDeserializerTest, ReadJSONWithTrailingCommasFromString) { int error_code = 0; std::string error_message; - scoped_ptr<Value> value( - str_deserializer.Deserialize(&error_code, &error_message)); + scoped_ptr<Value> value = + str_deserializer.Deserialize(&error_code, &error_message); ASSERT_FALSE(value.get()); ASSERT_NE(0, error_code); ASSERT_FALSE(error_message.empty()); // Now the flag is set and it must pass. str_deserializer.set_allow_trailing_comma(true); - value.reset(str_deserializer.Deserialize(&error_code, &error_message)); + value = str_deserializer.Deserialize(&error_code, &error_message); ASSERT_TRUE(value.get()); ASSERT_EQ(JSONReader::JSON_TRAILING_COMMA, error_code); // Verify if the same JSON is still there. @@ -157,8 +157,8 @@ TEST(JSONValueDeserializerTest, ReadProperJSONFromFile) { int error_code = 0; std::string error_message; - scoped_ptr<Value> value( - file_deserializer.Deserialize(&error_code, &error_message)); + scoped_ptr<Value> value = + file_deserializer.Deserialize(&error_code, &error_message); ASSERT_TRUE(value.get()); ASSERT_EQ(0, error_code); ASSERT_TRUE(error_message.empty()); @@ -182,14 +182,14 @@ TEST(JSONValueDeserializerTest, ReadJSONWithCommasFromFile) { // This must fail without the proper flag. int error_code = 0; std::string error_message; - scoped_ptr<Value> value( - file_deserializer.Deserialize(&error_code, &error_message)); + scoped_ptr<Value> value = + file_deserializer.Deserialize(&error_code, &error_message); ASSERT_FALSE(value.get()); ASSERT_NE(0, error_code); ASSERT_FALSE(error_message.empty()); // Now the flag is set and it must pass. file_deserializer.set_allow_trailing_comma(true); - value.reset(file_deserializer.Deserialize(&error_code, &error_message)); + value = file_deserializer.Deserialize(&error_code, &error_message); ASSERT_TRUE(value.get()); ASSERT_EQ(JSONReader::JSON_TRAILING_COMMA, error_code); // Verify if the same JSON is still there. @@ -205,9 +205,9 @@ TEST(JSONValueDeserializerTest, AllowTrailingComma) { JSONStringValueDeserializer deserializer(kTestWithCommas); deserializer.set_allow_trailing_comma(true); JSONStringValueDeserializer deserializer_expected(kTestNoCommas); - root.reset(deserializer.Deserialize(NULL, NULL)); + root = deserializer.Deserialize(NULL, NULL); ASSERT_TRUE(root.get()); - root_expected.reset(deserializer_expected.Deserialize(NULL, NULL)); + root_expected = deserializer_expected.Deserialize(NULL, NULL); ASSERT_TRUE(root_expected.get()); ASSERT_TRUE(root->Equals(root_expected.get())); } @@ -216,7 +216,7 @@ TEST(JSONValueSerializerTest, Roundtrip) { static const char kOriginalSerialization[] = "{\"bool\":true,\"double\":3.14,\"int\":42,\"list\":[1,2],\"null\":null}"; JSONStringValueDeserializer deserializer(kOriginalSerialization); - scoped_ptr<Value> root(deserializer.Deserialize(NULL, NULL)); + scoped_ptr<Value> root = deserializer.Deserialize(NULL, NULL); ASSERT_TRUE(root.get()); ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); @@ -326,7 +326,7 @@ TEST(JSONValueSerializerTest, UnicodeStrings) { // escaped ascii text -> json JSONStringValueDeserializer deserializer(kExpected); - scoped_ptr<Value> deserial_root(deserializer.Deserialize(NULL, NULL)); + scoped_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL); ASSERT_TRUE(deserial_root.get()); DictionaryValue* dict_root = static_cast<DictionaryValue*>(deserial_root.get()); @@ -350,7 +350,7 @@ TEST(JSONValueSerializerTest, HexStrings) { // escaped ascii text -> json JSONStringValueDeserializer deserializer(kExpected); - scoped_ptr<Value> deserial_root(deserializer.Deserialize(NULL, NULL)); + scoped_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL); ASSERT_TRUE(deserial_root.get()); DictionaryValue* dict_root = static_cast<DictionaryValue*>(deserial_root.get()); @@ -361,7 +361,7 @@ TEST(JSONValueSerializerTest, HexStrings) { // Test converting escaped regular chars static const char kEscapedChars[] = "{\"test\":\"\\u0067\\u006f\"}"; JSONStringValueDeserializer deserializer2(kEscapedChars); - deserial_root.reset(deserializer2.Deserialize(NULL, NULL)); + deserial_root = deserializer2.Deserialize(NULL, NULL); ASSERT_TRUE(deserial_root.get()); dict_root = static_cast<DictionaryValue*>(deserial_root.get()); ASSERT_TRUE(dict_root->GetString("test", &test_value)); @@ -413,7 +413,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { JSONFileValueDeserializer deserializer(original_file_path); scoped_ptr<Value> root; - root.reset(deserializer.Deserialize(NULL, NULL)); + root = deserializer.Deserialize(NULL, NULL); ASSERT_TRUE(root.get()); ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); @@ -461,7 +461,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { JSONFileValueDeserializer deserializer(original_file_path); scoped_ptr<Value> root; - root.reset(deserializer.Deserialize(NULL, NULL)); + root = deserializer.Deserialize(NULL, NULL); ASSERT_TRUE(root.get()); // Now try writing. @@ -486,7 +486,7 @@ TEST_F(JSONFileValueSerializerTest, NoWhitespace) { ASSERT_TRUE(PathExists(source_file_path)); JSONFileValueDeserializer deserializer(source_file_path); scoped_ptr<Value> root; - root.reset(deserializer.Deserialize(NULL, NULL)); + root = 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 87943d1..22036de 100644 --- a/base/prefs/json_pref_store.cc +++ b/base/prefs/json_pref_store.cc @@ -118,7 +118,7 @@ scoped_ptr<JsonPrefStore::ReadResult> ReadPrefsFromDisk( scoped_ptr<JsonPrefStore::ReadResult> read_result( new JsonPrefStore::ReadResult); JSONFileValueDeserializer deserializer(path); - read_result->value.reset(deserializer.Deserialize(&error_code, &error_msg)); + read_result->value = 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()); diff --git a/base/test/gtest_util.cc b/base/test/gtest_util.cc index 19cec51..3f44d74 100644 --- a/base/test/gtest_util.cc +++ b/base/test/gtest_util.cc @@ -60,8 +60,8 @@ bool ReadTestNamesFromFile(const FilePath& path, JSONFileValueDeserializer deserializer(path); int error_code = 0; std::string error_message; - scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_message)); + scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_message); if (!value.get()) return false; diff --git a/base/values.h b/base/values.h index 56be542..a64f6a8 100644 --- a/base/values.h +++ b/base/values.h @@ -531,7 +531,8 @@ class BASE_EXPORT ValueDeserializer { // error_code will be set with the underlying error. // If |error_message| is non-null, it will be filled in with a formatted // error message including the location of the error if appropriate. - virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; + virtual scoped_ptr<Value> Deserialize(int* error_code, + std::string* error_str) = 0; }; // Stream operator so Values can be used in assertion statements. In order that diff --git a/chrome/browser/android/contextualsearch/contextual_search_delegate.cc b/chrome/browser/android/contextualsearch/contextual_search_delegate.cc index e690b02..637c532 100644 --- a/chrome/browser/android/contextualsearch/contextual_search_delegate.cc +++ b/chrome/browser/android/contextualsearch/contextual_search_delegate.cc @@ -429,7 +429,7 @@ void ContextualSearchDelegate::DecodeSearchTermsFromJsonResponse( const std::string& proper_json = contains_xssi_escape ? response.substr(strlen(kXssiEscape)) : response; JSONStringValueDeserializer deserializer(proper_json); - scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); + scoped_ptr<base::Value> root = deserializer.Deserialize(NULL, NULL); if (root.get() != NULL && root->IsType(base::Value::TYPE_DICTIONARY)) { base::DictionaryValue* dict = diff --git a/chrome/browser/chromeos/app_mode/kiosk_external_updater.cc b/chrome/browser/chromeos/app_mode/kiosk_external_updater.cc index a875b8e..a753217 100644 --- a/chrome/browser/chromeos/app_mode/kiosk_external_updater.cc +++ b/chrome/browser/chromeos/app_mode/kiosk_external_updater.cc @@ -44,7 +44,9 @@ void ParseExternalUpdateManifest( JSONFileValueDeserializer deserializer(manifest); std::string error_msg; - base::Value* extensions = deserializer.Deserialize(NULL, &error_msg); + base::Value* extensions = + deserializer.Deserialize(NULL, &error_msg).release(); + // TODO(Olli Raula) possible memory leak http://crbug.com/543015 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 512aa21..61e125b 100644 --- a/chrome/browser/chromeos/app_mode/startup_app_launcher.cc +++ b/chrome/browser/chromeos/app_mode/startup_app_launcher.cc @@ -132,8 +132,8 @@ void StartupAppLauncher::LoadOAuthFileOnBlockingPool( base::FilePath auth_file = user_data_dir.Append(kOAuthFileName); scoped_ptr<JSONFileValueDeserializer> deserializer( new JSONFileValueDeserializer(user_data_dir.Append(kOAuthFileName))); - scoped_ptr<base::Value> value( - deserializer->Deserialize(&error_code, &error_msg)); + scoped_ptr<base::Value> value = + deserializer->Deserialize(&error_code, &error_msg); base::DictionaryValue* dict = NULL; if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !value.get() || !value->GetAsDictionary(&dict)) { diff --git a/chrome/browser/chromeos/extensions/default_app_order.cc b/chrome/browser/chromeos/extensions/default_app_order.cc index 4abcbaa..855b537 100644 --- a/chrome/browser/chromeos/extensions/default_app_order.cc +++ b/chrome/browser/chromeos/extensions/default_app_order.cc @@ -65,7 +65,7 @@ base::ListValue* ReadExternalOrdinalFile(const base::FilePath& path) { JSONFileValueDeserializer deserializer(path); std::string error_msg; - base::Value* value = deserializer.Deserialize(NULL, &error_msg); + base::Value* value = deserializer.Deserialize(NULL, &error_msg).release(); if (!value) { LOG(WARNING) << "Unable to deserialize default app ordinals json data:" << error_msg << ", file=" << path.value(); @@ -77,6 +77,7 @@ base::ListValue* ReadExternalOrdinalFile(const base::FilePath& path) { return ordinal_list_value; LOG(WARNING) << "Expect a JSON list in file " << path.value(); + // TODO(Olli Raula) possible memory leak http://crbug.com/543015 return NULL; } 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 0595733..b3059ae 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 @@ -167,7 +167,7 @@ scoped_ptr<base::DictionaryValue> ComponentExtensionIMEManagerImpl::GetManifest( const std::string& manifest_string) { std::string error; JSONStringValueDeserializer deserializer(manifest_string); - scoped_ptr<base::Value> manifest(deserializer.Deserialize(NULL, &error)); + 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 389dcc5..7485604 100644 --- a/chrome/browser/chromeos/login/supervised/supervised_user_authentication.cc +++ b/chrome/browser/chromeos/login/supervised/supervised_user_authentication.cc @@ -58,8 +58,8 @@ base::DictionaryValue* LoadPasswordData(base::FilePath profile_dir) { profile_dir.Append(kPasswordUpdateFile)); std::string error_message; int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; - scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_message)); + scoped_ptr<base::Value> value = + 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; diff --git a/chrome/browser/component_updater/component_installers_unittest.cc b/chrome/browser/component_updater/component_installers_unittest.cc index 10c5834..57db885 100644 --- a/chrome/browser/component_updater/component_installers_unittest.cc +++ b/chrome/browser/component_updater/component_installers_unittest.cc @@ -74,8 +74,10 @@ TEST(ComponentInstallerTest, PepperFlashCheck) { JSONFileValueDeserializer deserializer(manifest); std::string error; - scoped_ptr<base::DictionaryValue> root(static_cast<base::DictionaryValue*>( - deserializer.Deserialize(NULL, &error))); + + scoped_ptr<base::DictionaryValue> root = + base::DictionaryValue::From(deserializer.Deserialize(NULL, &error)); + ASSERT_TRUE(root); ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); diff --git a/chrome/browser/component_updater/pnacl_component_installer.cc b/chrome/browser/component_updater/pnacl_component_installer.cc index 1198d60..f10940b 100644 --- a/chrome/browser/component_updater/pnacl_component_installer.cc +++ b/chrome/browser/component_updater/pnacl_component_installer.cc @@ -127,7 +127,7 @@ bool GetLatestPnaclDirectory(const scoped_refptr<PnaclComponentInstaller>& pci, base::DictionaryValue* ReadJSONManifest(const base::FilePath& manifest_path) { JSONFileValueDeserializer deserializer(manifest_path); std::string error; - scoped_ptr<base::Value> root(deserializer.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 3657d64..8943ab4 100644 --- a/chrome/browser/component_updater/recovery_component_installer.cc +++ b/chrome/browser/component_updater/recovery_component_installer.cc @@ -118,12 +118,7 @@ base::CommandLine GetRecoveryInstallCommandLine( scoped_ptr<base::DictionaryValue> ReadManifest(const base::FilePath& manifest) { JSONFileValueDeserializer deserializer(manifest); std::string 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())); - } - return scoped_ptr<base::DictionaryValue>(); + return base::DictionaryValue::From(deserializer.Deserialize(NULL, &error)); } void WaitForElevatedInstallToComplete(base::Process process) { diff --git a/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc b/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc index 5e43a11..94f1b0e 100644 --- a/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc +++ b/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc @@ -36,10 +36,8 @@ const char kAllHostsPermission[] = "*://*/*"; scoped_ptr<base::DictionaryValue> DeserializeJSONTestData( const base::FilePath& path, std::string *error) { - base::Value* value = nullptr; JSONFileValueDeserializer deserializer(path); - value = deserializer.Deserialize(nullptr, error); - return make_scoped_ptr(static_cast<base::DictionaryValue*>(value)); + return base::DictionaryValue::From(deserializer.Deserialize(nullptr, error)); } } // namespace 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 8479b13..6b458b1 100644 --- a/chrome/browser/extensions/api/messaging/native_messaging_host_manifest.cc +++ b/chrome/browser/extensions/api/messaging/native_messaging_host_manifest.cc @@ -44,7 +44,8 @@ scoped_ptr<NativeMessagingHostManifest> NativeMessagingHostManifest::Load( DCHECK(error_message); JSONFileValueDeserializer deserializer(file_path); - scoped_ptr<base::Value> parsed(deserializer.Deserialize(NULL, error_message)); + 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 5ee4a1f..afa7bef 100644 --- a/chrome/browser/extensions/chrome_info_map_unittest.cc +++ b/chrome/browser/extensions/chrome_info_map_unittest.cc @@ -25,7 +25,7 @@ scoped_refptr<Extension> LoadManifest(const std::string& dir, path = path.AppendASCII("extensions").AppendASCII(dir).AppendASCII(test_file); JSONFileValueDeserializer deserializer(path); - scoped_ptr<base::Value> result(deserializer.Deserialize(NULL, NULL)); + 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 0f5aa98..cdb717b 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -164,7 +164,7 @@ void ComponentLoader::LoadAll() { base::DictionaryValue* ComponentLoader::ParseManifest( const std::string& manifest_contents) const { JSONStringValueDeserializer deserializer(manifest_contents); - scoped_ptr<base::Value> manifest(deserializer.Deserialize(NULL, NULL)); + 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 6af5c77..673a03b 100644 --- a/chrome/browser/extensions/extension_action_icon_factory_unittest.cc +++ b/chrome/browser/extensions/extension_action_icon_factory_unittest.cc @@ -109,10 +109,8 @@ class ExtensionActionIconFactoryTest std::string error; JSONFileValueDeserializer deserializer( test_file.AppendASCII("manifest.json")); - scoped_ptr<base::DictionaryValue> valid_value( - static_cast<base::DictionaryValue*>( - deserializer.Deserialize(&error_code, - &error))); + scoped_ptr<base::DictionaryValue> valid_value = base::DictionaryValue::From( + 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 bcec7a8..3ca1104 100644 --- a/chrome/browser/extensions/extension_icon_manager_unittest.cc +++ b/chrome/browser/extensions/extension_icon_manager_unittest.cc @@ -109,9 +109,8 @@ TEST_F(ExtensionIconManagerTest, LoadRemoveLoad) { "extensions/image_loading_tracker/app.json"); JSONFileValueDeserializer deserializer(manifest_path); - scoped_ptr<base::DictionaryValue> manifest( - static_cast<base::DictionaryValue*>(deserializer.Deserialize(NULL, - NULL))); + scoped_ptr<base::DictionaryValue> manifest = + base::DictionaryValue::From(deserializer.Deserialize(NULL, NULL)); ASSERT_TRUE(manifest.get() != NULL); std::string error; @@ -152,9 +151,8 @@ TEST_F(ExtensionIconManagerTest, LoadComponentExtensionResource) { "extensions/file_manager/app.json"); JSONFileValueDeserializer deserializer(manifest_path); - scoped_ptr<base::DictionaryValue> manifest( - static_cast<base::DictionaryValue*>(deserializer.Deserialize(NULL, - NULL))); + scoped_ptr<base::DictionaryValue> manifest = + base::DictionaryValue::From(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 e031b50..6c014b3 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -365,15 +365,13 @@ class MockProviderVisitor // We also parse the file into a dictionary to compare what we get back // from the provider. JSONStringValueDeserializer deserializer(json_data); - base::Value* json_value = deserializer.Deserialize(NULL, NULL); + scoped_ptr<base::Value> json_value = deserializer.Deserialize(NULL, NULL); if (!json_value || !json_value->IsType(base::Value::TYPE_DICTIONARY)) { NOTREACHED() << "Unable to deserialize json data"; return -1; } else { - base::DictionaryValue* external_extensions = - static_cast<base::DictionaryValue*>(json_value); - prefs_.reset(external_extensions); + prefs_ = base::DictionaryValue::From(json_value.Pass()); } // Reset our counter. diff --git a/chrome/browser/extensions/external_pref_loader.cc b/chrome/browser/extensions/external_pref_loader.cc index c0775d2..0e71a49 100644 --- a/chrome/browser/extensions/external_pref_loader.cc +++ b/chrome/browser/extensions/external_pref_loader.cc @@ -72,20 +72,24 @@ 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. +// TODO(Olli Raula) Make return scoped_ptr base::DictionaryValue* ExtractExtensionPrefs( base::ValueDeserializer* deserializer, const base::FilePath& path) { std::string error_msg; - base::Value* extensions = deserializer->Deserialize(NULL, &error_msg); + scoped_ptr<base::Value> extensions = + deserializer->Deserialize(NULL, &error_msg); if (!extensions) { LOG(WARNING) << "Unable to deserialize json data: " << error_msg << " in file " << path.value() << "."; return new base::DictionaryValue; } - base::DictionaryValue* ext_dictionary = NULL; - if (extensions->GetAsDictionary(&ext_dictionary)) - return ext_dictionary; + scoped_ptr<base::DictionaryValue> ext_dictionary = + base::DictionaryValue::From(extensions.Pass()); + if (ext_dictionary) { + return ext_dictionary.release(); + } LOG(WARNING) << "Expected a JSON dictionary in file " << path.value() << "."; diff --git a/chrome/browser/extensions/user_script_listener_unittest.cc b/chrome/browser/extensions/user_script_listener_unittest.cc index 64099b8..b4147f7 100644 --- a/chrome/browser/extensions/user_script_listener_unittest.cc +++ b/chrome/browser/extensions/user_script_listener_unittest.cc @@ -74,12 +74,13 @@ class SimpleTestJob : public net::URLRequestTestJob { }; // Yoinked from extension_manifest_unittest.cc. +// TODO(Olli Raula) Make this return scoped_ptr base::DictionaryValue* LoadManifestFile(const base::FilePath path, std::string* error) { EXPECT_TRUE(base::PathExists(path)); JSONFileValueDeserializer deserializer(path); - return static_cast<base::DictionaryValue*>( - deserializer.Deserialize(NULL, error)); + return base::DictionaryValue::From(deserializer.Deserialize(NULL, error)) + .release(); } scoped_refptr<Extension> LoadExtension(const std::string& filename, diff --git a/chrome/browser/platform_util_unittest.cc b/chrome/browser/platform_util_unittest.cc index cd30a7f..caaf200 100644 --- a/chrome/browser/platform_util_unittest.cc +++ b/chrome/browser/platform_util_unittest.cc @@ -92,8 +92,8 @@ class PlatformUtilTestBase : public BrowserWithTestWindowTest { " }" "}"; JSONStringValueDeserializer json_string_deserializer(json_manifest); - scoped_ptr<base::Value> manifest( - json_string_deserializer.Deserialize(&error_code, &error)); + scoped_ptr<base::Value> manifest = + json_string_deserializer.Deserialize(&error_code, &error); base::DictionaryValue* manifest_dictionary; manifest->GetAsDictionary(&manifest_dictionary); diff --git a/chrome/browser/prefs/pref_service_browsertest.cc b/chrome/browser/prefs/pref_service_browsertest.cc index 47e1007..35ea009 100644 --- a/chrome/browser/prefs/pref_service_browsertest.cc +++ b/chrome/browser/prefs/pref_service_browsertest.cc @@ -102,7 +102,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. JSONFileValueDeserializer deserializer(original_pref_file_); - scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); + scoped_ptr<base::Value> root = deserializer.Deserialize(NULL, NULL); ASSERT_TRUE(root.get()); ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); diff --git a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc index 6df10cf..43cfa0c 100644 --- a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc +++ b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc @@ -88,8 +88,8 @@ scoped_ptr<base::DictionaryValue> ReadPrefsDictionary( JSONFileValueDeserializer deserializer(pref_file); int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; std::string error_str; - scoped_ptr<base::Value> prefs( - deserializer.Deserialize(&error_code, &error_str)); + scoped_ptr<base::Value> prefs = + 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/supervised_user/supervised_user_site_list.cc b/chrome/browser/supervised_user/supervised_user_site_list.cc index de3baac..84ba29f 100644 --- a/chrome/browser/supervised_user/supervised_user_site_list.cc +++ b/chrome/browser/supervised_user/supervised_user_site_list.cc @@ -29,8 +29,8 @@ scoped_ptr<base::Value> ReadFileOnBlockingThread(const base::FilePath& path) { JSONFileValueDeserializer deserializer(path); int error_code; std::string error_msg; - scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_msg)); + scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_msg); if (!value) { LOG(ERROR) << "Couldn't load site list " << path.value() << ": " << error_msg; diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc index 404dbda..6dbc596 100644 --- a/chrome/browser/themes/browser_theme_pack_unittest.cc +++ b/chrome/browser/themes/browser_theme_pack_unittest.cc @@ -155,9 +155,8 @@ class BrowserThemePackTest : public ::testing::Test { extension_path.AppendASCII("manifest.json"); std::string error; JSONFileValueDeserializer deserializer(manifest_path); - scoped_ptr<base::DictionaryValue> valid_value( - static_cast<base::DictionaryValue*>( - deserializer.Deserialize(NULL, &error))); + scoped_ptr<base::DictionaryValue> valid_value = + base::DictionaryValue::From(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 6fc32fb..c078e731 100644 --- a/chrome/browser/ui/app_list/start_page_service.cc +++ b/chrome/browser/ui/app_list/start_page_service.cc @@ -668,8 +668,8 @@ void StartPageService::OnURLFetchComplete(const net::URLFetcher* source) { JSONStringValueDeserializer deserializer(json_data_substr); deserializer.set_allow_trailing_comma(true); int error_code = 0; - scoped_ptr<base::Value> doodle_json( - deserializer.Deserialize(&error_code, nullptr)); + scoped_ptr<base::Value> doodle_json = + deserializer.Deserialize(&error_code, nullptr); base::TimeDelta recheck_delay; if (error_code != 0) { 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 bbfc886..b2e2a70 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 @@ -36,8 +36,8 @@ scoped_refptr<extensions::Extension> LoadInstallPromptExtension( std::string error; JSONFileValueDeserializer deserializer(path); - scoped_ptr<base::DictionaryValue> value(static_cast<base::DictionaryValue*>( - deserializer.Deserialize(NULL, &error))); + scoped_ptr<base::DictionaryValue> value = + base::DictionaryValue::From(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 e129cfd5..3ee8381 100644 --- a/chrome/browser/ui/webui/nacl_ui.cc +++ b/chrome/browser/ui/webui/nacl_ui.cc @@ -328,7 +328,7 @@ void CheckVersion(const base::FilePath& pnacl_path, std::string* version) { pnacl_path.AppendASCII("pnacl_public_pnacl_json"); JSONFileValueDeserializer deserializer(pnacl_json_path); std::string error; - scoped_ptr<base::Value> root(deserializer.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/common/component_flash_hint_file_linux.cc b/chrome/common/component_flash_hint_file_linux.cc index 160c8e8..32d856e 100644 --- a/chrome/common/component_flash_hint_file_linux.cc +++ b/chrome/common/component_flash_hint_file_linux.cc @@ -156,8 +156,8 @@ bool VerifyAndReturnFlashLocation(base::FilePath* path, int error_code; std::string error_message; JSONStringValueDeserializer deserializer(json_string); - const scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_message)); + const scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_message); if (!value) { LOG(ERROR) diff --git a/chrome/common/extensions/extension_test_util.cc b/chrome/common/extensions/extension_test_util.cc index ec223f6..697be60 100644 --- a/chrome/common/extensions/extension_test_util.cc +++ b/chrome/common/extensions/extension_test_util.cc @@ -31,7 +31,7 @@ scoped_refptr<Extension> LoadManifestUnchecked(const std::string& dir, .AppendASCII(test_file); JSONFileValueDeserializer deserializer(path); - scoped_ptr<base::Value> result(deserializer.Deserialize(NULL, error)); + scoped_ptr<base::Value> result = deserializer.Deserialize(NULL, error); if (!result) return NULL; const base::DictionaryValue* dict; diff --git a/chrome/installer/util/uninstall_metrics.cc b/chrome/installer/util/uninstall_metrics.cc index 11e91da..606b132 100644 --- a/chrome/installer/util/uninstall_metrics.cc +++ b/chrome/installer/util/uninstall_metrics.cc @@ -78,7 +78,7 @@ bool ExtractUninstallMetricsFromFile(const base::FilePath& file_path, JSONFileValueDeserializer json_deserializer(file_path); std::string json_error_string; - scoped_ptr<base::Value> root(json_deserializer.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 aa0ff15..72b891f 100644 --- a/chrome/installer/util/uninstall_metrics_unittest.cc +++ b/chrome/installer/util/uninstall_metrics_unittest.cc @@ -46,8 +46,8 @@ TEST(UninstallMetricsTest, TestExtractUninstallMetrics) { JSONStringValueDeserializer json_deserializer(pref_string); std::string error_message; - scoped_ptr<base::Value> root( - json_deserializer.Deserialize(NULL, &error_message)); + scoped_ptr<base::Value> root = + json_deserializer.Deserialize(NULL, &error_message); ASSERT_TRUE(root.get()); base::string16 uninstall_metrics_string; diff --git a/chrome/test/media_router/media_router_integration_browsertest.cc b/chrome/test/media_router/media_router_integration_browsertest.cc index 99beb38..3bda712 100644 --- a/chrome/test/media_router/media_router_integration_browsertest.cc +++ b/chrome/test/media_router/media_router_integration_browsertest.cc @@ -158,8 +158,8 @@ void MediaRouterIntegrationBrowserTest::SetTestData( JSONFileValueDeserializer deserializer(full_path); int error_code = 0; std::string error_message; - scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_message)); + scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_message); CHECK(value.get()) << "Deserialize failed: " << error_message; std::string test_data_str; ASSERT_TRUE(base::JSONWriter::Write(*value, &test_data_str)); diff --git a/chrome/utility/importer/firefox_importer.cc b/chrome/utility/importer/firefox_importer.cc index b9238d6..f945fb3 100644 --- a/chrome/utility/importer/firefox_importer.cc +++ b/chrome/utility/importer/firefox_importer.cc @@ -541,8 +541,8 @@ void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( base::FilePath search_metadata_json_file = source_path_.AppendASCII("search-metadata.json"); JSONFileValueDeserializer metadata_deserializer(search_metadata_json_file); - scoped_ptr<base::Value> metadata_root( - metadata_deserializer.Deserialize(NULL, NULL)); + scoped_ptr<base::Value> metadata_root = + metadata_deserializer.Deserialize(NULL, NULL); const base::DictionaryValue* search_metadata_root = NULL; if (metadata_root) metadata_root->GetAsDictionary(&search_metadata_root); @@ -553,7 +553,7 @@ void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( return; JSONFileValueDeserializer deserializer(search_json_file); - scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); + 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/chromecast/base/serializers.cc b/chromecast/base/serializers.cc index 34bc9fd..2e6135b 100644 --- a/chromecast/base/serializers.cc +++ b/chromecast/base/serializers.cc @@ -15,8 +15,8 @@ scoped_ptr<base::Value> DeserializeFromJson(const std::string& text) { int error_code = -1; std::string error_msg; - scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_msg)); + scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_msg); DLOG_IF(ERROR, !value) << "JSON error " << error_code << ":" << error_msg; // Value will hold the nullptr in case of an error. @@ -36,8 +36,8 @@ scoped_ptr<base::Value> DeserializeJsonFromFile(const base::FilePath& path) { int error_code = -1; std::string error_msg; - scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_msg)); + scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_msg); DLOG_IF(ERROR, !value) << "JSON error " << error_code << ":" << error_msg; // Value will hold the nullptr in case of an error. diff --git a/chromeos/app_mode/kiosk_oem_manifest_parser.cc b/chromeos/app_mode/kiosk_oem_manifest_parser.cc index f13d1a8..16c072a 100644 --- a/chromeos/app_mode/kiosk_oem_manifest_parser.cc +++ b/chromeos/app_mode/kiosk_oem_manifest_parser.cc @@ -32,8 +32,8 @@ bool KioskOemManifestParser::Load( std::string error_msg; scoped_ptr<JSONFileValueDeserializer> deserializer( new JSONFileValueDeserializer(kiosk_oem_file)); - scoped_ptr<base::Value> value( - deserializer->Deserialize(&error_code, &error_msg)); + scoped_ptr<base::Value> value = + deserializer->Deserialize(&error_code, &error_msg); base::DictionaryValue* dict = NULL; if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !value.get() || diff --git a/chromeos/dbus/fake_easy_unlock_client.cc b/chromeos/dbus/fake_easy_unlock_client.cc index 7744188..ece1dfe 100644 --- a/chromeos/dbus/fake_easy_unlock_client.cc +++ b/chromeos/dbus/fake_easy_unlock_client.cc @@ -21,7 +21,7 @@ const char kEc256PublicKeyKey[] = "ec_p256_public_key"; int ExtractKeyPairIndexFromKey(const std::string& key, const std::string& key_type) { JSONStringValueDeserializer deserializer(key); - scoped_ptr<base::Value> json_value(deserializer.Deserialize(NULL, NULL)); + 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 522a9ed..7afc0d89 100644 --- a/chromeos/network/onc/onc_test_utils.cc +++ b/chromeos/network/onc/onc_test_utils.cc @@ -38,29 +38,30 @@ std::string ReadTestData(const std::string& filename) { scoped_ptr<base::DictionaryValue> ReadTestDictionary( const std::string& filename) { - base::DictionaryValue* dict = NULL; + scoped_ptr<base::DictionaryValue> dict; base::FilePath path; if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, filename, &path)) { NOTREACHED() << "Unable to get test dictionary path for " << kNetworkComponentDirectory << "/" << filename; - return make_scoped_ptr(dict); + return dict; } JSONFileValueDeserializer deserializer(path); deserializer.set_allow_trailing_comma(true); std::string error_message; - base::Value* content = deserializer.Deserialize(NULL, &error_message); + scoped_ptr<base::Value> content = + deserializer.Deserialize(NULL, &error_message); CHECK(content != NULL) << "Couldn't json-deserialize file '" << filename << "': " << error_message; - CHECK(content->GetAsDictionary(&dict)) - << "File '" << filename - << "' does not contain a dictionary as expected, but type " - << content->GetType(); - return make_scoped_ptr(dict); + dict = base::DictionaryValue::From(content.Pass()); + CHECK(dict) << "File '" << filename + << "' does not contain a dictionary as expected, but type " + << content->GetType(); + return dict; } ::testing::AssertionResult Equals(const base::Value* expected, diff --git a/chromeos/network/onc/onc_utils_unittest.cc b/chromeos/network/onc/onc_utils_unittest.cc index 6370a68..30053f1 100644 --- a/chromeos/network/onc/onc_utils_unittest.cc +++ b/chromeos/network/onc/onc_utils_unittest.cc @@ -21,11 +21,11 @@ namespace chromeos { namespace { scoped_ptr<base::Value> ReadTestJson(const std::string& filename) { - base::Value* result = nullptr; base::FilePath path; + scoped_ptr<base::Value> result; if (!test_utils::GetTestDataPath("network", filename, &path)) { NOTREACHED() << "Unable to get test file path for: " << filename; - return make_scoped_ptr(result); + return result; } JSONFileValueDeserializer deserializer(path); deserializer.set_allow_trailing_comma(true); @@ -33,7 +33,7 @@ scoped_ptr<base::Value> ReadTestJson(const std::string& filename) { result = deserializer.Deserialize(nullptr, &error_message); CHECK(result != nullptr) << "Couldn't json-deserialize file: " << filename << ": " << error_message; - return make_scoped_ptr(result); + return result; } } // namespace diff --git a/chromeos/system/statistics_provider.cc b/chromeos/system/statistics_provider.cc index 834f0b6a..6f86dfb 100644 --- a/chromeos/system/statistics_provider.cc +++ b/chromeos/system/statistics_provider.cc @@ -503,8 +503,8 @@ void StatisticsProviderImpl::LoadRegionsFile(const base::FilePath& filename) { JSONFileValueDeserializer regions_file(filename); int regions_error_code = 0; std::string regions_error_message; - regional_data_.reset( - regions_file.Deserialize(®ions_error_code, ®ions_error_message)); + regional_data_ = + regions_file.Deserialize(®ions_error_code, ®ions_error_message); if (!regional_data_.get()) { if (base::SysInfo::IsRunningOnChromeOS()) LOG(ERROR) << "Failed to load regions file '" << filename.value() diff --git a/chromeos/tools/onc_validator/onc_validator.cc b/chromeos/tools/onc_validator/onc_validator.cc index 14ed891..a4ec9bd 100644 --- a/chromeos/tools/onc_validator/onc_validator.cc +++ b/chromeos/tools/onc_validator/onc_validator.cc @@ -14,6 +14,9 @@ #include "chromeos/network/onc/onc_signature.h" #include "chromeos/network/onc/onc_validator.h" +// TODO Check why this file do not fail on default trybots +// http://crbug.com/543919 + // Command line switches. const char kSwitchErrorOnUnknownField[] = "error-on-unknown-field"; const char kSwitchErrorOnWrongRecommended[] = "error-on-wrong-recommended"; @@ -90,7 +93,8 @@ scoped_ptr<base::DictionaryValue> ReadDictionary(const std::string& filename) { base::DictionaryValue* dict = NULL; std::string json_error; - base::Value* value = deserializer.Deserialize(NULL, &json_error); + base::Value* value = deserializer.Deserialize(NULL, &json_error).release(); + // TODO(Olli Raula) possible memory leak http://crbug.com/543015 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 52f1a94..4d997d6 100644 --- a/components/bookmarks/browser/bookmark_codec.cc +++ b/components/bookmarks/browser/bookmark_codec.cc @@ -387,7 +387,7 @@ bool BookmarkCodec::DecodeMetaInfo(const base::DictionaryValue& value, std::string meta_info_str; meta_info->GetAsString(&meta_info_str); JSONStringValueDeserializer deserializer(meta_info_str); - deserialized_holder.reset(deserializer.Deserialize(nullptr, nullptr)); + deserialized_holder = 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 8c45aea..8094464 100644 --- a/components/bookmarks/browser/bookmark_codec_unittest.cc +++ b/components/bookmarks/browser/bookmark_codec_unittest.cc @@ -360,7 +360,7 @@ TEST_F(BookmarkCodecTest, CanDecodeModelWithoutMobileBookmarks) { ASSERT_TRUE(base::PathExists(test_file)); JSONFileValueDeserializer deserializer(test_file); - scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); + scoped_ptr<base::Value> root = deserializer.Deserialize(NULL, NULL); scoped_ptr<BookmarkModel> decoded_model(client_.CreateModel()); BookmarkCodec decoder; @@ -446,7 +446,7 @@ TEST_F(BookmarkCodecTest, CanDecodeMetaInfoAsString) { ASSERT_TRUE(base::PathExists(test_file)); JSONFileValueDeserializer deserializer(test_file); - scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); + 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 da721b1..6f11d06 100644 --- a/components/bookmarks/browser/bookmark_storage.cc +++ b/components/bookmarks/browser/bookmark_storage.cc @@ -56,7 +56,7 @@ void LoadCallback(const base::FilePath& path, bool bookmark_file_exists = base::PathExists(path); if (bookmark_file_exists) { JSONFileValueDeserializer deserializer(path); - scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); + 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 38f111c..7aae281 100644 --- a/components/json_schema/json_schema_validator_unittest_base.cc +++ b/components/json_schema/json_schema_validator_unittest_base.cc @@ -37,7 +37,8 @@ base::Value* LoadValue(const std::string& filename) { std::string error_message; JSONFileValueDeserializer deserializer(path); - base::Value* result = deserializer.Deserialize(NULL, &error_message); + base::Value* result = + deserializer.Deserialize(NULL, &error_message).release(); if (!result) ADD_FAILURE() << "Could not parse JSON: " << error_message; return result; diff --git a/components/omnibox/browser/search_suggestion_parser.cc b/components/omnibox/browser/search_suggestion_parser.cc index 24ab637..df0e00b 100644 --- a/components/omnibox/browser/search_suggestion_parser.cc +++ b/components/omnibox/browser/search_suggestion_parser.cc @@ -376,7 +376,7 @@ scoped_ptr<base::Value> SearchSuggestionParser::DeserializeJsonData( JSONStringValueDeserializer deserializer(json_data); deserializer.set_allow_trailing_comma(true); int error_code = 0; - scoped_ptr<base::Value> data(deserializer.Deserialize(&error_code, NULL)); + scoped_ptr<base::Value> data = deserializer.Deserialize(&error_code, NULL); if (error_code == 0) return data.Pass(); } diff --git a/components/policy/core/common/config_dir_policy_loader.cc b/components/policy/core/common/config_dir_policy_loader.cc index b81bfa9..daaf5415 100644 --- a/components/policy/core/common/config_dir_policy_loader.cc +++ b/components/policy/core/common/config_dir_policy_loader.cc @@ -143,8 +143,8 @@ void ConfigDirPolicyLoader::LoadFromPath(const base::FilePath& path, deserializer.set_allow_trailing_comma(true); int error_code = 0; std::string error_msg; - scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_msg)); + scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_msg); if (!value.get()) { LOG(WARNING) << "Failed to read configuration file " << config_file_iter->value() << ": " << error_msg; diff --git a/components/update_client/component_patcher.cc b/components/update_client/component_patcher.cc index 0525882..9105fda 100644 --- a/components/update_client/component_patcher.cc +++ b/components/update_client/component_patcher.cc @@ -31,7 +31,7 @@ base::ListValue* ReadCommands(const base::FilePath& unpack_path) { return NULL; JSONFileValueDeserializer deserializer(commands); - scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); + 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 9dfd555..b0fc94a 100644 --- a/components/update_client/component_unpacker.cc +++ b/components/update_client/component_unpacker.cc @@ -63,7 +63,7 @@ scoped_ptr<base::DictionaryValue> ReadManifest( return scoped_ptr<base::DictionaryValue>(); JSONFileValueDeserializer deserializer(manifest); std::string error; - scoped_ptr<base::Value> root(deserializer.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 8b02814d..b5d16a8 100644 --- a/extensions/browser/api/printer_provider/printer_provider_api.cc +++ b/extensions/browser/api/printer_provider/printer_provider_api.cc @@ -594,7 +594,7 @@ void PrinterProviderAPIImpl::DispatchPrintRequested( print_job.printer_id = internal_printer_id; JSONStringValueDeserializer deserializer(job.ticket_json); - scoped_ptr<base::Value> ticket_value(deserializer.Deserialize(NULL, NULL)); + scoped_ptr<base::Value> ticket_value = deserializer.Deserialize(NULL, NULL); if (!ticket_value || !api::printer_provider::PrintJob::Ticket::Populate(*ticket_value, &print_job.ticket)) { diff --git a/extensions/browser/extension_icon_image_unittest.cc b/extensions/browser/extension_icon_image_unittest.cc index 88c2fe4..35a8b5c 100644 --- a/extensions/browser/extension_icon_image_unittest.cc +++ b/extensions/browser/extension_icon_image_unittest.cc @@ -104,9 +104,8 @@ class ExtensionIconImageTest : public ExtensionsTest, std::string error; JSONFileValueDeserializer deserializer( test_file.AppendASCII("manifest.json")); - scoped_ptr<base::DictionaryValue> valid_value( - static_cast<base::DictionaryValue*>( - deserializer.Deserialize(&error_code, &error))); + scoped_ptr<base::DictionaryValue> valid_value = base::DictionaryValue::From( + 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 530a006b..4039b57 100644 --- a/extensions/browser/image_loader_unittest.cc +++ b/extensions/browser/image_loader_unittest.cc @@ -83,9 +83,8 @@ class ImageLoaderTest : public ExtensionsTest { std::string error; JSONFileValueDeserializer deserializer( extension_dir.AppendASCII("manifest.json")); - scoped_ptr<base::DictionaryValue> valid_value( - static_cast<base::DictionaryValue*>( - deserializer.Deserialize(&error_code, &error))); + scoped_ptr<base::DictionaryValue> valid_value = base::DictionaryValue::From( + 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 dd96b07..c4ebbe9 100644 --- a/extensions/common/extension_l10n_util.cc +++ b/extensions/common/extension_l10n_util.cc @@ -39,7 +39,8 @@ base::DictionaryValue* LoadMessageFile(const base::FilePath& locale_path, base::FilePath file = locale_path.AppendASCII(locale).Append(extensions::kMessagesFilename); JSONFileValueDeserializer messages_deserializer(file); - base::Value* dictionary = messages_deserializer.Deserialize(NULL, error); + scoped_ptr<base::DictionaryValue> dictionary = base::DictionaryValue::From( + messages_deserializer.Deserialize(NULL, error)); if (!dictionary) { if (error->empty()) { // JSONFileValueSerializer just returns NULL if file cannot be found. It @@ -54,7 +55,7 @@ base::DictionaryValue* LoadMessageFile(const base::FilePath& locale_path, } } - return static_cast<base::DictionaryValue*>(dictionary); + return dictionary.release(); } // Localizes manifest value of string type for a given key. diff --git a/extensions/common/file_util_unittest.cc b/extensions/common/file_util_unittest.cc index df82b82..0814334 100644 --- a/extensions/common/file_util_unittest.cc +++ b/extensions/common/file_util_unittest.cc @@ -44,7 +44,7 @@ scoped_refptr<Extension> LoadExtensionManifest( int extra_flags, std::string* error) { JSONStringValueDeserializer deserializer(manifest_value); - scoped_ptr<base::Value> result(deserializer.Deserialize(NULL, error)); + 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 048e183..37034b5 100644 --- a/extensions/common/manifest_test.cc +++ b/extensions/common/manifest_test.cc @@ -29,7 +29,7 @@ base::DictionaryValue* LoadManifestFile(const base::FilePath& manifest_path, JSONFileValueDeserializer deserializer(manifest_path); base::DictionaryValue* manifest = static_cast<base::DictionaryValue*>( - deserializer.Deserialize(NULL, error)); + deserializer.Deserialize(NULL, error).release()); // 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 6e28a49b..f499808 100644 --- a/extensions/utility/unpacker.cc +++ b/extensions/utility/unpacker.cc @@ -121,7 +121,7 @@ scoped_ptr<base::DictionaryValue> Unpacker::ReadManifest() { JSONFileValueDeserializer deserializer(manifest_path); std::string error; - scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error)); + scoped_ptr<base::Value> root = deserializer.Deserialize(NULL, &error); if (!root.get()) { SetError(error); return NULL; @@ -253,8 +253,8 @@ bool Unpacker::AddDecodedImage(const base::FilePath& path) { bool Unpacker::ReadMessageCatalog(const base::FilePath& message_path) { std::string error; JSONFileValueDeserializer deserializer(message_path); - scoped_ptr<base::DictionaryValue> root = base::DictionaryValue::From( - make_scoped_ptr(deserializer.Deserialize(NULL, &error))); + scoped_ptr<base::DictionaryValue> root = + base::DictionaryValue::From(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 e77aedf..e588519 100644 --- a/google_apis/drive/test_util.cc +++ b/google_apis/drive/test_util.cc @@ -82,7 +82,7 @@ scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path) { std::string error; JSONFileValueDeserializer deserializer(path); - scoped_ptr<base::Value> value(deserializer.Deserialize(NULL, &error)); + 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 7b22721..cf51255 100644 --- a/remoting/host/pairing_registry_delegate_linux.cc +++ b/remoting/host/pairing_registry_delegate_linux.cc @@ -49,8 +49,8 @@ scoped_ptr<base::ListValue> PairingRegistryDelegateLinux::LoadAll() { JSONFileValueDeserializer deserializer(pairing_file); int error_code; std::string error_message; - scoped_ptr<base::Value> pairing_json( - deserializer.Deserialize(&error_code, &error_message)); + scoped_ptr<base::Value> pairing_json = + deserializer.Deserialize(&error_code, &error_message); if (!pairing_json) { LOG(WARNING) << "Failed to load '" << pairing_file.value() << "' (" << error_code << ")."; @@ -88,8 +88,8 @@ PairingRegistry::Pairing PairingRegistryDelegateLinux::Load( JSONFileValueDeserializer deserializer(pairing_file); int error_code; std::string error_message; - scoped_ptr<base::Value> pairing( - deserializer.Deserialize(&error_code, &error_message)); + scoped_ptr<base::Value> pairing = + 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 a714e31..90b04ba 100644 --- a/remoting/host/pairing_registry_delegate_win.cc +++ b/remoting/host/pairing_registry_delegate_win.cc @@ -52,8 +52,8 @@ scoped_ptr<base::DictionaryValue> ReadValue(const base::win::RegKey& key, JSONStringValueDeserializer deserializer(value_json_utf8); int error_code; std::string error_message; - scoped_ptr<base::Value> value(deserializer.Deserialize(&error_code, - &error_message)); + scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_message); if (!value) { LOG(ERROR) << "Failed to parse '" << value_name << "': " << error_message << " (" << error_code << ")."; diff --git a/rlz/chromeos/lib/rlz_value_store_chromeos.cc b/rlz/chromeos/lib/rlz_value_store_chromeos.cc index 80d269e..6714de4 100644 --- a/rlz/chromeos/lib/rlz_value_store_chromeos.cc +++ b/rlz/chromeos/lib/rlz_value_store_chromeos.cc @@ -212,8 +212,8 @@ void RlzValueStoreChromeOS::ReadStore() { int error_code = 0; std::string error_msg; JSONFileValueDeserializer deserializer(store_path_); - scoped_ptr<base::Value> value( - deserializer.Deserialize(&error_code, &error_msg)); + scoped_ptr<base::Value> value = + deserializer.Deserialize(&error_code, &error_msg); switch (error_code) { case JSONFileValueDeserializer::JSON_NO_SUCH_FILE: read_only_ = false; diff --git a/ui/app_list/search/dictionary_data_store.cc b/ui/app_list/search/dictionary_data_store.cc index 45f53ca..443d973 100644 --- a/ui/app_list/search/dictionary_data_store.cc +++ b/ui/app_list/search/dictionary_data_store.cc @@ -67,16 +67,16 @@ scoped_ptr<base::DictionaryValue> DictionaryDataStore::LoadOnBlockingPool() { int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; std::string error_message; JSONFileValueDeserializer deserializer(data_file_); - base::Value* value = deserializer.Deserialize(&error_code, &error_message); - base::DictionaryValue* dict_value = NULL; - if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !value || - !value->GetAsDictionary(&dict_value) || !dict_value) { + scoped_ptr<base::DictionaryValue> dict_value = base::DictionaryValue::From( + deserializer.Deserialize(&error_code, &error_message)); + if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !dict_value) { return nullptr; } - base::DictionaryValue* return_dict = dict_value->DeepCopy(); - cached_dict_.reset(dict_value); - return make_scoped_ptr(return_dict); + scoped_ptr<base::DictionaryValue> return_dict = + make_scoped_ptr(dict_value.get()->DeepCopy()); + cached_dict_ = dict_value.Pass(); + return return_dict; } bool DictionaryDataStore::SerializeData(std::string* data) { |