Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Unified Diff: ipc/mojo/ipc_channel_mojo.cc

Issue 1550693002: Global conversion of Pass()→std::move() on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_test_base.cc ('k') | ipc/mojo/ipc_channel_mojo_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_);
« no previous file with comments | « ipc/ipc_test_base.cc ('k') | ipc/mojo/ipc_channel_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698