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 MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_ | 5 #ifndef MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_ |
6 #define MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_ | 6 #define MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Abstraction for loading a service (from the file system) and running it (on | 22 // Abstraction for loading a service (from the file system) and running it (on |
23 // another thread or in a separate process). | 23 // another thread or in a separate process). |
24 class DynamicServiceRunner { | 24 class DynamicServiceRunner { |
25 public: | 25 public: |
26 virtual ~DynamicServiceRunner() {} | 26 virtual ~DynamicServiceRunner() {} |
27 | 27 |
28 // Takes ownership of the file at |app_path|. Loads the app in that file and | 28 // Takes ownership of the file at |app_path|. Loads the app in that file and |
29 // runs it on some other thread/process. |app_completed_callback| is posted | 29 // runs it on some other thread/process. |app_completed_callback| is posted |
30 // (to the thread on which |Start()| was called) after |MojoMain()| completes. | 30 // (to the thread on which |Start()| was called) after |MojoMain()| completes. |
31 virtual void Start(const base::FilePath& app_path, | 31 virtual void Start(const base::FilePath& app_path, |
32 ScopedShellHandle service_handle, | 32 ScopedMessagePipeHandle service_handle, |
33 const base::Closure& app_completed_callback) = 0; | 33 const base::Closure& app_completed_callback) = 0; |
34 }; | 34 }; |
35 | 35 |
36 class DynamicServiceRunnerFactory { | 36 class DynamicServiceRunnerFactory { |
37 public: | 37 public: |
38 virtual ~DynamicServiceRunnerFactory() {} | 38 virtual ~DynamicServiceRunnerFactory() {} |
39 virtual scoped_ptr<DynamicServiceRunner> Create(Context* context) = 0; | 39 virtual scoped_ptr<DynamicServiceRunner> Create(Context* context) = 0; |
40 }; | 40 }; |
41 | 41 |
42 // A generic factory. | 42 // A generic factory. |
43 template <class DynamicServiceRunnerImpl> | 43 template <class DynamicServiceRunnerImpl> |
44 class DynamicServiceRunnerFactoryImpl : public DynamicServiceRunnerFactory { | 44 class DynamicServiceRunnerFactoryImpl : public DynamicServiceRunnerFactory { |
45 public: | 45 public: |
46 DynamicServiceRunnerFactoryImpl() {} | 46 DynamicServiceRunnerFactoryImpl() {} |
47 virtual ~DynamicServiceRunnerFactoryImpl() {} | 47 virtual ~DynamicServiceRunnerFactoryImpl() {} |
48 virtual scoped_ptr<DynamicServiceRunner> Create(Context* context) OVERRIDE { | 48 virtual scoped_ptr<DynamicServiceRunner> Create(Context* context) OVERRIDE { |
49 return scoped_ptr<DynamicServiceRunner>( | 49 return scoped_ptr<DynamicServiceRunner>( |
50 new DynamicServiceRunnerImpl(context)); | 50 new DynamicServiceRunnerImpl(context)); |
51 } | 51 } |
52 }; | 52 }; |
53 | 53 |
54 } // namespace shell | 54 } // namespace shell |
55 } // namespace mojo | 55 } // namespace mojo |
56 | 56 |
57 #endif // MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_ | 57 #endif // MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_ |
OLD | NEW |