| 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_DYNAMIC_SERVICE_RUNNER_H_ | 5 #ifndef SHELL_DYNAMIC_SERVICE_RUNNER_H_ |
| 6 #define SHELL_DYNAMIC_SERVICE_RUNNER_H_ | 6 #define SHELL_DYNAMIC_SERVICE_RUNNER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/native_library.h" | 8 #include "base/native_library.h" |
| 11 #include "mojo/public/cpp/bindings/interface_request.h" | 9 #include "mojo/public/cpp/bindings/interface_request.h" |
| 12 #include "mojo/public/cpp/system/core.h" | |
| 13 #include "shell/application_manager/application_manager.h" | 10 #include "shell/application_manager/application_manager.h" |
| 14 | 11 |
| 15 namespace base { | 12 namespace base { |
| 16 class FilePath; | 13 class FilePath; |
| 17 } | 14 } |
| 18 | 15 |
| 19 namespace mojo { | 16 namespace mojo { |
| 20 class Application; | 17 class Application; |
| 21 | 18 |
| 22 namespace shell { | 19 namespace shell { |
| 23 | 20 |
| 24 class Context; | |
| 25 | |
| 26 // Loads the service in the DSO specificed by |app_path| and prepares it for | 21 // Loads the service in the DSO specificed by |app_path| and prepares it for |
| 27 // execution. Runs the DSO's exported function MojoMain(). | 22 // execution. Runs the DSO's exported function MojoMain(). |
| 28 // The NativeLibrary is returned and ownership transferred to the caller. | 23 // The NativeLibrary is returned and ownership transferred to the caller. |
| 29 // This is so if it is unloaded at all, this can be done safely after this | 24 // This is so if it is unloaded at all, this can be done safely after this |
| 30 // thread is destroyed and any thread-local destructors have been executed. | 25 // thread is destroyed and any thread-local destructors have been executed. |
| 31 base::NativeLibrary LoadAndRunNativeApplication( | 26 base::NativeLibrary LoadAndRunNativeApplication( |
| 32 const base::FilePath& app_path, | 27 const base::FilePath& app_path, |
| 33 mojo::NativeRunner::CleanupBehavior cleanup_behavior, | 28 NativeRunner::CleanupBehavior cleanup_behavior, |
| 34 InterfaceRequest<Application> application_request); | 29 InterfaceRequest<Application> application_request); |
| 35 | 30 |
| 36 // A generic factory. | |
| 37 template <class DynamicServiceRunnerImpl> | |
| 38 class DynamicServiceRunnerFactoryImpl : public mojo::NativeRunnerFactory { | |
| 39 public: | |
| 40 DynamicServiceRunnerFactoryImpl(shell::Context* context) | |
| 41 : context_(context) {} | |
| 42 virtual ~DynamicServiceRunnerFactoryImpl() {} | |
| 43 scoped_ptr<NativeRunner> Create() override { | |
| 44 return scoped_ptr<NativeRunner>(new DynamicServiceRunnerImpl(context_)); | |
| 45 } | |
| 46 | |
| 47 private: | |
| 48 shell::Context* context_; | |
| 49 }; | |
| 50 | |
| 51 } // namespace shell | 31 } // namespace shell |
| 52 } // namespace mojo | 32 } // namespace mojo |
| 53 | 33 |
| 54 #endif // SHELL_DYNAMIC_SERVICE_RUNNER_H_ | 34 #endif // SHELL_DYNAMIC_SERVICE_RUNNER_H_ |
| OLD | NEW |