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

Side by Side Diff: mojo/edk/system/child_broker_host.cc

Issue 1529303004: Convert Pass()→std::move() in mojo/edk/ (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 unified diff | Download patch
« no previous file with comments | « mojo/edk/system/child_broker.cc ('k') | mojo/edk/system/core.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "mojo/edk/system/child_broker_host.h" 5 #include "mojo/edk/system/child_broker_host.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
9 #include "mojo/edk/embedder/embedder_internal.h" 11 #include "mojo/edk/embedder/embedder_internal.h"
10 #include "mojo/edk/embedder/platform_channel_pair.h" 12 #include "mojo/edk/embedder/platform_channel_pair.h"
11 #include "mojo/edk/system/broker_messages.h" 13 #include "mojo/edk/system/broker_messages.h"
12 #include "mojo/edk/system/broker_state.h" 14 #include "mojo/edk/system/broker_state.h"
13 #include "mojo/edk/system/configuration.h" 15 #include "mojo/edk/system/configuration.h"
14 #include "mojo/edk/system/core.h" 16 #include "mojo/edk/system/core.h"
15 #include "mojo/edk/system/platform_handle_dispatcher.h" 17 #include "mojo/edk/system/platform_handle_dispatcher.h"
16 18
17 namespace mojo { 19 namespace mojo {
18 namespace edk { 20 namespace edk {
19 21
20 namespace { 22 namespace {
21 #if defined(OS_WIN) 23 #if defined(OS_WIN)
22 static const int kDefaultReadBufferSize = 256; 24 static const int kDefaultReadBufferSize = 256;
23 #endif 25 #endif
24 } 26 }
25 27
26 ChildBrokerHost::ChildBrokerHost(base::ProcessHandle child_process, 28 ChildBrokerHost::ChildBrokerHost(base::ProcessHandle child_process,
27 ScopedPlatformHandle pipe) 29 ScopedPlatformHandle pipe)
28 : process_id_(base::GetProcId(child_process)), child_channel_(nullptr) { 30 : process_id_(base::GetProcId(child_process)), child_channel_(nullptr) {
29 ScopedPlatformHandle parent_async_channel_handle; 31 ScopedPlatformHandle parent_async_channel_handle;
30 #if defined(OS_POSIX) 32 #if defined(OS_POSIX)
31 parent_async_channel_handle = pipe.Pass(); 33 parent_async_channel_handle = std::move(pipe);
32 #else 34 #else
33 DuplicateHandle(GetCurrentProcess(), child_process, 35 DuplicateHandle(GetCurrentProcess(), child_process,
34 GetCurrentProcess(), &child_process, 36 GetCurrentProcess(), &child_process,
35 0, FALSE, DUPLICATE_SAME_ACCESS); 37 0, FALSE, DUPLICATE_SAME_ACCESS);
36 child_process_ = base::Process(child_process); 38 child_process_ = base::Process(child_process);
37 sync_channel_ = pipe.Pass(); 39 sync_channel_ = pipe.Pass();
38 memset(&read_context_.overlapped, 0, sizeof(read_context_.overlapped)); 40 memset(&read_context_.overlapped, 0, sizeof(read_context_.overlapped));
39 read_context_.handler = this; 41 read_context_.handler = this;
40 memset(&write_context_.overlapped, 0, sizeof(write_context_.overlapped)); 42 memset(&write_context_.overlapped, 0, sizeof(write_context_.overlapped));
41 write_context_.handler = this; 43 write_context_.handler = this;
(...skipping 26 matching lines...) Expand all
68 void ChildBrokerHost::ConnectToProcess(base::ProcessId process_id, 70 void ChildBrokerHost::ConnectToProcess(base::ProcessId process_id,
69 ScopedPlatformHandle pipe) { 71 ScopedPlatformHandle pipe) {
70 if (!child_channel_) 72 if (!child_channel_)
71 return; // Can happen at process shutdown on Windows. 73 return; // Can happen at process shutdown on Windows.
72 ConnectToProcessMessage data; 74 ConnectToProcessMessage data;
73 data.type = CONNECT_TO_PROCESS; 75 data.type = CONNECT_TO_PROCESS;
74 data.process_id = process_id; 76 data.process_id = process_id;
75 scoped_ptr<MessageInTransit> message(new MessageInTransit( 77 scoped_ptr<MessageInTransit> message(new MessageInTransit(
76 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); 78 MessageInTransit::Type::MESSAGE, sizeof(data), &data));
77 scoped_refptr<Dispatcher> dispatcher = 79 scoped_refptr<Dispatcher> dispatcher =
78 PlatformHandleDispatcher::Create(pipe.Pass()); 80 PlatformHandleDispatcher::Create(std::move(pipe));
79 internal::g_core->AddDispatcher(dispatcher); 81 internal::g_core->AddDispatcher(dispatcher);
80 scoped_ptr<DispatcherVector> dispatchers(new DispatcherVector); 82 scoped_ptr<DispatcherVector> dispatchers(new DispatcherVector);
81 dispatchers->push_back(dispatcher); 83 dispatchers->push_back(dispatcher);
82 message->SetDispatchers(dispatchers.Pass()); 84 message->SetDispatchers(std::move(dispatchers));
83 message->SerializeAndCloseDispatchers(); 85 message->SerializeAndCloseDispatchers();
84 message->set_route_id(kBrokerRouteId); 86 message->set_route_id(kBrokerRouteId);
85 child_channel_->channel()->WriteMessage(message.Pass()); 87 child_channel_->channel()->WriteMessage(std::move(message));
86 } 88 }
87 89
88 void ChildBrokerHost::ConnectMessagePipe(uint64_t pipe_id, 90 void ChildBrokerHost::ConnectMessagePipe(uint64_t pipe_id,
89 base::ProcessId process_id) { 91 base::ProcessId process_id) {
90 if (!child_channel_) 92 if (!child_channel_)
91 return; // Can happen at process shutdown on Windows. 93 return; // Can happen at process shutdown on Windows.
92 PeerPipeConnectedMessage data; 94 PeerPipeConnectedMessage data;
93 data.type = PEER_PIPE_CONNECTED; 95 data.type = PEER_PIPE_CONNECTED;
94 data.pipe_id = pipe_id; 96 data.pipe_id = pipe_id;
95 data.process_id = process_id; 97 data.process_id = process_id;
96 scoped_ptr<MessageInTransit> message(new MessageInTransit( 98 scoped_ptr<MessageInTransit> message(new MessageInTransit(
97 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); 99 MessageInTransit::Type::MESSAGE, sizeof(data), &data));
98 message->set_route_id(kBrokerRouteId); 100 message->set_route_id(kBrokerRouteId);
99 child_channel_->channel()->WriteMessage(message.Pass()); 101 child_channel_->channel()->WriteMessage(std::move(message));
100 } 102 }
101 103
102 ChildBrokerHost::~ChildBrokerHost() { 104 ChildBrokerHost::~ChildBrokerHost() {
103 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread()); 105 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread());
104 BrokerState::GetInstance()->ChildBrokerHostDestructed(this); 106 BrokerState::GetInstance()->ChildBrokerHostDestructed(this);
105 if (child_channel_) 107 if (child_channel_)
106 child_channel_->RemoveRoute(kBrokerRouteId); 108 child_channel_->RemoveRoute(kBrokerRouteId);
107 } 109 }
108 110
109 void ChildBrokerHost::InitOnIO( 111 void ChildBrokerHost::InitOnIO(
110 ScopedPlatformHandle parent_async_channel_handle) { 112 ScopedPlatformHandle parent_async_channel_handle) {
111 child_channel_ = new RoutedRawChannel( 113 child_channel_ = new RoutedRawChannel(
112 parent_async_channel_handle.Pass(), 114 std::move(parent_async_channel_handle),
113 base::Bind(&ChildBrokerHost::ChannelDestructed, base::Unretained(this))); 115 base::Bind(&ChildBrokerHost::ChannelDestructed, base::Unretained(this)));
114 child_channel_->AddRoute(kBrokerRouteId, this); 116 child_channel_->AddRoute(kBrokerRouteId, this);
115 117
116 BrokerState::GetInstance()->ChildBrokerHostCreated(this); 118 BrokerState::GetInstance()->ChildBrokerHostCreated(this);
117 119
118 #if defined(OS_WIN) 120 #if defined(OS_WIN)
119 // Call this after RoutedRawChannel calls its RawChannel::Init because this 121 // Call this after RoutedRawChannel calls its RawChannel::Init because this
120 // call could cause us to get notified that the child has gone away and to 122 // call could cause us to get notified that the child has gone away and to
121 // delete this class and shut down child_channel_ before Init() has run. 123 // delete this class and shut down child_channel_ before Init() has run.
122 base::MessageLoopForIO::current()->RegisterIOHandler( 124 base::MessageLoopForIO::current()->RegisterIOHandler(
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 BOOL result = DuplicateHandle(child_process_.Handle(), handle, 303 BOOL result = DuplicateHandle(child_process_.Handle(), handle,
302 base::GetCurrentProcessHandle(), &rv, 0, FALSE, 304 base::GetCurrentProcessHandle(), &rv, 0, FALSE,
303 DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); 305 DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
304 DCHECK(result); 306 DCHECK(result);
305 return rv; 307 return rv;
306 } 308 }
307 #endif 309 #endif
308 310
309 } // namespace edk 311 } // namespace edk
310 } // namespace mojo 312 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/child_broker.cc ('k') | mojo/edk/system/core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698