| 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 SERVICES_SERVICE_MANAGER_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ |
| 6 #define SERVICES_SERVICE_MANAGER_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | 6 #define SERVICES_SERVICE_MANAGER_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "services/service_manager/native_runner.h" | 16 #include "services/service_manager/native_runner.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class TaskRunner; | 19 class TaskRunner; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace service_manager { | 22 namespace service_manager { |
| 23 | 23 |
| 24 class ChildProcessHost; | 24 class ChildProcessHost; |
| 25 class NativeRunnerDelegate; | 25 class NativeRunnerDelegate; |
| 26 | 26 |
| 27 // An implementation of |NativeRunner| that runs a given service executable | 27 // An implementation of |NativeRunner| that loads/runs the given app (from the |
| 28 // in a separate, dedicated process. | 28 // file system) in a separate process (of its own). |
| 29 class OutOfProcessNativeRunner : public NativeRunner { | 29 class OutOfProcessNativeRunner : public NativeRunner { |
| 30 public: | 30 public: |
| 31 OutOfProcessNativeRunner(const base::FilePath& service_path, | 31 OutOfProcessNativeRunner(base::TaskRunner* launch_process_runner, |
| 32 base::TaskRunner* launch_process_runner, | |
| 33 NativeRunnerDelegate* delegate); | 32 NativeRunnerDelegate* delegate); |
| 34 ~OutOfProcessNativeRunner() override; | 33 ~OutOfProcessNativeRunner() override; |
| 35 | 34 |
| 36 // NativeRunner: | 35 // NativeRunner: |
| 37 mojom::ServicePtr Start( | 36 mojom::ServicePtr Start( |
| 37 const base::FilePath& app_path, |
| 38 const Identity& identity, | 38 const Identity& identity, |
| 39 bool start_sandboxed, | 39 bool start_sandboxed, |
| 40 const base::Callback<void(base::ProcessId)>& pid_available_callback, | 40 const base::Callback<void(base::ProcessId)>& pid_available_callback, |
| 41 const base::Closure& app_completed_callback) override; | 41 const base::Closure& app_completed_callback) override; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 void AppCompleted(); | 44 void AppCompleted(); |
| 45 | 45 |
| 46 base::TaskRunner* const launch_process_runner_; | 46 base::TaskRunner* const launch_process_runner_; |
| 47 NativeRunnerDelegate* delegate_; | 47 NativeRunnerDelegate* delegate_; |
| 48 | 48 |
| 49 const base::FilePath service_path_; | 49 base::FilePath app_path_; |
| 50 base::Closure app_completed_callback_; | 50 base::Closure app_completed_callback_; |
| 51 | 51 |
| 52 std::unique_ptr<ChildProcessHost> child_process_host_; | 52 std::unique_ptr<ChildProcessHost> child_process_host_; |
| 53 | 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunner); | 54 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunner); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 class OutOfProcessNativeRunnerFactory : public NativeRunnerFactory { | 57 class OutOfProcessNativeRunnerFactory : public NativeRunnerFactory { |
| 58 public: | 58 public: |
| 59 OutOfProcessNativeRunnerFactory(base::TaskRunner* launch_process_runner, | 59 OutOfProcessNativeRunnerFactory(base::TaskRunner* launch_process_runner, |
| 60 NativeRunnerDelegate* delegate); | 60 NativeRunnerDelegate* delegate); |
| 61 ~OutOfProcessNativeRunnerFactory() override; | 61 ~OutOfProcessNativeRunnerFactory() override; |
| 62 | 62 |
| 63 std::unique_ptr<NativeRunner> Create( | 63 std::unique_ptr<NativeRunner> Create(const base::FilePath& app_path) override; |
| 64 const base::FilePath& service_path) override; | |
| 65 | 64 |
| 66 private: | 65 private: |
| 67 base::TaskRunner* const launch_process_runner_; | 66 base::TaskRunner* const launch_process_runner_; |
| 68 NativeRunnerDelegate* delegate_; | 67 NativeRunnerDelegate* delegate_; |
| 69 | 68 |
| 70 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunnerFactory); | 69 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunnerFactory); |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 } // namespace service_manager | 72 } // namespace service_manager |
| 74 | 73 |
| 75 #endif // SERVICES_SERVICE_MANAGER_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | 74 #endif // SERVICES_SERVICE_MANAGER_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ |
| OLD | NEW |