OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "shell/app_child_process.h" | 5 #include "shell/child_main.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
17 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
18 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
19 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
21 #include "base/threading/thread_checker.h" | 22 #include "base/threading/thread_checker.h" |
22 #include "mojo/common/message_pump_mojo.h" | 23 #include "mojo/common/message_pump_mojo.h" |
23 #include "mojo/edk/embedder/embedder.h" | 24 #include "mojo/edk/embedder/embedder.h" |
| 25 #include "mojo/edk/embedder/platform_channel_pair.h" |
24 #include "mojo/edk/embedder/process_delegate.h" | 26 #include "mojo/edk/embedder/process_delegate.h" |
| 27 #include "mojo/edk/embedder/scoped_platform_handle.h" |
25 #include "mojo/edk/embedder/simple_platform_support.h" | 28 #include "mojo/edk/embedder/simple_platform_support.h" |
26 #include "mojo/public/cpp/system/core.h" | 29 #include "mojo/public/cpp/system/core.h" |
27 #include "shell/child_controller.mojom.h" | 30 #include "shell/child_controller.mojom.h" |
28 #include "shell/native_application_support.h" | 31 #include "shell/native_application_support.h" |
29 | 32 |
30 namespace mojo { | 33 namespace mojo { |
31 namespace shell { | 34 namespace shell { |
32 | 35 |
33 namespace { | 36 namespace { |
34 | 37 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 StartAppCallback on_app_complete_; | 269 StartAppCallback on_app_complete_; |
267 | 270 |
268 embedder::ChannelInfo* channel_info_; | 271 embedder::ChannelInfo* channel_info_; |
269 Binding<ChildController> binding_; | 272 Binding<ChildController> binding_; |
270 | 273 |
271 DISALLOW_COPY_AND_ASSIGN(ChildControllerImpl); | 274 DISALLOW_COPY_AND_ASSIGN(ChildControllerImpl); |
272 }; | 275 }; |
273 | 276 |
274 } // namespace | 277 } // namespace |
275 | 278 |
276 // AppChildProcess ------------------------------------------------------------- | 279 // ChildMain ------------------------------------------------------------------- |
277 | 280 |
278 AppChildProcess::AppChildProcess() { | 281 int ChildMain() { |
279 } | 282 DVLOG(2) << "ChildMain()"; |
280 | |
281 AppChildProcess::~AppChildProcess() { | |
282 } | |
283 | |
284 void AppChildProcess::Main() { | |
285 DVLOG(2) << "AppChildProcess::Main()"; | |
286 | 283 |
287 DCHECK(!base::MessageLoop::current()); | 284 DCHECK(!base::MessageLoop::current()); |
288 | 285 |
| 286 embedder::ScopedPlatformHandle platform_channel = |
| 287 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( |
| 288 *base::CommandLine::ForCurrentProcess()); |
| 289 CHECK(platform_channel.is_valid()); |
| 290 |
289 AppContext app_context; | 291 AppContext app_context; |
290 app_context.Init(); | 292 app_context.Init(); |
291 | 293 |
292 Blocker blocker; | 294 Blocker blocker; |
293 app_context.controller_runner()->PostTask( | 295 app_context.controller_runner()->PostTask( |
294 FROM_HERE, | 296 FROM_HERE, |
295 base::Bind(&ChildControllerImpl::Init, base::Unretained(&app_context), | 297 base::Bind(&ChildControllerImpl::Init, base::Unretained(&app_context), |
296 base::Passed(platform_channel()), blocker.GetUnblocker())); | 298 base::Passed(&platform_channel), blocker.GetUnblocker())); |
297 // This will block, then run whatever the controller wants. | 299 // This will block, then run whatever the controller wants. |
298 blocker.Block(); | 300 blocker.Block(); |
299 | 301 |
300 app_context.Shutdown(); | 302 app_context.Shutdown(); |
| 303 |
| 304 return 0; |
301 } | 305 } |
302 | 306 |
303 } // namespace shell | 307 } // namespace shell |
304 } // namespace mojo | 308 } // namespace mojo |
OLD | NEW |