OLD | NEW |
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 Loading... |
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 |
77 void OnGotApplicationRequest(InterfaceRequest<mojom::ShellClient>* out_request, | 84 void OnGotApplicationRequest(InterfaceRequest<mojom::ShellClient>* out_request, |
78 InterfaceRequest<mojom::ShellClient> request) { | 85 InterfaceRequest<mojom::ShellClient> request) { |
79 *out_request = std::move(request); | 86 *out_request = std::move(request); |
80 } | 87 } |
81 | 88 |
82 class ChildControllerImpl; | 89 class ChildControllerImpl; |
83 | 90 |
84 class RunnerConnectionImpl : public RunnerConnection { | 91 class RunnerConnectionImpl : public RunnerConnection { |
85 public: | 92 public: |
86 RunnerConnectionImpl() : controller_thread_("controller_thread") { | 93 RunnerConnectionImpl() : controller_thread_("controller_thread") { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 if (!handle.is_valid()) { | 222 if (!handle.is_valid()) { |
216 edk::ScopedPlatformHandle platform_channel = | 223 edk::ScopedPlatformHandle platform_channel = |
217 edk::PlatformChannelPair::PassClientHandleFromParentProcess( | 224 edk::PlatformChannelPair::PassClientHandleFromParentProcess( |
218 *base::CommandLine::ForCurrentProcess()); | 225 *base::CommandLine::ForCurrentProcess()); |
219 if (!platform_channel.is_valid()) | 226 if (!platform_channel.is_valid()) |
220 return false; | 227 return false; |
221 edk::SetParentPipeHandle(std::move(platform_channel)); | 228 edk::SetParentPipeHandle(std::move(platform_channel)); |
222 std::string primordial_pipe_token = | 229 std::string primordial_pipe_token = |
223 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 230 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
224 switches::kPrimordialPipeToken); | 231 switches::kPrimordialPipeToken); |
225 handle = edk::CreateChildMessagePipe(primordial_pipe_token); | 232 Blocker blocker; |
| 233 edk::CreateChildMessagePipe( |
| 234 primordial_pipe_token, |
| 235 base::Bind(&OnCreateMessagePipe, base::Unretained(&handle), |
| 236 blocker.GetUnblocker())); |
| 237 blocker.Block(); |
226 } | 238 } |
227 | 239 |
228 DCHECK(handle.is_valid()); | |
229 | |
230 Blocker blocker; | 240 Blocker blocker; |
231 controller_runner_->PostTask( | 241 controller_runner_->PostTask( |
232 FROM_HERE, | 242 FROM_HERE, |
233 base::Bind( | 243 base::Bind( |
234 &ChildControllerImpl::Create, base::Unretained(this), | 244 &ChildControllerImpl::Create, base::Unretained(this), |
235 base::Bind(&OnGotApplicationRequest, base::Unretained(request)), | 245 base::Bind(&OnGotApplicationRequest, base::Unretained(request)), |
236 base::Passed(&handle), blocker.GetUnblocker())); | 246 base::Passed(&handle), blocker.GetUnblocker())); |
237 blocker.Block(); | 247 blocker.Block(); |
238 | 248 |
239 return true; | 249 return true; |
(...skipping 12 matching lines...) Expand all Loading... |
252 delete connection; | 262 delete connection; |
253 return nullptr; | 263 return nullptr; |
254 } | 264 } |
255 return connection; | 265 return connection; |
256 } | 266 } |
257 | 267 |
258 RunnerConnection::RunnerConnection() {} | 268 RunnerConnection::RunnerConnection() {} |
259 | 269 |
260 } // namespace shell | 270 } // namespace shell |
261 } // namespace mojo | 271 } // namespace mojo |
OLD | NEW |