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 "shell/native_application_support.h" | 5 #include "shell/native_application_support.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "mojo/public/platform/native/gles2_impl_chromium_miscellaneous_thunks.h
" | 10 #include "mojo/public/platform/native/gles2_impl_chromium_miscellaneous_thunks.h
" |
11 #include "mojo/public/platform/native/gles2_impl_chromium_sub_image_thunks.h" | 11 #include "mojo/public/platform/native/gles2_impl_chromium_sub_image_thunks.h" |
12 #include "mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h" | 12 #include "mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h" |
13 #include "mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks
.h" | 13 #include "mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks
.h" |
14 #include "mojo/public/platform/native/gles2_impl_occlusion_query_ext_thunks.h" | 14 #include "mojo/public/platform/native/gles2_impl_occlusion_query_ext_thunks.h" |
15 #include "mojo/public/platform/native/gles2_impl_thunks.h" | 15 #include "mojo/public/platform/native/gles2_impl_thunks.h" |
16 #include "mojo/public/platform/native/gles2_thunks.h" | 16 #include "mojo/public/platform/native/gles2_thunks.h" |
17 #include "mojo/public/platform/native/system_impl_private_thunks.h" | 17 #include "mojo/public/platform/native/system_impl_private_thunks.h" |
18 #include "mojo/public/platform/native/system_thunks.h" | 18 #include "mojo/public/platform/native/system_thunks.h" |
19 | 19 |
20 namespace mojo { | |
21 namespace shell { | 20 namespace shell { |
22 | 21 |
23 namespace { | 22 namespace { |
24 | 23 |
25 template <typename Thunks> | 24 template <typename Thunks> |
26 bool SetThunks(Thunks (*make_thunks)(), | 25 bool SetThunks(Thunks (*make_thunks)(), |
27 const char* function_name, | 26 const char* function_name, |
28 base::NativeLibrary library) { | 27 base::NativeLibrary library) { |
29 typedef size_t (*SetThunksFn)(const Thunks* thunks); | 28 typedef size_t (*SetThunksFn)(const Thunks* thunks); |
30 SetThunksFn set_thunks = reinterpret_cast<SetThunksFn>( | 29 SetThunksFn set_thunks = reinterpret_cast<SetThunksFn>( |
(...skipping 18 matching lines...) Expand all Loading... |
49 | 48 |
50 base::NativeLibraryLoadError error; | 49 base::NativeLibraryLoadError error; |
51 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, &error); | 50 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, &error); |
52 if (cleanup == NativeApplicationCleanup::DELETE) | 51 if (cleanup == NativeApplicationCleanup::DELETE) |
53 DeleteFile(app_path, false); | 52 DeleteFile(app_path, false); |
54 LOG_IF(ERROR, !app_library) | 53 LOG_IF(ERROR, !app_library) |
55 << "Failed to load app library (error: " << error.ToString() << ")"; | 54 << "Failed to load app library (error: " << error.ToString() << ")"; |
56 return app_library; | 55 return app_library; |
57 } | 56 } |
58 | 57 |
59 bool RunNativeApplication(base::NativeLibrary app_library, | 58 bool RunNativeApplication( |
60 InterfaceRequest<Application> application_request) { | 59 base::NativeLibrary app_library, |
| 60 mojo::InterfaceRequest<mojo::Application> application_request) { |
61 // Tolerate |app_library| being null, to make life easier for callers. | 61 // Tolerate |app_library| being null, to make life easier for callers. |
62 if (!app_library) | 62 if (!app_library) |
63 return false; | 63 return false; |
64 | 64 |
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; |
68 } | 68 } |
69 | 69 |
70 // TODO(ncbray): enforce the private nature of this API, somehow? | 70 // TODO(ncbray): enforce the private nature of this API, somehow? |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 // |MojoMain()| takes ownership of the service handle. | 121 // |MojoMain()| takes ownership of the service handle. |
122 MojoHandle handle = application_request.PassMessagePipe().release().value(); | 122 MojoHandle handle = application_request.PassMessagePipe().release().value(); |
123 MojoResult result = main_function(handle); | 123 MojoResult result = main_function(handle); |
124 LOG_IF(ERROR, result != MOJO_RESULT_OK) | 124 LOG_IF(ERROR, result != MOJO_RESULT_OK) |
125 << "MojoMain returned error (result: " << result << ")"; | 125 << "MojoMain returned error (result: " << result << ")"; |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 } // namespace shell | 129 } // namespace shell |
130 } // namespace mojo | |
OLD | NEW |