diff options
author | dcheng <dcheng@chromium.org> | 2015-12-18 09:48:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-18 17:48:52 +0000 |
commit | e59eca16010c109a5e3e4922189c8b264d34caa9 (patch) | |
tree | 838815399c6364a99a465938df9978aeaf75c766 /extensions/browser/mojo | |
parent | 5100baf1eac806abbdaaf8002887aacf652f34e5 (diff) | |
download | chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.zip chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.tar.gz chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.tar.bz2 |
Convert Pass()→std::move() in //extensions
BUG=557422
Review URL: https://codereview.chromium.org/1537893002
Cr-Commit-Position: refs/heads/master@{#366120}
Diffstat (limited to 'extensions/browser/mojo')
-rw-r--r-- | extensions/browser/mojo/keep_alive_impl.cc | 6 | ||||
-rw-r--r-- | extensions/browser/mojo/keep_alive_impl_unittest.cc | 3 | ||||
-rw-r--r-- | extensions/browser/mojo/stash_backend.cc | 16 | ||||
-rw-r--r-- | extensions/browser/mojo/stash_backend_unittest.cc | 59 |
4 files changed, 45 insertions, 39 deletions
diff --git a/extensions/browser/mojo/keep_alive_impl.cc b/extensions/browser/mojo/keep_alive_impl.cc index adfccaa..8f17582 100644 --- a/extensions/browser/mojo/keep_alive_impl.cc +++ b/extensions/browser/mojo/keep_alive_impl.cc @@ -4,6 +4,8 @@ #include "extensions/browser/mojo/keep_alive_impl.h" +#include <utility> + #include "base/bind.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/process_manager.h" @@ -14,7 +16,7 @@ namespace extensions { void KeepAliveImpl::Create(content::BrowserContext* context, const Extension* extension, mojo::InterfaceRequest<KeepAlive> request) { - new KeepAliveImpl(context, extension, request.Pass()); + new KeepAliveImpl(context, extension, std::move(request)); } KeepAliveImpl::KeepAliveImpl(content::BrowserContext* context, @@ -23,7 +25,7 @@ KeepAliveImpl::KeepAliveImpl(content::BrowserContext* context, : context_(context), extension_(extension), extension_registry_observer_(this), - binding_(this, request.Pass()) { + binding_(this, std::move(request)) { ProcessManager::Get(context_)->IncrementLazyKeepaliveCount(extension_); binding_.set_connection_error_handler( base::Bind(&KeepAliveImpl::OnDisconnected, base::Unretained(this))); diff --git a/extensions/browser/mojo/keep_alive_impl_unittest.cc b/extensions/browser/mojo/keep_alive_impl_unittest.cc index 72e61b36..92bd9dd 100644 --- a/extensions/browser/mojo/keep_alive_impl_unittest.cc +++ b/extensions/browser/mojo/keep_alive_impl_unittest.cc @@ -54,7 +54,8 @@ class KeepAliveTest : public ExtensionsTest { } void CreateKeepAlive(mojo::InterfaceRequest<KeepAlive> request) { - KeepAliveImpl::Create(browser_context(), extension_.get(), request.Pass()); + KeepAliveImpl::Create(browser_context(), extension_.get(), + std::move(request)); } const Extension* extension() { return extension_.get(); } diff --git a/extensions/browser/mojo/stash_backend.cc b/extensions/browser/mojo/stash_backend.cc index 381142d..8d5f480 100644 --- a/extensions/browser/mojo/stash_backend.cc +++ b/extensions/browser/mojo/stash_backend.cc @@ -4,6 +4,7 @@ #include "extensions/browser/mojo/stash_backend.h" +#include <utility> #include <vector> #include "base/bind.h" @@ -35,8 +36,7 @@ class StashServiceImpl : public StashService { StashServiceImpl::StashServiceImpl(mojo::InterfaceRequest<StashService> request, base::WeakPtr<StashBackend> backend) - : binding_(this, request.Pass()), backend_(backend) { -} + : binding_(this, std::move(request)), backend_(backend) {} StashServiceImpl::~StashServiceImpl() { } @@ -45,7 +45,7 @@ void StashServiceImpl::AddToStash( mojo::Array<StashedObjectPtr> stashed_objects) { if (!backend_) return; - backend_->AddToStash(stashed_objects.Pass()); + backend_->AddToStash(std::move(stashed_objects)); } void StashServiceImpl::RetrieveStash( @@ -102,7 +102,7 @@ StashBackend::~StashBackend() { void StashBackend::AddToStash(mojo::Array<StashedObjectPtr> stashed_objects) { for (size_t i = 0; i < stashed_objects.size(); i++) { stashed_objects_.push_back(make_scoped_ptr(new StashEntry( - stashed_objects[i].Pass(), + std::move(stashed_objects[i]), has_notified_ ? base::Closure() : base::Bind(&StashBackend::OnHandleReady, weak_factory_.GetWeakPtr())))); @@ -116,11 +116,11 @@ mojo::Array<StashedObjectPtr> StashBackend::RetrieveStash() { result.push_back(entry->Release()); } stashed_objects_.clear(); - return result.Pass(); + return result; } void StashBackend::BindToRequest(mojo::InterfaceRequest<StashService> request) { - new StashServiceImpl(request.Pass(), weak_factory_.GetWeakPtr()); + new StashServiceImpl(std::move(request), weak_factory_.GetWeakPtr()); } void StashBackend::OnHandleReady() { @@ -135,7 +135,7 @@ void StashBackend::OnHandleReady() { StashBackend::StashEntry::StashEntry(StashedObjectPtr stashed_object, const base::Closure& on_handle_readable) - : stashed_object_(stashed_object.Pass()), + : stashed_object_(std::move(stashed_object)), on_handle_readable_(on_handle_readable) { if (on_handle_readable_.is_null() || !stashed_object_->monitor_handles) return; @@ -153,7 +153,7 @@ StashBackend::StashEntry::~StashEntry() { StashedObjectPtr StashBackend::StashEntry::Release() { waiters_.clear(); - return stashed_object_.Pass(); + return std::move(stashed_object_); } void StashBackend::StashEntry::CancelHandleNotifications() { diff --git a/extensions/browser/mojo/stash_backend_unittest.cc b/extensions/browser/mojo/stash_backend_unittest.cc index be76bac..c054cc5 100644 --- a/extensions/browser/mojo/stash_backend_unittest.cc +++ b/extensions/browser/mojo/stash_backend_unittest.cc @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "extensions/browser/mojo/stash_backend.h" + +#include <utility> + #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" -#include "extensions/browser/mojo/stash_backend.h" #include "mojo/application/public/interfaces/service_provider.mojom.h" #include "testing/gtest/include/gtest/gtest.h" @@ -28,7 +31,7 @@ mojo::ScopedHandle CreateReadableHandle() { MOJO_WRITE_DATA_FLAG_NONE); EXPECT_EQ(MOJO_RESULT_OK, result); EXPECT_EQ(1u, num_bytes); - return mojo::ScopedHandle::From(consumer_handle.Pass()); + return mojo::ScopedHandle::From(std::move(consumer_handle)); } } // namespace @@ -60,12 +63,12 @@ class StashServiceTest : public testing::Test { stash_service_->RetrieveStash(base::Bind( &StashServiceTest::StashRetrieved, base::Unretained(this), &stash)); WaitForEvent(EVENT_STASH_RETRIEVED); - return stash.Pass(); + return stash; } void StashRetrieved(mojo::Array<StashedObjectPtr>* output, mojo::Array<StashedObjectPtr> stash) { - *output = stash.Pass(); + *output = std::move(stash); EventReceived(EVENT_STASH_RETRIEVED); } @@ -107,15 +110,15 @@ TEST_F(StashServiceTest, AddTwiceAndRetrieve) { stashed_object->id = "test type"; stashed_object->data.push_back(1); stashed_object->stashed_handles = mojo::Array<mojo::ScopedHandle>(0); - stashed_objects.push_back(stashed_object.Pass()); - stash_service_->AddToStash(stashed_objects.Pass()); + stashed_objects.push_back(std::move(stashed_object)); + stash_service_->AddToStash(std::move(stashed_objects)); stashed_object = StashedObject::New(); stashed_object->id = "test type2"; stashed_object->data.push_back(2); stashed_object->data.push_back(3); stashed_object->stashed_handles = mojo::Array<mojo::ScopedHandle>(0); - stashed_objects.push_back(stashed_object.Pass()); - stash_service_->AddToStash(stashed_objects.Pass()); + stashed_objects.push_back(std::move(stashed_object)); + stash_service_->AddToStash(std::move(stashed_objects)); stashed_objects = RetrieveStash(); ASSERT_EQ(2u, stashed_objects.size()); EXPECT_EQ("test type", stashed_objects[0]->id); @@ -149,18 +152,18 @@ TEST_F(StashServiceTest, StashAndRetrieveHandles) { ASSERT_EQ(1u, num_bytes); stashed_object->stashed_handles.push_back( - mojo::ScopedHandle::From(producer.Pass())); + mojo::ScopedHandle::From(std::move(producer))); stashed_object->stashed_handles.push_back( - mojo::ScopedHandle::From(consumer.Pass())); - stashed_objects.push_back(stashed_object.Pass()); - stash_service_->AddToStash(stashed_objects.Pass()); + mojo::ScopedHandle::From(std::move(consumer))); + stashed_objects.push_back(std::move(stashed_object)); + stash_service_->AddToStash(std::move(stashed_objects)); stashed_objects = RetrieveStash(); ASSERT_EQ(1u, stashed_objects.size()); EXPECT_EQ("test type", stashed_objects[0]->id); ASSERT_EQ(2u, stashed_objects[0]->stashed_handles.size()); consumer = mojo::ScopedDataPipeConsumerHandle::From( - stashed_objects[0]->stashed_handles[1].Pass()); + std::move(stashed_objects[0]->stashed_handles[1])); result = mojo::Wait( consumer.get(), MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE, nullptr); @@ -192,11 +195,11 @@ TEST_F(StashServiceTest, NotifyOnReadableHandle) { stashed_object->stashed_handles.push_back(mojo::ScopedHandle::From( mojo::GetProxy(&service_provider).PassMessagePipe())); - stash_entries.push_back(stashed_object.Pass()); - stash_service_->AddToStash(stash_entries.Pass()); + stash_entries.push_back(std::move(stashed_object)); + stash_service_->AddToStash(std::move(stash_entries)); mojo::MessagePipe pipe; - service_provider->ConnectToService("", pipe.handle0.Pass()); + service_provider->ConnectToService("", std::move(pipe.handle0)); WaitForEvent(EVENT_HANDLE_READY); EXPECT_EQ(1, handles_ready_); @@ -222,13 +225,13 @@ TEST_F(StashServiceTest, NotifyOnReadableDataPipeHandle) { ASSERT_EQ(MOJO_RESULT_OK, result); ASSERT_EQ(1u, num_bytes); stashed_object->stashed_handles.push_back( - mojo::ScopedHandle::From(producer_handle.Pass())); + mojo::ScopedHandle::From(std::move(producer_handle))); stashed_object->stashed_handles.push_back( - mojo::ScopedHandle::From(consumer_handle.Pass())); + mojo::ScopedHandle::From(std::move(consumer_handle))); stashed_object->data.push_back(1); - stash_entries.push_back(stashed_object.Pass()); - stash_service_->AddToStash(stash_entries.Pass()); + stash_entries.push_back(std::move(stashed_object)); + stash_service_->AddToStash(std::move(stash_entries)); WaitForEvent(EVENT_HANDLE_READY); EXPECT_EQ(1, handles_ready_); } @@ -241,15 +244,15 @@ TEST_F(StashServiceTest, NotifyOncePerStashOnReadableHandles) { stashed_object->monitor_handles = true; stashed_object->stashed_handles.push_back(CreateReadableHandle()); stashed_object->stashed_handles.push_back(CreateReadableHandle()); - stash_entries.push_back(stashed_object.Pass()); + stash_entries.push_back(std::move(stashed_object)); stashed_object = StashedObject::New(); stashed_object->id = "another test type"; stashed_object->data.push_back(2); stashed_object->monitor_handles = true; stashed_object->stashed_handles.push_back(CreateReadableHandle()); stashed_object->stashed_handles.push_back(CreateReadableHandle()); - stash_entries.push_back(stashed_object.Pass()); - stash_service_->AddToStash(stash_entries.Pass()); + stash_entries.push_back(std::move(stashed_object)); + stash_service_->AddToStash(std::move(stash_entries)); WaitForEvent(EVENT_HANDLE_READY); EXPECT_EQ(1, handles_ready_); @@ -259,8 +262,8 @@ TEST_F(StashServiceTest, NotifyOncePerStashOnReadableHandles) { stashed_object->monitor_handles = true; stashed_object->stashed_handles.push_back(CreateReadableHandle()); stashed_object->stashed_handles.push_back(CreateReadableHandle()); - stash_entries.push_back(stashed_object.Pass()); - stash_service_->AddToStash(stash_entries.Pass()); + stash_entries.push_back(std::move(stashed_object)); + stash_service_->AddToStash(std::move(stash_entries)); stash_service_->AddToStash(RetrieveStash()); WaitForEvent(EVENT_HANDLE_READY); @@ -279,9 +282,9 @@ TEST_F(StashServiceTest, ServiceWithDeletedBackend) { stashed_object->data.push_back(1); mojo::MessagePipe message_pipe; stashed_object->stashed_handles.push_back( - mojo::ScopedHandle::From(message_pipe.handle0.Pass())); - stashed_objects.push_back(stashed_object.Pass()); - stash_service_->AddToStash(stashed_objects.Pass()); + mojo::ScopedHandle::From(std::move(message_pipe.handle0))); + stashed_objects.push_back(std::move(stashed_object)); + stash_service_->AddToStash(std::move(stashed_objects)); stashed_objects = RetrieveStash(); ASSERT_EQ(0u, stashed_objects.size()); // Check that the stashed handle has been closed. |