| 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_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ | 5 #ifndef SERVICES_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ |
| 6 #define SERVICES_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ | 6 #define SERVICES_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/scoped_native_library.h" | 13 #include "base/scoped_native_library.h" |
| 14 #include "base/threading/simple_thread.h" | 14 #include "base/threading/simple_thread.h" |
| 15 #include "services/shell/native_runner.h" | 15 #include "services/shell/native_runner.h" |
| 16 #include "services/shell/runner/host/native_application_support.h" | |
| 17 | 16 |
| 18 namespace base { | 17 namespace base { |
| 19 class TaskRunner; | 18 class TaskRunner; |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace shell { | 21 namespace shell { |
| 23 | 22 |
| 24 // An implementation of |NativeRunner| that loads/runs the given app (from the | 23 // An implementation of |NativeRunner| that loads/runs the given service (from |
| 25 // file system) on a separate thread (in the current process). | 24 // the file system) on a separate thread (in the current process). |
| 26 class InProcessNativeRunner : public NativeRunner, | 25 class InProcessNativeRunner : public NativeRunner, |
| 27 public base::DelegateSimpleThread::Delegate { | 26 public base::DelegateSimpleThread::Delegate { |
| 28 public: | 27 public: |
| 29 InProcessNativeRunner(); | 28 InProcessNativeRunner(); |
| 30 ~InProcessNativeRunner() override; | 29 ~InProcessNativeRunner() override; |
| 31 | 30 |
| 32 // NativeRunner: | 31 // NativeRunner: |
| 33 mojom::ServicePtr Start( | 32 mojom::ServicePtr Start( |
| 34 const base::FilePath& app_path, | 33 const base::FilePath& library_path, |
| 35 const Identity& target, | 34 const Identity& target, |
| 36 bool start_sandboxed, | 35 bool start_sandboxed, |
| 37 const base::Callback<void(base::ProcessId)>& pid_available_callback, | 36 const base::Callback<void(base::ProcessId)>& pid_available_callback, |
| 38 const base::Closure& app_completed_callback) override; | 37 const base::Closure& service_completed_callback) override; |
| 39 | 38 |
| 40 private: | 39 private: |
| 41 // |base::DelegateSimpleThread::Delegate| method: | 40 // |base::DelegateSimpleThread::Delegate| method: |
| 42 void Run() override; | 41 void Run() override; |
| 43 | 42 |
| 44 base::FilePath app_path_; | 43 base::FilePath library_path_; |
| 45 mojom::ServiceRequest request_; | 44 mojom::ServiceRequest request_; |
| 46 base::Callback<bool(void)> app_completed_callback_runner_; | 45 base::Callback<bool(void)> service_completed_callback_runner_; |
| 47 | 46 |
| 48 base::ScopedNativeLibrary app_library_; | 47 base::ScopedNativeLibrary library_; |
| 49 std::unique_ptr<base::DelegateSimpleThread> thread_; | 48 std::unique_ptr<base::DelegateSimpleThread> thread_; |
| 50 | 49 |
| 51 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunner); | 50 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunner); |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 class InProcessNativeRunnerFactory : public NativeRunnerFactory { | 53 class InProcessNativeRunnerFactory : public NativeRunnerFactory { |
| 55 public: | 54 public: |
| 56 explicit InProcessNativeRunnerFactory(base::TaskRunner* launch_process_runner) | 55 explicit InProcessNativeRunnerFactory(base::TaskRunner* launch_process_runner) |
| 57 : launch_process_runner_(launch_process_runner) {} | 56 : launch_process_runner_(launch_process_runner) {} |
| 58 ~InProcessNativeRunnerFactory() override {} | 57 ~InProcessNativeRunnerFactory() override {} |
| 59 | 58 |
| 60 std::unique_ptr<NativeRunner> Create(const base::FilePath& app_path) override; | 59 std::unique_ptr<NativeRunner> Create( |
| 60 const base::FilePath& library_path) override; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 base::TaskRunner* const launch_process_runner_; | 63 base::TaskRunner* const launch_process_runner_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunnerFactory); | 65 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunnerFactory); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace shell | 68 } // namespace shell |
| 69 | 69 |
| 70 #endif // SERVICES_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ | 70 #endif // SERVICES_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ |
| OLD | NEW |