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

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

Issue 1675603002: [mojo-edk] Simplify multiprocess pipe bootstrap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/core.h" 5 #include "mojo/edk/system/core.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (base::ThreadTaskRunnerHandle::IsSet()) { 153 if (base::ThreadTaskRunnerHandle::IsSet()) {
154 on_shutdown = base::Bind(base::IgnoreResult(&base::TaskRunner::PostTask), 154 on_shutdown = base::Bind(base::IgnoreResult(&base::TaskRunner::PostTask),
155 base::ThreadTaskRunnerHandle::Get(), 155 base::ThreadTaskRunnerHandle::Get(),
156 FROM_HERE, callback); 156 FROM_HERE, callback);
157 } else { 157 } else {
158 on_shutdown = callback; 158 on_shutdown = callback;
159 } 159 }
160 GetNodeController()->RequestShutdown(on_shutdown); 160 GetNodeController()->RequestShutdown(on_shutdown);
161 } 161 }
162 162
163 void Core::CreateMessagePipe( 163 ScopedMessagePipeHandle Core::CreateMessagePipe(
164 ScopedPlatformHandle platform_handle, 164 ScopedPlatformHandle platform_handle) {
165 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { 165 ports::PortRef port0, port1;
166 ports::PortRef port; 166 GetNodeController()->node()->CreatePortPair(&port0, &port1);
167 GetNodeController()->node()->CreateUninitializedPort(&port); 167 MojoHandle handle = AddDispatcher(
168 new MessagePipeDispatcher(GetNodeController(), port0,
169 0x7f7f7f7f7f7f7f7fUL, 0));
168 RemoteMessagePipeBootstrap::Create( 170 RemoteMessagePipeBootstrap::Create(
169 GetNodeController(), std::move(platform_handle), port, 171 GetNodeController(), std::move(platform_handle), port1);
170 base::Bind(&OnPortConnected, base::Unretained(this), 0, callback, port)); 172 return ScopedMessagePipeHandle(MessagePipeHandle(handle));
171 } 173 }
172 174
173 void Core::CreateParentMessagePipe( 175 void Core::CreateParentMessagePipe(
174 const std::string& token, 176 const std::string& token,
175 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { 177 const base::Callback<void(ScopedMessagePipeHandle)>& callback) {
176 GetNodeController()->ReservePort( 178 GetNodeController()->ReservePort(
177 token, 179 token,
178 base::Bind(&OnPortConnected, base::Unretained(this), 0, callback)); 180 base::Bind(&OnPortConnected, base::Unretained(this), 0, callback));
179 } 181 }
180 182
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 scoped_ptr<NodeController> node_controller) { 706 scoped_ptr<NodeController> node_controller) {
705 // It's OK to leak this reference. At this point we know the IO loop is still 707 // It's OK to leak this reference. At this point we know the IO loop is still
706 // running, and we know the NodeController will observe its eventual 708 // running, and we know the NodeController will observe its eventual
707 // destruction. This tells the NodeController to delete itself when that 709 // destruction. This tells the NodeController to delete itself when that
708 // happens. 710 // happens.
709 node_controller.release()->DestroyOnIOThreadShutdown(); 711 node_controller.release()->DestroyOnIOThreadShutdown();
710 } 712 }
711 713
712 } // namespace edk 714 } // namespace edk
713 } // namespace mojo 715 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698