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 #include "mojo/shell/runner/host/native_application_support.h" | 5 #include "mojo/shell/runner/host/native_application_support.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 base::NativeLibraryLoadError error; | 48 base::NativeLibraryLoadError error; |
49 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, &error); | 49 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, &error); |
50 LOG_IF(ERROR, !app_library) | 50 LOG_IF(ERROR, !app_library) |
51 << "Failed to load app library (error: " << error.ToString() << ")"; | 51 << "Failed to load app library (error: " << error.ToString() << ")"; |
52 return app_library; | 52 return app_library; |
53 } | 53 } |
54 | 54 |
55 bool RunNativeApplication( | 55 bool RunNativeApplication( |
56 base::NativeLibrary app_library, | 56 base::NativeLibrary app_library, |
57 InterfaceRequest<mojom::Application> application_request) { | 57 InterfaceRequest<mojom::ShellClient> request) { |
58 // Tolerate |app_library| being null, to make life easier for callers. | 58 // Tolerate |app_library| being null, to make life easier for callers. |
59 if (!app_library) | 59 if (!app_library) |
60 return false; | 60 return false; |
61 | 61 |
62 // Thunks aren't needed/used in component build, since the thunked methods | 62 // Thunks aren't needed/used in component build, since the thunked methods |
63 // just live in their own dynamically loaded library. | 63 // just live in their own dynamically loaded library. |
64 #if !defined(COMPONENT_BUILD) | 64 #if !defined(COMPONENT_BUILD) |
65 if (!SetThunks(&MojoMakeSystemThunks, "MojoSetSystemThunks", app_library)) { | 65 if (!SetThunks(&MojoMakeSystemThunks, "MojoSetSystemThunks", app_library)) { |
66 LOG(ERROR) << "MojoSetSystemThunks not found"; | 66 LOG(ERROR) << "MojoSetSystemThunks not found"; |
67 return false; | 67 return false; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 #endif | 113 #endif |
114 | 114 |
115 typedef MojoResult (*MojoMainFunction)(MojoHandle); | 115 typedef MojoResult (*MojoMainFunction)(MojoHandle); |
116 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( | 116 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( |
117 base::GetFunctionPointerFromNativeLibrary(app_library, "MojoMain")); | 117 base::GetFunctionPointerFromNativeLibrary(app_library, "MojoMain")); |
118 if (!main_function) { | 118 if (!main_function) { |
119 LOG(ERROR) << "MojoMain not found"; | 119 LOG(ERROR) << "MojoMain not found"; |
120 return false; | 120 return false; |
121 } | 121 } |
122 // |MojoMain()| takes ownership of the service handle. | 122 // |MojoMain()| takes ownership of the service handle. |
123 MojoHandle handle = application_request.PassMessagePipe().release().value(); | 123 MojoHandle handle = request.PassMessagePipe().release().value(); |
124 MojoResult result = main_function(handle); | 124 MojoResult result = main_function(handle); |
125 if (result != MOJO_RESULT_OK) { | 125 if (result != MOJO_RESULT_OK) { |
126 LOG(ERROR) << "MojoMain returned error (result: " << result << ")"; | 126 LOG(ERROR) << "MojoMain returned error (result: " << result << ")"; |
127 } | 127 } |
128 return true; | 128 return true; |
129 } | 129 } |
130 | 130 |
131 } // namespace shell | 131 } // namespace shell |
132 } // namespace mojo | 132 } // namespace mojo |
OLD | NEW |