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