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