| 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_APP_CHILD_PROCESS_HOST_H_ | 5 #ifndef SHELL_APP_CHILD_PROCESS_HOST_H_ |
| 6 #define SHELL_APP_CHILD_PROCESS_HOST_H_ | 6 #define SHELL_APP_CHILD_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "mojo/edk/embedder/channel_info_forward.h" | 11 #include "mojo/edk/embedder/channel_info_forward.h" |
| 12 #include "mojo/public/cpp/bindings/error_handler.h" |
| 12 #include "shell/app_child_process.mojom.h" | 13 #include "shell/app_child_process.mojom.h" |
| 13 #include "shell/child_process_host.h" | 14 #include "shell/child_process_host.h" |
| 14 | 15 |
| 15 namespace mojo { | 16 namespace mojo { |
| 16 namespace shell { | 17 namespace shell { |
| 17 | 18 |
| 18 // A subclass of |ChildProcessHost| to host an app child process, which runs a | 19 // A subclass of |ChildProcessHost| to host an app child process, which runs a |
| 19 // single app (loaded from the file system). | 20 // single app (loaded from the file system). |
| 20 // | 21 // |
| 21 // Note: After |Start()|, |StartApp| must be called and this object must | 22 // Note: After |Start()|, |StartApp| must be called and this object must |
| 22 // remained alive until the |on_app_complete| callback is called. | 23 // remained alive until the |on_app_complete| callback is called. |
| 23 class AppChildProcessHost : public ChildProcessHost { | 24 class AppChildProcessHost : public ChildProcessHost, public ErrorHandler { |
| 24 public: | 25 public: |
| 25 explicit AppChildProcessHost(Context* context); | 26 explicit AppChildProcessHost(Context* context); |
| 26 ~AppChildProcessHost() override; | 27 ~AppChildProcessHost() override; |
| 27 | 28 |
| 28 // See |AppChildController|: | 29 // See |AppChildController::StartApp()| (this may only be called after |
| 30 // |Start()|). Note, however, one difference: |on_app_complete| will *always* |
| 31 // get called, even on connection error (or even if the child process failed |
| 32 // to start at all). |
| 29 void StartApp(const String& app_path, | 33 void StartApp(const String& app_path, |
| 30 bool clean_app_path, | 34 bool clean_app_path, |
| 31 InterfaceRequest<Application> application_request, | 35 InterfaceRequest<Application> application_request, |
| 32 const AppChildController::StartAppCallback& on_app_complete); | 36 const AppChildController::StartAppCallback& on_app_complete); |
| 37 // See |AppChildController::ExitNow()|. |
| 33 void ExitNow(int32_t exit_code); | 38 void ExitNow(int32_t exit_code); |
| 34 | 39 |
| 35 // |ChildProcessHost| methods: | 40 // |ChildProcessHost| methods: |
| 36 void WillStart() override; | 41 void WillStart() override; |
| 37 void DidStart(bool success) override; | 42 void DidStart(bool success) override; |
| 38 | 43 |
| 44 // |ErrorHandler| methods: |
| 45 void OnConnectionError() override; |
| 46 |
| 39 private: | 47 private: |
| 40 // Callback for |embedder::CreateChannel()|. | 48 // Callback for |embedder::CreateChannel()|. |
| 41 void DidCreateChannel(embedder::ChannelInfo* channel_info); | 49 void DidCreateChannel(embedder::ChannelInfo* channel_info); |
| 42 | 50 |
| 43 void AppCompleted(int32_t result); | 51 void AppCompleted(int32_t result); |
| 44 | 52 |
| 45 AppChildControllerPtr controller_; | 53 AppChildControllerPtr controller_; |
| 46 embedder::ChannelInfo* channel_info_; | 54 embedder::ChannelInfo* channel_info_; |
| 47 AppChildController::StartAppCallback on_app_complete_; | 55 AppChildController::StartAppCallback on_app_complete_; |
| 48 | 56 |
| 49 DISALLOW_COPY_AND_ASSIGN(AppChildProcessHost); | 57 DISALLOW_COPY_AND_ASSIGN(AppChildProcessHost); |
| 50 }; | 58 }; |
| 51 | 59 |
| 52 } // namespace shell | 60 } // namespace shell |
| 53 } // namespace mojo | 61 } // namespace mojo |
| 54 | 62 |
| 55 #endif // SHELL_APP_CHILD_PROCESS_HOST_H_ | 63 #endif // SHELL_APP_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |