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

Side by Side Diff: content/common/mojo/channel_init.cc

Issue 1544293002: Convert Pass()→std::move() in //content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/mojo/channel_init.h" 5 #include "content/common/mojo/channel_init.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
9 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
10 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
11 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
12 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" 14 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
13 15
14 namespace content { 16 namespace content {
15 17
16 ChannelInit::ChannelInit() : channel_info_(nullptr), weak_factory_(this) {} 18 ChannelInit::ChannelInit() : channel_info_(nullptr), weak_factory_(this) {}
17 19
18 ChannelInit::~ChannelInit() { 20 ChannelInit::~ChannelInit() {
19 if (channel_info_) 21 if (channel_info_)
20 mojo::embedder::DestroyChannel(channel_info_, 22 mojo::embedder::DestroyChannel(channel_info_,
21 base::Bind(&base::DoNothing), nullptr); 23 base::Bind(&base::DoNothing), nullptr);
22 } 24 }
23 25
24 mojo::ScopedMessagePipeHandle ChannelInit::Init( 26 mojo::ScopedMessagePipeHandle ChannelInit::Init(
25 base::PlatformFile file, 27 base::PlatformFile file,
26 scoped_refptr<base::TaskRunner> io_thread_task_runner) { 28 scoped_refptr<base::TaskRunner> io_thread_task_runner) {
27 scoped_ptr<IPC::ScopedIPCSupport> ipc_support( 29 scoped_ptr<IPC::ScopedIPCSupport> ipc_support(
28 new IPC::ScopedIPCSupport(io_thread_task_runner)); 30 new IPC::ScopedIPCSupport(io_thread_task_runner));
29 mojo::ScopedMessagePipeHandle message_pipe = 31 mojo::ScopedMessagePipeHandle message_pipe = mojo::embedder::CreateChannel(
30 mojo::embedder::CreateChannel( 32 mojo::embedder::ScopedPlatformHandle(
31 mojo::embedder::ScopedPlatformHandle( 33 mojo::embedder::PlatformHandle(file)),
32 mojo::embedder::PlatformHandle(file)), 34 base::Bind(&ChannelInit::OnCreatedChannel, weak_factory_.GetWeakPtr(),
33 base::Bind(&ChannelInit::OnCreatedChannel, 35 base::Passed(&ipc_support)),
34 weak_factory_.GetWeakPtr(), 36 base::ThreadTaskRunnerHandle::Get());
35 base::Passed(&ipc_support)), 37 return message_pipe;
36 base::ThreadTaskRunnerHandle::Get()).Pass();
37 return message_pipe.Pass();
38 } 38 }
39 39
40 void ChannelInit::WillDestroySoon() { 40 void ChannelInit::WillDestroySoon() {
41 if (channel_info_) 41 if (channel_info_)
42 mojo::embedder::WillDestroyChannelSoon(channel_info_); 42 mojo::embedder::WillDestroyChannelSoon(channel_info_);
43 } 43 }
44 44
45 // static 45 // static
46 void ChannelInit::OnCreatedChannel( 46 void ChannelInit::OnCreatedChannel(
47 base::WeakPtr<ChannelInit> self, 47 base::WeakPtr<ChannelInit> self,
48 scoped_ptr<IPC::ScopedIPCSupport> ipc_support, 48 scoped_ptr<IPC::ScopedIPCSupport> ipc_support,
49 mojo::embedder::ChannelInfo* channel) { 49 mojo::embedder::ChannelInfo* channel) {
50 // If |self| was already destroyed, shut the channel down. 50 // If |self| was already destroyed, shut the channel down.
51 if (!self) { 51 if (!self) {
52 mojo::embedder::DestroyChannel(channel, 52 mojo::embedder::DestroyChannel(channel,
53 base::Bind(&base::DoNothing), nullptr); 53 base::Bind(&base::DoNothing), nullptr);
54 return; 54 return;
55 } 55 }
56 56
57 DCHECK(!self->channel_info_); 57 DCHECK(!self->channel_info_);
58 self->channel_info_ = channel; 58 self->channel_info_ = channel;
59 self->ipc_support_ = ipc_support.Pass(); 59 self->ipc_support_ = std::move(ipc_support);
60 } 60 }
61 61
62 } // namespace content 62 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/web_input_event_traits.cc ('k') | content/common/mojo/mojo_shell_connection_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698