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

Side by Side Diff: mojo/shell/runner/child/runner_connection.cc

Issue 1675603002: [mojo-edk] Simplify multiprocess pipe bootstrap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix some callers to work with sync APIs 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 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/shell/runner/child/runner_connection.h" 5 #include "mojo/shell/runner/child/runner_connection.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 private: 67 private:
68 base::WaitableEvent event_; 68 base::WaitableEvent event_;
69 base::Closure run_after_; 69 base::Closure run_after_;
70 70
71 DISALLOW_COPY_AND_ASSIGN(Blocker); 71 DISALLOW_COPY_AND_ASSIGN(Blocker);
72 }; 72 };
73 73
74 using GotApplicationRequestCallback = 74 using GotApplicationRequestCallback =
75 base::Callback<void(InterfaceRequest<mojom::ShellClient>)>; 75 base::Callback<void(InterfaceRequest<mojom::ShellClient>)>;
76 76
77 void OnCreateMessagePipe(ScopedMessagePipeHandle* result,
78 Blocker::Unblocker unblocker,
79 ScopedMessagePipeHandle pipe) {
80 *result = std::move(pipe);
81 unblocker.Unblock(base::Bind(&base::DoNothing));
82 }
83
84 void OnGotApplicationRequest(InterfaceRequest<mojom::ShellClient>* out_request, 77 void OnGotApplicationRequest(InterfaceRequest<mojom::ShellClient>* out_request,
85 InterfaceRequest<mojom::ShellClient> request) { 78 InterfaceRequest<mojom::ShellClient> request) {
86 *out_request = std::move(request); 79 *out_request = std::move(request);
87 } 80 }
88 81
89 class ChildControllerImpl; 82 class ChildControllerImpl;
90 83
91 class RunnerConnectionImpl : public RunnerConnection { 84 class RunnerConnectionImpl : public RunnerConnection {
92 public: 85 public:
93 RunnerConnectionImpl() : controller_thread_("controller_thread") { 86 RunnerConnectionImpl() : controller_thread_("controller_thread") {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (!handle.is_valid()) { 215 if (!handle.is_valid()) {
223 edk::ScopedPlatformHandle platform_channel = 216 edk::ScopedPlatformHandle platform_channel =
224 edk::PlatformChannelPair::PassClientHandleFromParentProcess( 217 edk::PlatformChannelPair::PassClientHandleFromParentProcess(
225 *base::CommandLine::ForCurrentProcess()); 218 *base::CommandLine::ForCurrentProcess());
226 if (!platform_channel.is_valid()) 219 if (!platform_channel.is_valid())
227 return false; 220 return false;
228 edk::SetParentPipeHandle(std::move(platform_channel)); 221 edk::SetParentPipeHandle(std::move(platform_channel));
229 std::string primordial_pipe_token = 222 std::string primordial_pipe_token =
230 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 223 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
231 switches::kPrimordialPipeToken); 224 switches::kPrimordialPipeToken);
232 Blocker blocker; 225 handle = edk::CreateChildMessagePipe(primordial_pipe_token);
233 edk::CreateChildMessagePipe(
234 primordial_pipe_token,
235 base::Bind(&OnCreateMessagePipe, base::Unretained(&handle),
236 blocker.GetUnblocker()));
237 blocker.Block();
238 } 226 }
239 227
228 DCHECK(handle.is_valid());
229
240 Blocker blocker; 230 Blocker blocker;
241 controller_runner_->PostTask( 231 controller_runner_->PostTask(
242 FROM_HERE, 232 FROM_HERE,
243 base::Bind( 233 base::Bind(
244 &ChildControllerImpl::Create, base::Unretained(this), 234 &ChildControllerImpl::Create, base::Unretained(this),
245 base::Bind(&OnGotApplicationRequest, base::Unretained(request)), 235 base::Bind(&OnGotApplicationRequest, base::Unretained(request)),
246 base::Passed(&handle), blocker.GetUnblocker())); 236 base::Passed(&handle), blocker.GetUnblocker()));
247 blocker.Block(); 237 blocker.Block();
248 238
249 return true; 239 return true;
(...skipping 12 matching lines...) Expand all
262 delete connection; 252 delete connection;
263 return nullptr; 253 return nullptr;
264 } 254 }
265 return connection; 255 return connection;
266 } 256 }
267 257
268 RunnerConnection::RunnerConnection() {} 258 RunnerConnection::RunnerConnection() {}
269 259
270 } // namespace shell 260 } // namespace shell
271 } // namespace mojo 261 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/remote_message_pipe_bootstrap.cc ('k') | mojo/shell/runner/host/child_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698