Index: ipc/mojo/ipc_channel_mojo.cc |
diff --git a/ipc/mojo/ipc_channel_mojo.cc b/ipc/mojo/ipc_channel_mojo.cc |
index d0356eb518367d342e1fa33e12de9a0d90120197..404c814516e84493b729ca7dfa930764943e3302 100644 |
--- a/ipc/mojo/ipc_channel_mojo.cc |
+++ b/ipc/mojo/ipc_channel_mojo.cc |
@@ -6,8 +6,8 @@ |
#include <stddef.h> |
#include <stdint.h> |
- |
#include <memory> |
+#include <utility> |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
@@ -76,13 +76,17 @@ class ClientChannelMojo : public ChannelMojo, public ClientChannel { |
void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle, |
int32_t peer_pid) override { |
if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { |
- InitMessageReader(mojo::embedder::CreateChannel( |
- handle.Pass(), base::Callback<void(mojo::embedder::ChannelInfo*)>(), |
- scoped_refptr<base::TaskRunner>()), peer_pid); |
+ InitMessageReader( |
+ mojo::embedder::CreateChannel( |
+ std::move(handle), |
+ base::Callback<void(mojo::embedder::ChannelInfo*)>(), |
+ scoped_refptr<base::TaskRunner>()), |
+ peer_pid); |
return; |
} |
- CreateMessagingPipe(handle.Pass(), base::Bind(&ClientChannelMojo::BindPipe, |
- weak_factory_.GetWeakPtr())); |
+ CreateMessagingPipe( |
+ std::move(handle), |
+ base::Bind(&ClientChannelMojo::BindPipe, weak_factory_.GetWeakPtr())); |
} |
// ClientChannel implementation |
@@ -90,13 +94,13 @@ class ClientChannelMojo : public ChannelMojo, public ClientChannel { |
mojo::ScopedMessagePipeHandle pipe, |
int32_t peer_pid, |
const mojo::Callback<void(int32_t)>& callback) override { |
- InitMessageReader(pipe.Pass(), static_cast<base::ProcessId>(peer_pid)); |
+ InitMessageReader(std::move(pipe), static_cast<base::ProcessId>(peer_pid)); |
callback.Run(GetSelfPID()); |
} |
private: |
void BindPipe(mojo::ScopedMessagePipeHandle handle) { |
- binding_.Bind(handle.Pass()); |
+ binding_.Bind(std::move(handle)); |
} |
void OnConnectionError() { |
listener()->OnChannelError(); |
@@ -127,14 +131,15 @@ class ServerChannelMojo : public ChannelMojo { |
int32_t peer_pid) override { |
if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { |
message_pipe_ = mojo::embedder::CreateChannel( |
- handle.Pass(), base::Callback<void(mojo::embedder::ChannelInfo*)>(), |
+ std::move(handle), |
+ base::Callback<void(mojo::embedder::ChannelInfo*)>(), |
scoped_refptr<base::TaskRunner>()); |
if (!message_pipe_.is_valid()) { |
LOG(WARNING) << "mojo::CreateMessagePipe failed: "; |
listener()->OnChannelError(); |
return; |
} |
- InitMessageReader(message_pipe_.Pass(), peer_pid); |
+ InitMessageReader(std::move(message_pipe_), peer_pid); |
return; |
} |
@@ -147,7 +152,7 @@ class ServerChannelMojo : public ChannelMojo { |
return; |
} |
CreateMessagingPipe( |
- handle.Pass(), |
+ std::move(handle), |
base::Bind(&ServerChannelMojo::InitClientChannel, |
weak_factory_.GetWeakPtr(), base::Passed(&peer))); |
} |
@@ -162,11 +167,11 @@ class ServerChannelMojo : public ChannelMojo { |
void InitClientChannel(mojo::ScopedMessagePipeHandle peer_handle, |
mojo::ScopedMessagePipeHandle handle) { |
client_channel_.Bind( |
- mojo::InterfacePtrInfo<ClientChannel>(handle.Pass(), 0u)); |
+ mojo::InterfacePtrInfo<ClientChannel>(std::move(handle), 0u)); |
client_channel_.set_connection_error_handler(base::Bind( |
&ServerChannelMojo::OnConnectionError, base::Unretained(this))); |
client_channel_->Init( |
- peer_handle.Pass(), static_cast<int32_t>(GetSelfPID()), |
+ std::move(peer_handle), static_cast<int32_t>(GetSelfPID()), |
base::Bind(&ServerChannelMojo::ClientChannelWasInitialized, |
base::Unretained(this))); |
} |
@@ -177,7 +182,7 @@ class ServerChannelMojo : public ChannelMojo { |
// ClientChannelClient implementation |
void ClientChannelWasInitialized(int32_t peer_pid) { |
- InitMessageReader(message_pipe_.Pass(), peer_pid); |
+ InitMessageReader(std::move(message_pipe_), peer_pid); |
} |
mojo::InterfacePtr<ClientChannel> client_channel_; |
@@ -300,8 +305,9 @@ void ChannelMojo::CreateMessagingPipe( |
weak_factory_.GetWeakPtr(), callback); |
if (!g_use_channel_on_io_thread_only || |
base::ThreadTaskRunnerHandle::Get() == io_runner_) { |
- CreateMessagingPipeOnIOThread( |
- handle.Pass(), base::ThreadTaskRunnerHandle::Get(), return_callback); |
+ CreateMessagingPipeOnIOThread(std::move(handle), |
+ base::ThreadTaskRunnerHandle::Get(), |
+ return_callback); |
} else { |
io_runner_->PostTask( |
FROM_HERE, |
@@ -318,9 +324,9 @@ void ChannelMojo::CreateMessagingPipeOnIOThread( |
const CreateMessagingPipeOnIOThreadCallback& callback) { |
mojo::embedder::ChannelInfo* channel_info; |
mojo::ScopedMessagePipeHandle pipe = |
- mojo::embedder::CreateChannelOnIOThread(handle.Pass(), &channel_info); |
+ mojo::embedder::CreateChannelOnIOThread(std::move(handle), &channel_info); |
if (base::ThreadTaskRunnerHandle::Get() == callback_runner) { |
- callback.Run(pipe.Pass(), channel_info); |
+ callback.Run(std::move(pipe), channel_info); |
} else { |
callback_runner->PostTask( |
FROM_HERE, base::Bind(callback, base::Passed(&pipe), channel_info)); |
@@ -334,7 +340,7 @@ void ChannelMojo::OnMessagingPipeCreated( |
DCHECK(!channel_info_.get()); |
channel_info_ = scoped_ptr<mojo::embedder::ChannelInfo, ChannelInfoDeleter>( |
channel_info, ChannelInfoDeleter(io_runner_)); |
- callback.Run(handle.Pass()); |
+ callback.Run(std::move(handle)); |
} |
bool ChannelMojo::Connect() { |
@@ -349,7 +355,7 @@ void ChannelMojo::Close() { |
// |message_reader_| has to be cleared inside the lock, |
// but the instance has to be deleted outside. |
base::AutoLock l(lock_); |
- to_be_deleted = message_reader_.Pass(); |
+ to_be_deleted = std::move(message_reader_); |
// We might Close() before we Connect(). |
waiting_connect_ = false; |
} |
@@ -381,7 +387,7 @@ struct ClosingDeleter { |
void ChannelMojo::InitMessageReader(mojo::ScopedMessagePipeHandle pipe, |
int32_t peer_pid) { |
scoped_ptr<internal::MessagePipeReader, ClosingDeleter> reader( |
- new internal::MessagePipeReader(pipe.Pass(), this)); |
+ new internal::MessagePipeReader(std::move(pipe), this)); |
{ |
base::AutoLock l(lock_); |