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