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_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ | 5 #ifndef SHELL_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ |
6 #define SHELL_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ | 6 #define SHELL_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" |
11 #include "mojo/public/cpp/bindings/error_handler.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/app_child_process_host.h" | 14 #include "shell/app_child_process_host.h" |
14 #include "shell/application_manager/application_manager.h" | 15 #include "shell/application_manager/application_manager.h" |
15 #include "shell/dynamic_service_runner.h" | 16 #include "shell/dynamic_service_runner.h" |
16 | 17 |
17 namespace mojo { | 18 namespace mojo { |
18 namespace shell { | 19 namespace shell { |
19 | 20 |
| 21 class Context; |
| 22 |
20 // An implementation of |DynamicServiceRunner| that loads/runs the given app | 23 // An implementation of |DynamicServiceRunner| that loads/runs the given app |
21 // (from the file system) in a separate process (of its own). | 24 // (from the file system) in a separate process (of its own). |
22 class OutOfProcessDynamicServiceRunner : public mojo::NativeRunner { | 25 class OutOfProcessDynamicServiceRunner : public NativeRunner { |
23 public: | 26 public: |
24 explicit OutOfProcessDynamicServiceRunner(Context* context); | 27 explicit OutOfProcessDynamicServiceRunner(Context* context); |
25 ~OutOfProcessDynamicServiceRunner() override; | 28 ~OutOfProcessDynamicServiceRunner() override; |
26 | 29 |
27 // |DynamicServiceRunner| method: | 30 // |DynamicServiceRunner| method: |
28 void Start(const base::FilePath& app_path, | 31 void Start(const base::FilePath& app_path, |
29 mojo::NativeRunner::CleanupBehavior cleanup_behavior, | 32 NativeRunner::CleanupBehavior cleanup_behavior, |
30 InterfaceRequest<Application> application_request, | 33 InterfaceRequest<Application> application_request, |
31 const base::Closure& app_completed_callback) override; | 34 const base::Closure& app_completed_callback) override; |
32 | 35 |
33 private: | 36 private: |
34 // |AppChildController::StartApp| callback: | 37 // |AppChildController::StartApp| callback: |
35 void AppCompleted(int32_t result); | 38 void AppCompleted(int32_t result); |
36 | 39 |
37 Context* const context_; | 40 Context* const context_; |
38 | 41 |
39 base::FilePath app_path_; | 42 base::FilePath app_path_; |
40 base::Closure app_completed_callback_; | 43 base::Closure app_completed_callback_; |
41 | 44 |
42 scoped_ptr<AppChildProcessHost> app_child_process_host_; | 45 scoped_ptr<AppChildProcessHost> app_child_process_host_; |
43 | 46 |
44 DISALLOW_COPY_AND_ASSIGN(OutOfProcessDynamicServiceRunner); | 47 DISALLOW_COPY_AND_ASSIGN(OutOfProcessDynamicServiceRunner); |
45 }; | 48 }; |
46 | 49 |
47 typedef DynamicServiceRunnerFactoryImpl<OutOfProcessDynamicServiceRunner> | 50 class OutOfProcessDynamicServiceRunnerFactory : public NativeRunnerFactory { |
48 OutOfProcessDynamicServiceRunnerFactory; | 51 public: |
| 52 explicit OutOfProcessDynamicServiceRunnerFactory(Context* context) |
| 53 : context_(context) {} |
| 54 ~OutOfProcessDynamicServiceRunnerFactory() override {} |
| 55 |
| 56 scoped_ptr<NativeRunner> Create(const Options& options) override; |
| 57 |
| 58 private: |
| 59 Context* const context_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(OutOfProcessDynamicServiceRunnerFactory); |
| 62 }; |
49 | 63 |
50 } // namespace shell | 64 } // namespace shell |
51 } // namespace mojo | 65 } // namespace mojo |
52 | 66 |
53 #endif // SHELL_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ | 67 #endif // SHELL_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ |
OLD | NEW |