diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 10:32:41 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 10:32:41 +0000 |
commit | b54e6259cc91acf5c1f37ae5f7126a47a9447b1f (patch) | |
tree | 1c521be12176fc81f84110372ad874548a325e64 | |
parent | 63aaa3f95c09df0edfc9a3703ad638cd4644434b (diff) | |
download | chromium_src-b54e6259cc91acf5c1f37ae5f7126a47a9447b1f.zip chromium_src-b54e6259cc91acf5c1f37ae5f7126a47a9447b1f.tar.gz chromium_src-b54e6259cc91acf5c1f37ae5f7126a47a9447b1f.tar.bz2 |
Get rid of some uses of base::Create*Value
BUG=160586
TBR=finnur, ajuma, thakis, atwilson
Review URL: https://codereview.chromium.org/131503015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247922 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/prefs/pref_registry_simple.cc | 13 | ||||
-rw-r--r-- | base/prefs/pref_service.cc | 14 | ||||
-rw-r--r-- | base/prefs/pref_service_unittest.cc | 10 | ||||
-rw-r--r-- | base/values.cc | 38 | ||||
-rw-r--r-- | base/values_unittest.cc | 6 | ||||
-rw-r--r-- | cc/resources/managed_tile_state.cc | 20 | ||||
-rw-r--r-- | cc/resources/raster_mode.cc | 8 | ||||
-rw-r--r-- | cc/resources/tile_priority.cc | 37 | ||||
-rw-r--r-- | extensions/common/url_pattern_set.cc | 2 | ||||
-rw-r--r-- | rlz/chromeos/lib/rlz_value_store_chromeos.cc | 4 | ||||
-rw-r--r-- | sync/syncable/entry_kernel.cc | 2 |
11 files changed, 73 insertions, 81 deletions
diff --git a/base/prefs/pref_registry_simple.cc b/base/prefs/pref_registry_simple.cc index c068b4b..7453016 100644 --- a/base/prefs/pref_registry_simple.cc +++ b/base/prefs/pref_registry_simple.cc @@ -16,29 +16,28 @@ PrefRegistrySimple::~PrefRegistrySimple() { void PrefRegistrySimple::RegisterBooleanPref(const char* path, bool default_value) { - RegisterPreference(path, base::Value::CreateBooleanValue(default_value)); + RegisterPreference(path, new base::FundamentalValue(default_value)); } void PrefRegistrySimple::RegisterIntegerPref(const char* path, int default_value) { - RegisterPreference(path, base::Value::CreateIntegerValue(default_value)); + RegisterPreference(path, new base::FundamentalValue(default_value)); } void PrefRegistrySimple::RegisterDoublePref(const char* path, double default_value) { - RegisterPreference(path, base::Value::CreateDoubleValue(default_value)); + RegisterPreference(path, new base::FundamentalValue(default_value)); } void PrefRegistrySimple::RegisterStringPref(const char* path, const std::string& default_value) { - RegisterPreference(path, base::Value::CreateStringValue(default_value)); + RegisterPreference(path, new base::StringValue(default_value)); } void PrefRegistrySimple::RegisterFilePathPref( const char* path, const base::FilePath& default_value) { - RegisterPreference(path, - base::Value::CreateStringValue(default_value.value())); + RegisterPreference(path, new base::StringValue(default_value.value())); } void PrefRegistrySimple::RegisterListPref(const char* path) { @@ -63,5 +62,5 @@ void PrefRegistrySimple::RegisterDictionaryPref( void PrefRegistrySimple::RegisterInt64Pref(const char* path, int64 default_value) { RegisterPreference( - path, base::Value::CreateStringValue(base::Int64ToString(default_value))); + path, new base::StringValue(base::Int64ToString(default_value))); } diff --git a/base/prefs/pref_service.cc b/base/prefs/pref_service.cc index 576043b..8a2c7421 100644 --- a/base/prefs/pref_service.cc +++ b/base/prefs/pref_service.cc @@ -336,19 +336,19 @@ void PrefService::Set(const char* path, const base::Value& value) { } void PrefService::SetBoolean(const char* path, bool value) { - SetUserPrefValue(path, base::Value::CreateBooleanValue(value)); + SetUserPrefValue(path, new base::FundamentalValue(value)); } void PrefService::SetInteger(const char* path, int value) { - SetUserPrefValue(path, base::Value::CreateIntegerValue(value)); + SetUserPrefValue(path, new base::FundamentalValue(value)); } void PrefService::SetDouble(const char* path, double value) { - SetUserPrefValue(path, base::Value::CreateDoubleValue(value)); + SetUserPrefValue(path, new base::FundamentalValue(value)); } void PrefService::SetString(const char* path, const std::string& value) { - SetUserPrefValue(path, base::Value::CreateStringValue(value)); + SetUserPrefValue(path, new base::StringValue(value)); } void PrefService::SetFilePath(const char* path, const base::FilePath& value) { @@ -356,8 +356,7 @@ void PrefService::SetFilePath(const char* path, const base::FilePath& value) { } void PrefService::SetInt64(const char* path, int64 value) { - SetUserPrefValue(path, - base::Value::CreateStringValue(base::Int64ToString(value))); + SetUserPrefValue(path, new base::StringValue(base::Int64ToString(value))); } int64 PrefService::GetInt64(const char* path) const { @@ -378,8 +377,7 @@ int64 PrefService::GetInt64(const char* path) const { } void PrefService::SetUint64(const char* path, uint64 value) { - SetUserPrefValue(path, - base::Value::CreateStringValue(base::Uint64ToString(value))); + SetUserPrefValue(path, new base::StringValue(base::Uint64ToString(value))); } uint64 PrefService::GetUint64(const char* path) const { diff --git a/base/prefs/pref_service_unittest.cc b/base/prefs/pref_service_unittest.cc index ff6bb2f..36ad887 100644 --- a/base/prefs/pref_service_unittest.cc +++ b/base/prefs/pref_service_unittest.cc @@ -79,7 +79,7 @@ TEST(PrefServiceTest, Observers) { TestingPrefServiceSimple prefs; prefs.SetUserPref(pref_name, - base::Value::CreateStringValue("http://www.cnn.com")); + new base::StringValue("http://www.cnn.com")); prefs.registry()->RegisterStringPref(pref_name, std::string()); const char new_pref_value[] = "http://www.google.com/"; @@ -138,7 +138,7 @@ TEST(PrefServiceTest, GetValueChangedType) { // Check falling back to a recommended value. prefs.SetUserPref(kPrefName, - base::Value::CreateStringValue("not an integer")); + new base::StringValue("not an integer")); const PrefService::Preference* pref = prefs.FindPreference(kPrefName); ASSERT_TRUE(pref); const base::Value* value = pref->GetValue(); @@ -173,7 +173,7 @@ TEST(PrefServiceTest, GetValueAndGetRecommendedValue) { ASSERT_FALSE(value); // Set a user-set value. - prefs.SetUserPref(kPrefName, base::Value::CreateIntegerValue(kUserValue)); + prefs.SetUserPref(kPrefName, new base::FundamentalValue(kUserValue)); // Check that GetValue() returns the user-set value. value = pref->GetValue(); @@ -189,7 +189,7 @@ TEST(PrefServiceTest, GetValueAndGetRecommendedValue) { // Set a recommended value. prefs.SetRecommendedPref(kPrefName, - base::Value::CreateIntegerValue(kRecommendedValue)); + new base::FundamentalValue(kRecommendedValue)); // Check that GetValue() returns the user-set value. value = pref->GetValue(); @@ -302,7 +302,7 @@ TEST_F(PrefServiceSetValueTest, SetListValue) { Mock::VerifyAndClearExpectations(&observer_); base::ListValue new_value; - new_value.Append(base::Value::CreateStringValue(kValue)); + new_value.Append(new base::StringValue(kValue)); observer_.Expect(kName, &new_value); prefs_.Set(kName, new_value); Mock::VerifyAndClearExpectations(&observer_); diff --git a/base/values.cc b/base/values.cc index 6068556..fa256aa 100644 --- a/base/values.cc +++ b/base/values.cc @@ -225,13 +225,13 @@ bool FundamentalValue::GetAsDouble(double* out_value) const { FundamentalValue* FundamentalValue::DeepCopy() const { switch (GetType()) { case TYPE_BOOLEAN: - return CreateBooleanValue(boolean_value_); + return new FundamentalValue(boolean_value_); case TYPE_INTEGER: - return CreateIntegerValue(integer_value_); + return new FundamentalValue(integer_value_); case TYPE_DOUBLE: - return CreateDoubleValue(double_value_); + return new FundamentalValue(double_value_); default: NOTREACHED(); @@ -291,7 +291,7 @@ bool StringValue::GetAsString(string16* out_value) const { } StringValue* StringValue::DeepCopy() const { - return CreateStringValue(value_); + return new StringValue(value_); } bool StringValue::Equals(const Value* other) const { @@ -403,25 +403,25 @@ void DictionaryValue::Set(const std::string& path, Value* in_value) { } void DictionaryValue::SetBoolean(const std::string& path, bool in_value) { - Set(path, CreateBooleanValue(in_value)); + Set(path, new FundamentalValue(in_value)); } void DictionaryValue::SetInteger(const std::string& path, int in_value) { - Set(path, CreateIntegerValue(in_value)); + Set(path, new FundamentalValue(in_value)); } void DictionaryValue::SetDouble(const std::string& path, double in_value) { - Set(path, CreateDoubleValue(in_value)); + Set(path, new FundamentalValue(in_value)); } void DictionaryValue::SetString(const std::string& path, const std::string& in_value) { - Set(path, CreateStringValue(in_value)); + Set(path, new StringValue(in_value)); } void DictionaryValue::SetString(const std::string& path, const string16& in_value) { - Set(path, CreateStringValue(in_value)); + Set(path, new StringValue(in_value)); } void DictionaryValue::SetWithoutPathExpansion(const std::string& key, @@ -439,27 +439,27 @@ void DictionaryValue::SetWithoutPathExpansion(const std::string& key, void DictionaryValue::SetBooleanWithoutPathExpansion( const std::string& path, bool in_value) { - SetWithoutPathExpansion(path, CreateBooleanValue(in_value)); + SetWithoutPathExpansion(path, new FundamentalValue(in_value)); } void DictionaryValue::SetIntegerWithoutPathExpansion( const std::string& path, int in_value) { - SetWithoutPathExpansion(path, CreateIntegerValue(in_value)); + SetWithoutPathExpansion(path, new FundamentalValue(in_value)); } void DictionaryValue::SetDoubleWithoutPathExpansion( const std::string& path, double in_value) { - SetWithoutPathExpansion(path, CreateDoubleValue(in_value)); + SetWithoutPathExpansion(path, new FundamentalValue(in_value)); } void DictionaryValue::SetStringWithoutPathExpansion( const std::string& path, const std::string& in_value) { - SetWithoutPathExpansion(path, CreateStringValue(in_value)); + SetWithoutPathExpansion(path, new StringValue(in_value)); } void DictionaryValue::SetStringWithoutPathExpansion( const std::string& path, const string16& in_value) { - SetWithoutPathExpansion(path, CreateStringValue(in_value)); + SetWithoutPathExpansion(path, new StringValue(in_value)); } bool DictionaryValue::Get(const std::string& path, @@ -1025,23 +1025,23 @@ void ListValue::Append(Value* in_value) { } void ListValue::AppendBoolean(bool in_value) { - Append(CreateBooleanValue(in_value)); + Append(new FundamentalValue(in_value)); } void ListValue::AppendInteger(int in_value) { - Append(CreateIntegerValue(in_value)); + Append(new FundamentalValue(in_value)); } void ListValue::AppendDouble(double in_value) { - Append(CreateDoubleValue(in_value)); + Append(new FundamentalValue(in_value)); } void ListValue::AppendString(const std::string& in_value) { - Append(CreateStringValue(in_value)); + Append(new StringValue(in_value)); } void ListValue::AppendString(const string16& in_value) { - Append(CreateStringValue(in_value)); + Append(new StringValue(in_value)); } void ListValue::AppendStrings(const std::vector<std::string>& in_values) { diff --git a/base/values_unittest.cc b/base/values_unittest.cc index 70acdfd..c765dee 100644 --- a/base/values_unittest.cc +++ b/base/values_unittest.cc @@ -130,7 +130,7 @@ TEST(ValuesTest, BinaryValue) { } TEST(ValuesTest, StringValue) { - // Test overloaded CreateStringValue. + // Test overloaded StringValue constructor. scoped_ptr<Value> narrow_value(new StringValue("narrow")); ASSERT_TRUE(narrow_value.get()); ASSERT_TRUE(narrow_value->IsType(Value::TYPE_STRING)); @@ -325,8 +325,8 @@ TEST(ValuesTest, DictionaryWithoutPathExpansion) { TEST(ValuesTest, DictionaryRemovePath) { DictionaryValue dict; - dict.Set("a.long.way.down", Value::CreateIntegerValue(1)); - dict.Set("a.long.key.path", Value::CreateBooleanValue(true)); + dict.Set("a.long.way.down", new FundamentalValue(1)); + dict.Set("a.long.key.path", new FundamentalValue(true)); scoped_ptr<Value> removed_item; EXPECT_TRUE(dict.RemovePath("a.long.way.down", &removed_item)); diff --git a/cc/resources/managed_tile_state.cc b/cc/resources/managed_tile_state.cc index 1c66044..198ebb3 100644 --- a/cc/resources/managed_tile_state.cc +++ b/cc/resources/managed_tile_state.cc @@ -14,34 +14,34 @@ scoped_ptr<base::Value> ManagedTileBinAsValue(ManagedTileBin bin) { switch (bin) { case NOW_AND_READY_TO_DRAW_BIN: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("NOW_AND_READY_TO_DRAW_BIN")); + new base::StringValue("NOW_AND_READY_TO_DRAW_BIN")); case NOW_BIN: - return scoped_ptr<base::Value>(base::Value::CreateStringValue("NOW_BIN")); + return scoped_ptr<base::Value>(new base::StringValue("NOW_BIN")); case SOON_BIN: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("SOON_BIN")); + new base::StringValue("SOON_BIN")); case EVENTUALLY_AND_ACTIVE_BIN: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("EVENTUALLY_AND_ACTIVE_BIN")); + new base::StringValue("EVENTUALLY_AND_ACTIVE_BIN")); case EVENTUALLY_BIN: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("EVENTUALLY_BIN")); + new base::StringValue("EVENTUALLY_BIN")); case AT_LAST_AND_ACTIVE_BIN: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("AT_LAST_AND_ACTIVE_BIN")); + new base::StringValue("AT_LAST_AND_ACTIVE_BIN")); case AT_LAST_BIN: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("AT_LAST_BIN")); + new base::StringValue("AT_LAST_BIN")); case NEVER_BIN: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("NEVER_BIN")); + new base::StringValue("NEVER_BIN")); case NUM_BINS: NOTREACHED(); return scoped_ptr<base::Value>( - base::Value::CreateStringValue("Invalid Bin (NUM_BINS)")); + new base::StringValue("Invalid Bin (NUM_BINS)")); } return scoped_ptr<base::Value>( - base::Value::CreateStringValue("Invalid Bin (UNKNOWN)")); + new base::StringValue("Invalid Bin (UNKNOWN)")); } ManagedTileState::ManagedTileState() diff --git a/cc/resources/raster_mode.cc b/cc/resources/raster_mode.cc index 47d6344..61375c2 100644 --- a/cc/resources/raster_mode.cc +++ b/cc/resources/raster_mode.cc @@ -14,17 +14,17 @@ scoped_ptr<base::Value> RasterModeAsValue(RasterMode raster_mode) { switch (raster_mode) { case HIGH_QUALITY_NO_LCD_RASTER_MODE: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("HIGH_QUALITY_NO_LCD_RASTER_MODE")); + new base::StringValue("HIGH_QUALITY_NO_LCD_RASTER_MODE")); case HIGH_QUALITY_RASTER_MODE: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("HIGH_QUALITY_RASTER_MODE")); + new base::StringValue("HIGH_QUALITY_RASTER_MODE")); case LOW_QUALITY_RASTER_MODE: return scoped_ptr<base::Value>( - base::Value::CreateStringValue("LOW_QUALITY_RASTER_MODE")); + new base::StringValue("LOW_QUALITY_RASTER_MODE")); default: NOTREACHED() << "Unrecognized RasterMode value " << raster_mode; return scoped_ptr<base::Value>( - base::Value::CreateStringValue("<unknown RasterMode value>")); + new base::StringValue("<unknown RasterMode value>")); } } diff --git a/cc/resources/tile_priority.cc b/cc/resources/tile_priority.cc index 1523eef..672a2f0 100644 --- a/cc/resources/tile_priority.cc +++ b/cc/resources/tile_priority.cc @@ -55,14 +55,12 @@ namespace cc { scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) { switch (tree) { case ACTIVE_TREE: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( - "ACTIVE_TREE")); + return scoped_ptr<base::Value>(new base::StringValue("ACTIVE_TREE")); case PENDING_TREE: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( - "PENDING_TREE")); + return scoped_ptr<base::Value>(new base::StringValue("PENDING_TREE")); default: DCHECK(false) << "Unrecognized WhichTree value " << tree; - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "<unknown WhichTree value>")); } } @@ -71,17 +69,15 @@ scoped_ptr<base::Value> TileResolutionAsValue( TileResolution resolution) { switch (resolution) { case LOW_RESOLUTION: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( - "LOW_RESOLUTION")); + return scoped_ptr<base::Value>(new base::StringValue("LOW_RESOLUTION")); case HIGH_RESOLUTION: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( - "HIGH_RESOLUTION")); + return scoped_ptr<base::Value>(new base::StringValue("HIGH_RESOLUTION")); case NON_IDEAL_RESOLUTION: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "NON_IDEAL_RESOLUTION")); } DCHECK(false) << "Unrecognized TileResolution value " << resolution; - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "<unknown TileResolution value>")); } @@ -138,20 +134,19 @@ scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( TileMemoryLimitPolicy policy) { switch (policy) { case ALLOW_NOTHING: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( - "ALLOW_NOTHING")); + return scoped_ptr<base::Value>(new base::StringValue("ALLOW_NOTHING")); case ALLOW_ABSOLUTE_MINIMUM: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "ALLOW_ABSOLUTE_MINIMUM")); case ALLOW_PREPAINT_ONLY: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "ALLOW_PREPAINT_ONLY")); case ALLOW_ANYTHING: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "ALLOW_ANYTHING")); default: DCHECK(false) << "Unrecognized policy value"; - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "<unknown>")); } } @@ -159,17 +154,17 @@ scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) { switch (prio) { case SAME_PRIORITY_FOR_BOTH_TREES: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "SAME_PRIORITY_FOR_BOTH_TREES")); case SMOOTHNESS_TAKES_PRIORITY: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "SMOOTHNESS_TAKES_PRIORITY")); case NEW_CONTENT_TAKES_PRIORITY: - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "NEW_CONTENT_TAKES_PRIORITY")); } DCHECK(false) << "Unrecognized priority value " << prio; - return scoped_ptr<base::Value>(base::Value::CreateStringValue( + return scoped_ptr<base::Value>(new base::StringValue( "<unknown>")); } diff --git a/extensions/common/url_pattern_set.cc b/extensions/common/url_pattern_set.cc index 8187299..118f9ee 100644 --- a/extensions/common/url_pattern_set.cc +++ b/extensions/common/url_pattern_set.cc @@ -186,7 +186,7 @@ scoped_ptr<base::ListValue> URLPatternSet::ToValue() const { scoped_ptr<base::ListValue> value(new base::ListValue); for (URLPatternSet::const_iterator i = patterns_.begin(); i != patterns_.end(); ++i) - value->AppendIfNotPresent(base::Value::CreateStringValue(i->GetAsString())); + value->AppendIfNotPresent(new base::StringValue(i->GetAsString())); return value.Pass(); } diff --git a/rlz/chromeos/lib/rlz_value_store_chromeos.cc b/rlz/chromeos/lib/rlz_value_store_chromeos.cc index 7fe5fdb..0cd87af 100644 --- a/rlz/chromeos/lib/rlz_value_store_chromeos.cc +++ b/rlz/chromeos/lib/rlz_value_store_chromeos.cc @@ -141,7 +141,7 @@ bool RlzValueStoreChromeOS::AddProductEvent(Product product, const char* event_rlz) { DCHECK(CalledOnValidThread()); return AddValueToList(GetKeyName(kProductEventKey, product), - base::Value::CreateStringValue(event_rlz)); + new base::StringValue(event_rlz)); } bool RlzValueStoreChromeOS::ReadProductEvents( @@ -178,7 +178,7 @@ bool RlzValueStoreChromeOS::AddStatefulEvent(Product product, const char* event_rlz) { DCHECK(CalledOnValidThread()); return AddValueToList(GetKeyName(kStatefulEventKey, product), - base::Value::CreateStringValue(event_rlz)); + new base::StringValue(event_rlz)); } bool RlzValueStoreChromeOS::IsStatefulEvent(Product product, diff --git a/sync/syncable/entry_kernel.cc b/sync/syncable/entry_kernel.cc index d872695..9734483 100644 --- a/sync/syncable/entry_kernel.cc +++ b/sync/syncable/entry_kernel.cc @@ -126,7 +126,7 @@ base::StringValue* StringToValue(const std::string& str) { } base::StringValue* UniquePositionToValue(const UniquePosition& pos) { - return base::Value::CreateStringValue(pos.ToDebugString()); + return new base::StringValue(pos.ToDebugString()); } } // namespace |