diff options
author | dcheng <dcheng@chromium.org> | 2016-02-26 19:51:32 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-27 03:53:04 +0000 |
commit | 794d2bd77811b6d6b45048c19c287075cc9930db (patch) | |
tree | ef71bf3826d396a488ef0c72a68b3d7f4ff236d3 /extensions | |
parent | 47dc6a8a0f7d36d20f90df5ac62da075d45bc9c3 (diff) | |
download | chromium_src-794d2bd77811b6d6b45048c19c287075cc9930db.zip chromium_src-794d2bd77811b6d6b45048c19c287075cc9930db.tar.gz chromium_src-794d2bd77811b6d6b45048c19c287075cc9930db.tar.bz2 |
Make extensions::DictionaryBuilder and extensions::ListValue unmovable.
There's no reason for these classes to be movable. std::move() is just
being used as a synonym for Build().
In addition:
- Build() is fewer characters than std::move().
- clang-format works better when builder syntax is consistently used,
which makes it easier for readers to visually match up deeply nested
builders.
- It's surprising to see std::move() used with what looks like a
temporary.
BUG=none
Review URL: https://codereview.chromium.org/1739183003
Cr-Commit-Position: refs/heads/master@{#378107}
Diffstat (limited to 'extensions')
20 files changed, 172 insertions, 189 deletions
diff --git a/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc b/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc index 701a28d..597d738 100644 --- a/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc +++ b/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc @@ -83,10 +83,11 @@ TEST_F(BluetoothEventRouterTest, MultipleBluetoothEventListeners) { TEST_F(BluetoothEventRouterTest, UnloadExtension) { scoped_refptr<const Extension> extension = ExtensionBuilder() - .SetManifest(std::move(DictionaryBuilder() - .Set("name", "BT event router test") - .Set("version", "1.0") - .Set("manifest_version", 2))) + .SetManifest(DictionaryBuilder() + .Set("name", "BT event router test") + .Set("version", "1.0") + .Set("manifest_version", 2) + .Build()) .SetID(kTestExtensionId) .Build(); diff --git a/extensions/browser/api/device_permissions_prompt_unittest.cc b/extensions/browser/api/device_permissions_prompt_unittest.cc index 9c2d22c..ba6a07e 100644 --- a/extensions/browser/api/device_permissions_prompt_unittest.cc +++ b/extensions/browser/api/device_permissions_prompt_unittest.cc @@ -19,10 +19,11 @@ class DevicePermissionsPromptTest : public testing::Test {}; TEST_F(DevicePermissionsPromptTest, HidPromptMessages) { scoped_refptr<Extension> extension = ExtensionBuilder() - .SetManifest(std::move(DictionaryBuilder() - .Set("name", "Test Application") - .Set("manifest_version", 2) - .Set("version", "1.0"))) + .SetManifest(DictionaryBuilder() + .Set("name", "Test Application") + .Set("manifest_version", 2) + .Set("version", "1.0") + .Build()) .Build(); scoped_refptr<DevicePermissionsPrompt::Prompt> prompt = @@ -47,10 +48,11 @@ TEST_F(DevicePermissionsPromptTest, HidPromptMessages) { TEST_F(DevicePermissionsPromptTest, UsbPromptMessages) { scoped_refptr<Extension> extension = ExtensionBuilder() - .SetManifest(std::move(DictionaryBuilder() - .Set("name", "Test Application") - .Set("manifest_version", 2) - .Set("version", "1.0"))) + .SetManifest(DictionaryBuilder() + .Set("name", "Test Application") + .Set("manifest_version", 2) + .Set("version", "1.0") + .Build()) .Build(); scoped_refptr<DevicePermissionsPrompt::Prompt> prompt = diff --git a/extensions/browser/api_unittest.cc b/extensions/browser/api_unittest.cc index f0c0f61..0496563 100644 --- a/extensions/browser/api_unittest.cc +++ b/extensions/browser/api_unittest.cc @@ -44,12 +44,13 @@ void ApiUnitTest::SetUp() { content::TestBrowserThreadBundle::DEFAULT)); user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_); - extension_ = - ExtensionBuilder() - .SetManifest(std::move( - DictionaryBuilder().Set("name", "Test").Set("version", "1.0"))) - .SetLocation(Manifest::UNPACKED) - .Build(); + extension_ = ExtensionBuilder() + .SetManifest(DictionaryBuilder() + .Set("name", "Test") + .Set("version", "1.0") + .Build()) + .SetLocation(Manifest::UNPACKED) + .Build(); } void ApiUnitTest::CreateBackgroundPage() { diff --git a/extensions/browser/app_window/app_window_geometry_cache_unittest.cc b/extensions/browser/app_window/app_window_geometry_cache_unittest.cc index 491f614..3c664c6 100644 --- a/extensions/browser/app_window/app_window_geometry_cache_unittest.cc +++ b/extensions/browser/app_window/app_window_geometry_cache_unittest.cc @@ -36,8 +36,8 @@ const char kWindowId2[] = "windowid2"; // Create a very simple extension with id. scoped_refptr<Extension> CreateExtension(const std::string& id) { return ExtensionBuilder() - .SetManifest(std::move( - DictionaryBuilder().Set("name", "test").Set("version", "0.1"))) + .SetManifest( + DictionaryBuilder().Set("name", "test").Set("version", "0.1").Build()) .SetID(id) .Build(); } @@ -163,8 +163,10 @@ std::string AppWindowGeometryCacheTest::AddExtensionWithPrefs( browser_context()->GetPath().AppendASCII("Extensions").AppendASCII(name); scoped_refptr<Extension> extension = ExtensionBuilder() - .SetManifest(std::move( - DictionaryBuilder().Set("name", "test").Set("version", "0.1"))) + .SetManifest(DictionaryBuilder() + .Set("name", "test") + .Set("version", "0.1") + .Build()) .SetPath(path) .Build(); diff --git a/extensions/browser/lazy_background_task_queue_unittest.cc b/extensions/browser/lazy_background_task_queue_unittest.cc index a2b82eb..02ec3bb 100644 --- a/extensions/browser/lazy_background_task_queue_unittest.cc +++ b/extensions/browser/lazy_background_task_queue_unittest.cc @@ -82,10 +82,11 @@ class LazyBackgroundTaskQueueTest : public ExtensionsTest { scoped_refptr<Extension> CreateSimpleExtension() { scoped_refptr<Extension> extension = ExtensionBuilder() - .SetManifest(std::move(DictionaryBuilder() - .Set("name", "No background") - .Set("version", "1") - .Set("manifest_version", 2))) + .SetManifest(DictionaryBuilder() + .Set("name", "No background") + .Set("version", "1") + .Set("manifest_version", 2) + .Build()) .SetID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") .Build(); ExtensionRegistry::Get(browser_context())->AddEnabled(extension); @@ -96,15 +97,16 @@ class LazyBackgroundTaskQueueTest : public ExtensionsTest { scoped_refptr<Extension> CreateLazyBackgroundExtension() { scoped_refptr<Extension> extension = ExtensionBuilder() - .SetManifest(std::move( + .SetManifest( DictionaryBuilder() .Set("name", "Lazy background") .Set("version", "1") .Set("manifest_version", 2) - .Set("background", - std::move(DictionaryBuilder() - .Set("page", "background.html") - .SetBoolean("persistent", false))))) + .Set("background", DictionaryBuilder() + .Set("page", "background.html") + .SetBoolean("persistent", false) + .Build()) + .Build()) .SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") .Build(); ExtensionRegistry::Get(browser_context())->AddEnabled(extension); diff --git a/extensions/browser/mojo/keep_alive_impl_unittest.cc b/extensions/browser/mojo/keep_alive_impl_unittest.cc index c1f4810..5d640e0 100644 --- a/extensions/browser/mojo/keep_alive_impl_unittest.cc +++ b/extensions/browser/mojo/keep_alive_impl_unittest.cc @@ -28,17 +28,21 @@ class KeepAliveTest : public ExtensionsTest { message_loop_.reset(new base::MessageLoop); extension_ = ExtensionBuilder() - .SetManifest(std::move( + .SetManifest( DictionaryBuilder() .Set("name", "app") .Set("version", "1") .Set("manifest_version", 2) - .Set("app", - std::move(DictionaryBuilder().Set( - "background", - std::move(DictionaryBuilder().Set( - "scripts", std::move(ListBuilder().Append( - "background.js"))))))))) + .Set("app", DictionaryBuilder() + .Set("background", + DictionaryBuilder() + .Set("scripts", + ListBuilder() + .Append("background.js") + .Build()) + .Build()) + .Build()) + .Build()) .SetID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") .Build(); } @@ -110,16 +114,21 @@ TEST_F(KeepAliveTest, UnloadExtension) { scoped_refptr<const Extension> other_extension = ExtensionBuilder() - .SetManifest(std::move( + .SetManifest( DictionaryBuilder() .Set("name", "app") .Set("version", "1") .Set("manifest_version", 2) - .Set("app", std::move(DictionaryBuilder().Set( - "background", - std::move(DictionaryBuilder().Set( - "scripts", std::move(ListBuilder().Append( - "background.js"))))))))) + .Set("app", + DictionaryBuilder() + .Set("background", + DictionaryBuilder() + .Set("scripts", ListBuilder() + .Append("background.js") + .Build()) + .Build()) + .Build()) + .Build()) .SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") .Build(); diff --git a/extensions/browser/runtime_data_unittest.cc b/extensions/browser/runtime_data_unittest.cc index 6e522a4..790dd25 100644 --- a/extensions/browser/runtime_data_unittest.cc +++ b/extensions/browser/runtime_data_unittest.cc @@ -21,12 +21,12 @@ namespace { // Creates a very simple extension with a background page. scoped_refptr<Extension> CreateExtensionWithBackgroundPage() { return ExtensionBuilder() - .SetManifest(std::move( - DictionaryBuilder() - .Set("name", "test") - .Set("version", "0.1") - .Set("background", - std::move(DictionaryBuilder().Set("page", "bg.html"))))) + .SetManifest(DictionaryBuilder() + .Set("name", "test") + .Set("version", "0.1") + .Set("background", + DictionaryBuilder().Set("page", "bg.html").Build()) + .Build()) .SetID("id2") .Build(); } diff --git a/extensions/browser/updater/update_service_unittest.cc b/extensions/browser/updater/update_service_unittest.cc index 94bfad3..67c3087 100644 --- a/extensions/browser/updater/update_service_unittest.cc +++ b/extensions/browser/updater/update_service_unittest.cc @@ -183,10 +183,11 @@ TEST_F(UpdateServiceTest, BasicUpdateOperations) { ASSERT_TRUE(AddFileToDirectory(temp_dir.path(), bar_html, "world")); ExtensionBuilder builder; - builder.SetManifest(std::move(DictionaryBuilder() - .Set("name", "Foo") - .Set("version", "1.0") - .Set("manifest_version", 2))); + builder.SetManifest(DictionaryBuilder() + .Set("name", "Foo") + .Set("version", "1.0") + .Set("manifest_version", 2) + .Build()); builder.SetID(crx_file::id_util::GenerateId("whatever")); builder.SetPath(temp_dir.path()); diff --git a/extensions/browser/value_store/value_store_change_unittest.cc b/extensions/browser/value_store/value_store_change_unittest.cc index 123385b..895f1ac 100644 --- a/extensions/browser/value_store/value_store_change_unittest.cc +++ b/extensions/browser/value_store/value_store_change_unittest.cc @@ -61,7 +61,7 @@ TEST(ValueStoreChangeTest, ToJson) { DictionaryBuilder() .Set("key", "value") .Set("key.with.dots", "value.with.dots") - .Set("tricked", std::move(DictionaryBuilder().Set("you", "nodots"))) + .Set("tricked", DictionaryBuilder().Set("you", "nodots").Build()) .Set("tricked.you", "with.dots") .Build(); @@ -81,12 +81,14 @@ TEST(ValueStoreChangeTest, ToJson) { DictionaryBuilder v4(*value); scoped_ptr<base::DictionaryValue> expected_from_json = DictionaryBuilder() - .Set("key", std::move(DictionaryBuilder() - .Set("oldValue", std::move(v1)) - .Set("newValue", std::move(v2)))) - .Set("key.with.dots", std::move(DictionaryBuilder() - .Set("oldValue", std::move(v3)) - .Set("newValue", std::move(v4)))) + .Set("key", DictionaryBuilder() + .Set("oldValue", v1.Build()) + .Set("newValue", v2.Build()) + .Build()) + .Set("key.with.dots", DictionaryBuilder() + .Set("oldValue", v3.Build()) + .Set("newValue", v4.Build()) + .Build()) .Build(); EXPECT_TRUE(from_json->Equals(expected_from_json.get())); diff --git a/extensions/common/extension_builder.cc b/extensions/common/extension_builder.cc index 9e41166..905ba6b 100644 --- a/extensions/common/extension_builder.cc +++ b/extensions/common/extension_builder.cc @@ -61,8 +61,9 @@ ExtensionBuilder& ExtensionBuilder::SetManifest( return *this; } -ExtensionBuilder& ExtensionBuilder::MergeManifest(DictionaryBuilder& builder) { - manifest_->MergeDictionary(builder.Build().get()); +ExtensionBuilder& ExtensionBuilder::MergeManifest( + scoped_ptr<base::DictionaryValue> manifest) { + manifest_->MergeDictionary(manifest.get()); return *this; } diff --git a/extensions/common/extension_builder.h b/extensions/common/extension_builder.h index 4734baa..5fe9801 100644 --- a/extensions/common/extension_builder.h +++ b/extensions/common/extension_builder.h @@ -40,13 +40,10 @@ class ExtensionBuilder { ExtensionBuilder& SetLocation(Manifest::Location location); ExtensionBuilder& SetManifest(scoped_ptr<base::DictionaryValue> manifest); - ExtensionBuilder& SetManifest(DictionaryBuilder manifest_builder) { - return SetManifest(manifest_builder.Build()); - } - // Adds the keys from the DictionaryBuilder to the manifest, with new keys - // taking precedence. - ExtensionBuilder& MergeManifest(DictionaryBuilder& builder); + // Merge another manifest into the current manifest, with new keys taking + // precedence. + ExtensionBuilder& MergeManifest(scoped_ptr<base::DictionaryValue> manifest); ExtensionBuilder& AddFlags(int init_from_value_flags); diff --git a/extensions/common/features/base_feature_provider_unittest.cc b/extensions/common/features/base_feature_provider_unittest.cc index 43e0ce2..e601cfa5 100644 --- a/extensions/common/features/base_feature_provider_unittest.cc +++ b/extensions/common/features/base_feature_provider_unittest.cc @@ -46,10 +46,11 @@ TEST(BaseFeatureProviderTest, ManifestFeatureAvailability) { scoped_refptr<const Extension> extension = ExtensionBuilder() - .SetManifest(std::move(DictionaryBuilder() - .Set("name", "test extension") - .Set("version", "1") - .Set("description", "hello there"))) + .SetManifest(DictionaryBuilder() + .Set("name", "test extension") + .Set("version", "1") + .Set("description", "hello there") + .Build()) .Build(); ASSERT_TRUE(extension.get()); @@ -100,17 +101,21 @@ TEST(BaseFeatureProviderTest, PermissionFeatureAvailability) { scoped_refptr<const Extension> app = ExtensionBuilder() - .SetManifest(std::move( + .SetManifest( DictionaryBuilder() .Set("name", "test app") .Set("version", "1") - .Set("app", std::move(DictionaryBuilder().Set( - "background", - std::move(DictionaryBuilder().Set( - "scripts", std::move(ListBuilder().Append( - "background.js"))))))) - .Set("permissions", - std::move(ListBuilder().Append("power"))))) + .Set("app", + DictionaryBuilder() + .Set("background", + DictionaryBuilder() + .Set("scripts", ListBuilder() + .Append("background.js") + .Build()) + .Build()) + .Build()) + .Set("permissions", ListBuilder().Append("power").Build()) + .Build()) .Build(); ASSERT_TRUE(app.get()); ASSERT_TRUE(app->is_platform_app()); diff --git a/extensions/common/features/complex_feature_unittest.cc b/extensions/common/features/complex_feature_unittest.cc index 0dd7c8f..f60c900 100644 --- a/extensions/common/features/complex_feature_unittest.cc +++ b/extensions/common/features/complex_feature_unittest.cc @@ -24,8 +24,8 @@ TEST(ComplexFeatureTest, MultipleRulesWhitelist) { scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature); scoped_ptr<base::DictionaryValue> rule( DictionaryBuilder() - .Set("whitelist", std::move(ListBuilder().Append(kIdFoo))) - .Set("extension_types", std::move(ListBuilder().Append("extension"))) + .Set("whitelist", ListBuilder().Append(kIdFoo).Build()) + .Set("extension_types", ListBuilder().Append("extension").Build()) .Build()); simple_feature->Parse(rule.get()); features->push_back(std::move(simple_feature)); @@ -33,9 +33,9 @@ TEST(ComplexFeatureTest, MultipleRulesWhitelist) { // Rule: "legacy_packaged_app", whitelist "bar". simple_feature.reset(new SimpleFeature); rule = DictionaryBuilder() - .Set("whitelist", std::move(ListBuilder().Append(kIdBar))) + .Set("whitelist", ListBuilder().Append(kIdBar).Build()) .Set("extension_types", - std::move(ListBuilder().Append("legacy_packaged_app"))) + ListBuilder().Append("legacy_packaged_app").Build()) .Build(); simple_feature->Parse(rule.get()); features->push_back(std::move(simple_feature)); @@ -86,8 +86,8 @@ TEST(ComplexFeatureTest, Dependencies) { scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature); scoped_ptr<base::DictionaryValue> rule = DictionaryBuilder() - .Set("dependencies", std::move(ListBuilder().Append( - "manifest:content_security_policy"))) + .Set("dependencies", + ListBuilder().Append("manifest:content_security_policy").Build()) .Build(); simple_feature->Parse(rule.get()); features->push_back(std::move(simple_feature)); @@ -96,7 +96,7 @@ TEST(ComplexFeatureTest, Dependencies) { simple_feature.reset(new SimpleFeature); rule = DictionaryBuilder() .Set("dependencies", - std::move(ListBuilder().Append("permission:serial"))) + ListBuilder().Append("permission:serial").Build()) .Build(); simple_feature->Parse(rule.get()); features->push_back(std::move(simple_feature)); diff --git a/extensions/common/manifest_handler_unittest.cc b/extensions/common/manifest_handler_unittest.cc index 3e01d49..cbccf12 100644 --- a/extensions/common/manifest_handler_unittest.cc +++ b/extensions/common/manifest_handler_unittest.cc @@ -186,17 +186,19 @@ TEST_F(ManifestHandlerTest, DependentHandlers) { scoped_refptr<Extension> extension = ExtensionBuilder() - .SetManifest(std::move( - DictionaryBuilder() - .Set("name", "no name") - .Set("version", "0") - .Set("manifest_version", 2) - .Set("a", 1) - .Set("b", 2) - .Set("c", std::move( - DictionaryBuilder().Set("d", 3).Set("e", 4).Set( - "f", 5))) - .Set("g", 6))) + .SetManifest(DictionaryBuilder() + .Set("name", "no name") + .Set("version", "0") + .Set("manifest_version", 2) + .Set("a", 1) + .Set("b", 2) + .Set("c", DictionaryBuilder() + .Set("d", 3) + .Set("e", 4) + .Set("f", 5) + .Build()) + .Set("g", 6) + .Build()) .Build(); // A, B, C.EZ, C.D, K @@ -248,12 +250,13 @@ TEST_F(ManifestHandlerTest, Validate) { ScopedTestingManifestHandlerRegistry registry; scoped_refptr<Extension> extension = ExtensionBuilder() - .SetManifest(std::move(DictionaryBuilder() - .Set("name", "no name") - .Set("version", "0") - .Set("manifest_version", 2) - .Set("a", 1) - .Set("b", 2))) + .SetManifest(DictionaryBuilder() + .Set("name", "no name") + .Set("version", "0") + .Set("manifest_version", 2) + .Set("a", 1) + .Set("b", 2) + .Build()) .Build(); EXPECT_TRUE(extension.get()); diff --git a/extensions/common/test_util.cc b/extensions/common/test_util.cc index e3775e5..c065c29 100644 --- a/extensions/common/test_util.cc +++ b/extensions/common/test_util.cc @@ -14,39 +14,43 @@ namespace extensions { namespace test_util { ExtensionBuilder BuildExtension(ExtensionBuilder builder) { - builder.SetManifest(std::move(DictionaryBuilder() - .Set("name", "Test extension") - .Set("version", "1.0") - .Set("manifest_version", 2))); + builder.SetManifest(DictionaryBuilder() + .Set("name", "Test extension") + .Set("version", "1.0") + .Set("manifest_version", 2) + .Build()); return builder; } ExtensionBuilder BuildApp(ExtensionBuilder builder) { - builder.SetManifest(std::move( + builder.SetManifest( DictionaryBuilder() .Set("name", "Test extension") .Set("version", "1.0") .Set("manifest_version", 2) - .Set("app", - std::move(extensions::DictionaryBuilder().Set( - "background", - std::move(extensions::DictionaryBuilder().Set( - "scripts", std::move(extensions::ListBuilder().Append( - "background.js"))))))))); + .Set("app", extensions::DictionaryBuilder() + .Set("background", + extensions::DictionaryBuilder() + .Set("scripts", extensions::ListBuilder() + .Append("background.js") + .Build()) + .Build()) + .Build()) + .Build()); return builder; } scoped_refptr<Extension> CreateEmptyExtension() { return ExtensionBuilder() - .SetManifest(std::move( - DictionaryBuilder().Set("name", "Test").Set("version", "1.0"))) + .SetManifest( + DictionaryBuilder().Set("name", "Test").Set("version", "1.0").Build()) .Build(); } scoped_refptr<Extension> CreateEmptyExtension(const std::string& id) { return ExtensionBuilder() - .SetManifest(std::move( - DictionaryBuilder().Set("name", "test").Set("version", "0.1"))) + .SetManifest( + DictionaryBuilder().Set("name", "test").Set("version", "0.1").Build()) .SetID(id) .Build(); } diff --git a/extensions/common/value_builder.cc b/extensions/common/value_builder.cc index 987bbb4..efc2e44 100644 --- a/extensions/common/value_builder.cc +++ b/extensions/common/value_builder.cc @@ -20,14 +20,6 @@ DictionaryBuilder::DictionaryBuilder(const base::DictionaryValue& init) DictionaryBuilder::~DictionaryBuilder() {} -DictionaryBuilder::DictionaryBuilder(DictionaryBuilder&& other) - : dict_(other.Build()) {} - -DictionaryBuilder& DictionaryBuilder::operator=(DictionaryBuilder&& other) { - dict_ = other.Build(); - return *this; -} - std::string DictionaryBuilder::ToJSON() const { std::string json; base::JSONWriter::WriteWithOptions( @@ -60,18 +52,6 @@ DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, } DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, - DictionaryBuilder in_value) { - dict_->SetWithoutPathExpansion(path, in_value.Build()); - return *this; -} - -DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, - ListBuilder in_value) { - dict_->SetWithoutPathExpansion(path, in_value.Build()); - return *this; -} - -DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, scoped_ptr<base::Value> in_value) { dict_->SetWithoutPathExpansion(path, std::move(in_value)); return *this; @@ -90,14 +70,6 @@ ListBuilder::ListBuilder(const base::ListValue& init) : list_(init.DeepCopy()) { } ListBuilder::~ListBuilder() {} -ListBuilder::ListBuilder(ListBuilder&& other) - : list_(other.Build()) {} - -ListBuilder& ListBuilder::operator=(ListBuilder&& other) { - list_ = other.Build(); - return *this; -} - ListBuilder& ListBuilder::Append(int in_value) { list_->Append(new base::FundamentalValue(in_value)); return *this; @@ -118,13 +90,8 @@ ListBuilder& ListBuilder::Append(const base::string16& in_value) { return *this; } -ListBuilder& ListBuilder::Append(DictionaryBuilder in_value) { - list_->Append(in_value.Build()); - return *this; -} - -ListBuilder& ListBuilder::Append(ListBuilder in_value) { - list_->Append(in_value.Build()); +ListBuilder& ListBuilder::Append(scoped_ptr<base::Value> in_value) { + list_->Append(std::move(in_value)); return *this; } diff --git a/extensions/common/value_builder.h b/extensions/common/value_builder.h index d746904..27c4e01 100644 --- a/extensions/common/value_builder.h +++ b/extensions/common/value_builder.h @@ -6,19 +6,13 @@ // aren't specific to extensions and could move up to base/ if there's interest // from other sub-projects. // -// The general pattern is to write: +// The pattern is to write: // // scoped_ptr<BuiltType> result(FooBuilder() // .Set(args) // .Set(args) // .Build()); // -// For methods that take other built types, you can pass the builder directly -// to the setter without calling Build(): -// -// DictionaryBuilder().Set("key", std::move(ListBuilder() -// .Append("foo").Append("bar")) /* No .Build() */); -// // The Build() method invalidates its builder, and returns ownership of the // built value. // @@ -52,10 +46,6 @@ class DictionaryBuilder { explicit DictionaryBuilder(const base::DictionaryValue& init); ~DictionaryBuilder(); - // Move constructor and operator=. - DictionaryBuilder(DictionaryBuilder&& other); - DictionaryBuilder& operator=(DictionaryBuilder&& other); - // Can only be called once, after which it's invalid to use the builder. scoped_ptr<base::DictionaryValue> Build() { return std::move(dict_); } @@ -68,8 +58,6 @@ class DictionaryBuilder { DictionaryBuilder& Set(const std::string& path, const std::string& in_value); DictionaryBuilder& Set(const std::string& path, const base::string16& in_value); - DictionaryBuilder& Set(const std::string& path, DictionaryBuilder in_value); - DictionaryBuilder& Set(const std::string& path, ListBuilder in_value); DictionaryBuilder& Set(const std::string& path, scoped_ptr<base::Value> in_value); @@ -87,10 +75,6 @@ class ListBuilder { explicit ListBuilder(const base::ListValue& init); ~ListBuilder(); - // Move constructor and operator=. - ListBuilder(ListBuilder&& other); - ListBuilder& operator=(ListBuilder&& other); - // Can only be called once, after which it's invalid to use the builder. scoped_ptr<base::ListValue> Build() { return std::move(list_); } @@ -98,8 +82,7 @@ class ListBuilder { ListBuilder& Append(double in_value); ListBuilder& Append(const std::string& in_value); ListBuilder& Append(const base::string16& in_value); - ListBuilder& Append(DictionaryBuilder in_value); - ListBuilder& Append(ListBuilder in_value); + ListBuilder& Append(scoped_ptr<base::Value> in_value); // Named differently because overload resolution is too eager to // convert implicitly to bool. diff --git a/extensions/common/value_builder_unittest.cc b/extensions/common/value_builder_unittest.cc index 7c47451..1f1c14e 100644 --- a/extensions/common/value_builder_unittest.cc +++ b/extensions/common/value_builder_unittest.cc @@ -20,9 +20,8 @@ TEST(ValueBuilderTest, Basic) { scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue); ASSERT_FALSE(settings->GetList("permissions", nullptr)); - settings = DictionaryBuilder() - .Set("permissions", std::move(permission_list)) - .Build(); + settings = + DictionaryBuilder().Set("permissions", permission_list.Build()).Build(); base::ListValue* list_value; ASSERT_TRUE(settings->GetList("permissions", &list_value)); diff --git a/extensions/shell/browser/api/identity/identity_api_unittest.cc b/extensions/shell/browser/api/identity/identity_api_unittest.cc index bf9248c..0af6e4b1 100644 --- a/extensions/shell/browser/api/identity/identity_api_unittest.cc +++ b/extensions/shell/browser/api/identity/identity_api_unittest.cc @@ -65,18 +65,21 @@ class IdentityApiTest : public ApiUnitTest { // Create an extension with OAuth2 scopes. set_extension( ExtensionBuilder() - .SetManifest(std::move( + .SetManifest( DictionaryBuilder() .Set("name", "Test") .Set("version", "1.0") .Set("oauth2", - std::move(DictionaryBuilder() - .Set("client_id", - "123456.apps.googleusercontent.com") - .Set("scopes", - std::move(ListBuilder().Append( - "https://www.googleapis.com/" - "auth/drive"))))))) + DictionaryBuilder() + .Set("client_id", + "123456.apps.googleusercontent.com") + .Set("scopes", + ListBuilder() + .Append("https://www.googleapis.com/" + "auth/drive") + .Build()) + .Build()) + .Build()) .SetLocation(Manifest::UNPACKED) .Build()); } diff --git a/extensions/shell/browser/shell_native_app_window_aura_unittest.cc b/extensions/shell/browser/shell_native_app_window_aura_unittest.cc index 728e787..be7df4b 100644 --- a/extensions/shell/browser/shell_native_app_window_aura_unittest.cc +++ b/extensions/shell/browser/shell_native_app_window_aura_unittest.cc @@ -44,10 +44,11 @@ TEST_F(ShellNativeAppWindowAuraTest, Bounds) { new content::TestBrowserContext); scoped_refptr<Extension> extension = ExtensionBuilder() - .SetManifest(std::move(DictionaryBuilder() - .Set("name", "test extension") - .Set("version", "1") - .Set("manifest_version", 2))) + .SetManifest(DictionaryBuilder() + .Set("name", "test extension") + .Set("version", "1") + .Set("manifest_version", 2) + .Build()) .Build(); AppWindow* app_window = new AppWindow( |