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 #ifndef SHELL_CHILD_PROCESS_HOST_H_ | 5 #ifndef SHELL_CHILD_PROCESS_HOST_H_ |
6 #define SHELL_CHILD_PROCESS_HOST_H_ | 6 #define SHELL_CHILD_PROCESS_HOST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/process/process.h" | 14 #include "base/process/process.h" |
14 #include "mojo/edk/embedder/channel_info_forward.h" | 15 #include "mojo/edk/embedder/channel_info_forward.h" |
15 #include "mojo/edk/embedder/platform_channel_pair.h" | |
16 #include "mojo/edk/embedder/scoped_platform_handle.h" | 16 #include "mojo/edk/embedder/scoped_platform_handle.h" |
17 #include "mojo/public/cpp/bindings/error_handler.h" | 17 #include "mojo/public/cpp/bindings/error_handler.h" |
18 #include "shell/child_controller.mojom.h" | 18 #include "shell/child_controller.mojom.h" |
19 | 19 |
20 namespace shell { | 20 namespace shell { |
21 | 21 |
22 class Context; | 22 class Context; |
23 | 23 |
24 // Child process host: parent-process representation of a child process, which | 24 // Child process host: parent-process representation of a child process, which |
25 // hosts/runs a native Mojo application loaded from the file system. This class | 25 // hosts/runs a native Mojo application loaded from the file system. This class |
(...skipping 27 matching lines...) Expand all Loading... |
53 // Like |ChildController::StartApp()|, but with one difference: | 53 // Like |ChildController::StartApp()|, but with one difference: |
54 // |on_app_complete| will *always* get called, even on connection error (or | 54 // |on_app_complete| will *always* get called, even on connection error (or |
55 // even if the child process failed to start at all). | 55 // even if the child process failed to start at all). |
56 void StartApp(const mojo::String& app_path, | 56 void StartApp(const mojo::String& app_path, |
57 mojo::InterfaceRequest<mojo::Application> application_request, | 57 mojo::InterfaceRequest<mojo::Application> application_request, |
58 const ChildController::StartAppCallback& on_app_complete); | 58 const ChildController::StartAppCallback& on_app_complete); |
59 void ExitNow(int32_t exit_code); | 59 void ExitNow(int32_t exit_code); |
60 | 60 |
61 // TODO(vtl): This is virtual, so tests can override it, but really |Start()| | 61 // TODO(vtl): This is virtual, so tests can override it, but really |Start()| |
62 // should take a callback (see above) and this should be private. | 62 // should take a callback (see above) and this should be private. |
63 virtual void DidStart(bool success); | 63 virtual void DidStart(base::Process child_process); |
64 | 64 |
65 private: | 65 private: |
| 66 struct LaunchData; |
| 67 |
66 // Callback for |mojo::embedder::CreateChannel()|. | 68 // Callback for |mojo::embedder::CreateChannel()|. |
67 void DidCreateChannel(mojo::embedder::ChannelInfo* channel_info); | 69 void DidCreateChannel(mojo::embedder::ChannelInfo* channel_info); |
68 | 70 |
69 bool DoLaunch(const std::string& child_connection_id); | 71 // Note: This is probably executed on a different thread (namely, using the |
| 72 // blocking pool). |
| 73 base::Process DoLaunch(scoped_ptr<LaunchData> launch_data); |
70 | 74 |
71 void AppCompleted(int32_t result); | 75 void AppCompleted(int32_t result); |
72 | 76 |
73 // |mojo::ErrorHandler| methods: | 77 // |mojo::ErrorHandler| methods: |
74 void OnConnectionError() override; | 78 void OnConnectionError() override; |
75 | 79 |
76 Context* const context_; | 80 Context* const context_; |
77 mojo::embedder::PlatformChannelPair platform_channel_pair_; | |
78 | 81 |
79 ChildControllerPtr controller_; | 82 ChildControllerPtr controller_; |
80 mojo::embedder::ChannelInfo* channel_info_; | 83 mojo::embedder::ChannelInfo* channel_info_; |
81 ChildController::StartAppCallback on_app_complete_; | 84 ChildController::StartAppCallback on_app_complete_; |
82 | 85 |
83 base::Process child_process_; | 86 base::Process child_process_; |
84 | 87 |
85 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); | 88 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
86 }; | 89 }; |
87 | 90 |
88 } // namespace shell | 91 } // namespace shell |
89 | 92 |
90 #endif // SHELL_CHILD_PROCESS_HOST_H_ | 93 #endif // SHELL_CHILD_PROCESS_HOST_H_ |
OLD | NEW |