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_NATIVE_APPLICATION_SUPPORT_H_ | 5 #ifndef SHELL_NATIVE_APPLICATION_SUPPORT_H_ |
6 #define SHELL_NATIVE_APPLICATION_SUPPORT_H_ | 6 #define SHELL_NATIVE_APPLICATION_SUPPORT_H_ |
7 | 7 |
8 #include "base/native_library.h" | 8 #include "base/native_library.h" |
9 #include "mojo/public/cpp/bindings/interface_request.h" | 9 #include "mojo/public/cpp/bindings/interface_request.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 class FilePath; | 12 class FilePath; |
13 } | 13 } |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 class Application; | 16 class Application; |
17 } // namespace mojo | 17 } // namespace mojo |
18 | 18 |
19 namespace shell { | 19 namespace shell { |
20 | 20 |
21 enum class NativeApplicationCleanup { DELETE, DONT_DELETE }; | |
22 | |
23 // Loads the native Mojo application from the DSO specified by |app_path|. | 21 // Loads the native Mojo application from the DSO specified by |app_path|. |
24 // Returns the |base::NativeLibrary| for the application on success (or null on | 22 // Returns the |base::NativeLibrary| for the application on success (or null on |
25 // failure). If |cleanup| is |DELETE|, it will delete |app_path| (regardless of | 23 // failure). |
26 // sucess or failure). | |
27 // | 24 // |
28 // Note: The caller may choose to eventually unload the returned DSO. If so, | 25 // Note: The caller may choose to eventually unload the returned DSO. If so, |
29 // this should be done only after the thread on which |LoadNativeApplication()| | 26 // this should be done only after the thread on which |LoadNativeApplication()| |
30 // and |RunNativeApplication()| were called has terminated, so that any | 27 // and |RunNativeApplication()| were called has terminated, so that any |
31 // thread-local destructors have been executed. | 28 // thread-local destructors have been executed. |
32 base::NativeLibrary LoadNativeApplication(const base::FilePath& app_path, | 29 base::NativeLibrary LoadNativeApplication(const base::FilePath& app_path); |
33 NativeApplicationCleanup cleanup); | |
34 | 30 |
35 // Runs the native Mojo application from the DSO that was loaded using | 31 // Runs the native Mojo application from the DSO that was loaded using |
36 // |LoadNativeApplication()|; this tolerates |app_library| being null. This | 32 // |LoadNativeApplication()|; this tolerates |app_library| being null. This |
37 // should be called on the same thread as |LoadNativeApplication()|. Returns | 33 // should be called on the same thread as |LoadNativeApplication()|. Returns |
38 // true if |MojoMain()| was called (even if it returns an error), and false | 34 // true if |MojoMain()| was called (even if it returns an error), and false |
39 // otherwise. | 35 // otherwise. |
40 // TODO(vtl): Maybe this should also have a |MojoResult| as an out parameter? | 36 // TODO(vtl): Maybe this should also have a |MojoResult| as an out parameter? |
41 bool RunNativeApplication( | 37 bool RunNativeApplication( |
42 base::NativeLibrary app_library, | 38 base::NativeLibrary app_library, |
43 mojo::InterfaceRequest<mojo::Application> application_request); | 39 mojo::InterfaceRequest<mojo::Application> application_request); |
44 | 40 |
45 } // namespace shell | 41 } // namespace shell |
46 | 42 |
47 #endif // SHELL_NATIVE_APPLICATION_SUPPORT_H_ | 43 #endif // SHELL_NATIVE_APPLICATION_SUPPORT_H_ |
OLD | NEW |