| 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_IN_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ | 5 #ifndef SHELL_IN_PROCESS_NATIVE_RUNNER_H_ |
| 6 #define SHELL_IN_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ | 6 #define SHELL_IN_PROCESS_NATIVE_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 "base/memory/scoped_ptr.h" |
| 12 #include "base/scoped_native_library.h" | 12 #include "base/scoped_native_library.h" |
| 13 #include "base/threading/simple_thread.h" | 13 #include "base/threading/simple_thread.h" |
| 14 #include "shell/application_manager/application_manager.h" | 14 #include "shell/application_manager/application_manager.h" |
| 15 #include "shell/dynamic_service_runner.h" | 15 #include "shell/dynamic_service_runner.h" |
| 16 | 16 |
| 17 namespace mojo { | 17 namespace mojo { |
| 18 namespace shell { | 18 namespace shell { |
| 19 | 19 |
| 20 class Context; | 20 class Context; |
| 21 | 21 |
| 22 // TODO(vtl): Rename this to "InProcessNativeRunner". | 22 // An implementation of |NativeRunner| that loads/runs the given app (from the |
| 23 // An implementation of |DynamicServiceRunner| that loads/runs the given app | 23 // file system) on a separate thread (in the current process). |
| 24 // (from the file system) on a separate thread (in the current process). | 24 class InProcessNativeRunner : public NativeRunner, |
| 25 class InProcessDynamicServiceRunner | 25 public base::DelegateSimpleThread::Delegate { |
| 26 : public NativeRunner, | |
| 27 public base::DelegateSimpleThread::Delegate { | |
| 28 public: | 26 public: |
| 29 explicit InProcessDynamicServiceRunner(Context* context); | 27 explicit InProcessNativeRunner(Context* context); |
| 30 ~InProcessDynamicServiceRunner() override; | 28 ~InProcessNativeRunner() override; |
| 31 | 29 |
| 32 // |DynamicServiceRunner| method: | 30 // |NativeRunner| method: |
| 33 void Start(const base::FilePath& app_path, | 31 void Start(const base::FilePath& app_path, |
| 34 NativeRunner::CleanupBehavior cleanup_behavior, | 32 NativeRunner::CleanupBehavior cleanup_behavior, |
| 35 InterfaceRequest<Application> application_request, | 33 InterfaceRequest<Application> application_request, |
| 36 const base::Closure& app_completed_callback) override; | 34 const base::Closure& app_completed_callback) override; |
| 37 | 35 |
| 38 private: | 36 private: |
| 39 // |base::DelegateSimpleThread::Delegate| method: | 37 // |base::DelegateSimpleThread::Delegate| method: |
| 40 void Run() override; | 38 void Run() override; |
| 41 | 39 |
| 42 base::FilePath app_path_; | 40 base::FilePath app_path_; |
| 43 NativeRunner::CleanupBehavior cleanup_behavior_; | 41 NativeRunner::CleanupBehavior cleanup_behavior_; |
| 44 InterfaceRequest<Application> application_request_; | 42 InterfaceRequest<Application> application_request_; |
| 45 base::Callback<bool(void)> app_completed_callback_runner_; | 43 base::Callback<bool(void)> app_completed_callback_runner_; |
| 46 | 44 |
| 47 base::ScopedNativeLibrary app_library_; | 45 base::ScopedNativeLibrary app_library_; |
| 48 scoped_ptr<base::DelegateSimpleThread> thread_; | 46 scoped_ptr<base::DelegateSimpleThread> thread_; |
| 49 | 47 |
| 50 DISALLOW_COPY_AND_ASSIGN(InProcessDynamicServiceRunner); | 48 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunner); |
| 51 }; | 49 }; |
| 52 | 50 |
| 53 class InProcessDynamicServiceRunnerFactory : public NativeRunnerFactory { | 51 class InProcessNativeRunnerFactory : public NativeRunnerFactory { |
| 54 public: | 52 public: |
| 55 explicit InProcessDynamicServiceRunnerFactory(Context* context) | 53 explicit InProcessNativeRunnerFactory(Context* context) : context_(context) {} |
| 56 : context_(context) {} | 54 ~InProcessNativeRunnerFactory() override {} |
| 57 ~InProcessDynamicServiceRunnerFactory() override {} | |
| 58 | 55 |
| 59 scoped_ptr<NativeRunner> Create(const Options& options) override; | 56 scoped_ptr<NativeRunner> Create(const Options& options) override; |
| 60 | 57 |
| 61 private: | 58 private: |
| 62 Context* const context_; | 59 Context* const context_; |
| 63 | 60 |
| 64 DISALLOW_COPY_AND_ASSIGN(InProcessDynamicServiceRunnerFactory); | 61 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunnerFactory); |
| 65 }; | 62 }; |
| 66 | 63 |
| 67 } // namespace shell | 64 } // namespace shell |
| 68 } // namespace mojo | 65 } // namespace mojo |
| 69 | 66 |
| 70 #endif // SHELL_IN_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ | 67 #endif // SHELL_IN_PROCESS_NATIVE_RUNNER_H_ |
| OLD | NEW |