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