OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_APPLICATION_MANAGER_NATIVE_RUNNER_H_ | 5 #ifndef SHELL_APPLICATION_MANAGER_NATIVE_RUNNER_H_ |
6 #define SHELL_APPLICATION_MANAGER_NATIVE_RUNNER_H_ | 6 #define SHELL_APPLICATION_MANAGER_NATIVE_RUNNER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 10 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "mojo/public/interfaces/application/application.mojom.h" | 11 #include "mojo/public/interfaces/application/application.mojom.h" |
12 #include "shell/native_application_support.h" | 12 #include "shell/native_application_support.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class FilePath; | 15 class FilePath; |
16 } | 16 } |
17 | 17 |
18 namespace shell { | 18 namespace shell { |
19 | 19 |
20 // ApplicationManager requires implementations of NativeRunner and | 20 // ApplicationManager requires implementations of NativeRunner and |
21 // NativeRunnerFactory to run native applications. | 21 // NativeRunnerFactory to run native applications. |
22 class NativeRunner { | 22 class NativeRunner { |
23 public: | 23 public: |
24 virtual ~NativeRunner() {} | 24 virtual ~NativeRunner() {} |
25 | 25 |
26 // Loads the app in the file at |app_path| and runs it on some other | 26 // Loads the app in the file at |app_path| and runs it on some other |
27 // thread/process. If |cleanup| is |DELETE|, this takes ownership of the file. | 27 // thread/process. |
28 // |app_completed_callback| is posted (to the thread on which |Start()| was | 28 // |app_completed_callback| is posted (to the thread on which |Start()| was |
29 // called) after |MojoMain()| completes, or on any error (including if it | 29 // called) after |MojoMain()| completes, or on any error (including if it |
30 // fails to start). | 30 // fails to start). |
31 // TODO(vtl): |app_path| and |cleanup| should probably be moved to the | 31 // TODO(vtl): |app_path| should probably be moved to the factory's Create(). |
32 // factory's Create(). Rationale: The factory may need information from the | 32 // Rationale: The factory may need information from the file to decide what |
33 // file to decide what kind of NativeRunner to make. | 33 // kind of NativeRunner to make. |
34 virtual void Start( | 34 virtual void Start( |
35 const base::FilePath& app_path, | 35 const base::FilePath& app_path, |
36 NativeApplicationCleanup cleanup, | |
37 mojo::InterfaceRequest<mojo::Application> application_request, | 36 mojo::InterfaceRequest<mojo::Application> application_request, |
38 const base::Closure& app_completed_callback) = 0; | 37 const base::Closure& app_completed_callback) = 0; |
39 }; | 38 }; |
40 | 39 |
41 class NativeRunnerFactory { | 40 class NativeRunnerFactory { |
42 public: | 41 public: |
43 // Options for running the native app. (This will contain, e.g., information | 42 // Options for running the native app. (This will contain, e.g., information |
44 // about the sandbox profile, etc.) | 43 // about the sandbox profile, etc.) |
45 struct Options { | 44 struct Options { |
46 // Constructs with default options. | 45 // Constructs with default options. |
47 Options() : force_in_process(false) {} | 46 Options() : force_in_process(false) {} |
48 | 47 |
49 bool force_in_process; | 48 bool force_in_process; |
50 }; | 49 }; |
51 | 50 |
52 virtual ~NativeRunnerFactory() {} | 51 virtual ~NativeRunnerFactory() {} |
53 virtual scoped_ptr<NativeRunner> Create(const Options& options) = 0; | 52 virtual scoped_ptr<NativeRunner> Create(const Options& options) = 0; |
54 }; | 53 }; |
55 | 54 |
56 } // namespace shell | 55 } // namespace shell |
57 | 56 |
58 #endif // SHELL_APPLICATION_MANAGER_NATIVE_RUNNER_H_ | 57 #endif // SHELL_APPLICATION_MANAGER_NATIVE_RUNNER_H_ |
OLD | NEW |