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/native_application_support.h" | 5 #include "mojo/shell/native_application_support.h" |
6 | 6 |
7 #include "base/command_line.h" | |
8 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 9 #include "base/logging.h" |
11 #include "mojo/public/platform/native/gles2_impl_chromium_miscellaneous_thunks.h
" | 10 #include "mojo/public/platform/native/gles2_impl_chromium_miscellaneous_thunks.h
" |
12 #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" |
13 #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" |
14 #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" |
15 #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" |
16 #include "mojo/public/platform/native/gles2_impl_thunks.h" | 15 #include "mojo/public/platform/native/gles2_impl_thunks.h" |
17 #include "mojo/public/platform/native/gles2_thunks.h" | 16 #include "mojo/public/platform/native/gles2_thunks.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Go shared library support requires us to initialize the runtime before we | 97 // Go shared library support requires us to initialize the runtime before we |
99 // start running any go code. This is a temporary patch. | 98 // start running any go code. This is a temporary patch. |
100 typedef void (*InitGoRuntimeFn)(); | 99 typedef void (*InitGoRuntimeFn)(); |
101 InitGoRuntimeFn init_go_runtime = reinterpret_cast<InitGoRuntimeFn>( | 100 InitGoRuntimeFn init_go_runtime = reinterpret_cast<InitGoRuntimeFn>( |
102 base::GetFunctionPointerFromNativeLibrary(app_library, "InitGoRuntime")); | 101 base::GetFunctionPointerFromNativeLibrary(app_library, "InitGoRuntime")); |
103 if (init_go_runtime) { | 102 if (init_go_runtime) { |
104 DVLOG(2) << "InitGoRuntime: Initializing Go Runtime found in app"; | 103 DVLOG(2) << "InitGoRuntime: Initializing Go Runtime found in app"; |
105 init_go_runtime(); | 104 init_go_runtime(); |
106 } | 105 } |
107 | 106 |
108 #if !defined(OS_WIN) | |
109 // On Windows, initializing base::CommandLine with null parameters gets the | |
110 // process's command line from the OS. Other platforms need it to be passed | |
111 // in. This needs to be passed in before the app initializes the command line, | |
112 // which is done as soon as it loads. | |
113 typedef void (*InitCommandLineArgs)(int, const char* const*); | |
114 InitCommandLineArgs init_command_line_args = | |
115 reinterpret_cast<InitCommandLineArgs>( | |
116 base::GetFunctionPointerFromNativeLibrary(app_library, | |
117 "InitCommandLineArgs")); | |
118 if (init_command_line_args) { | |
119 int argc = 0; | |
120 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
121 const char** argv = new const char* [cmd_line->argv().size()]; | |
122 for (auto& arg : cmd_line->argv()) | |
123 argv[argc++] = arg.c_str(); | |
124 init_command_line_args(argc, argv); | |
125 } | |
126 #endif | |
127 | |
128 typedef MojoResult (*MojoMainFunction)(MojoHandle); | 107 typedef MojoResult (*MojoMainFunction)(MojoHandle); |
129 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( | 108 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( |
130 base::GetFunctionPointerFromNativeLibrary(app_library, "MojoMain")); | 109 base::GetFunctionPointerFromNativeLibrary(app_library, "MojoMain")); |
131 if (!main_function) { | 110 if (!main_function) { |
132 LOG(ERROR) << "MojoMain not found"; | 111 LOG(ERROR) << "MojoMain not found"; |
133 return false; | 112 return false; |
134 } | 113 } |
135 // |MojoMain()| takes ownership of the service handle. | 114 // |MojoMain()| takes ownership of the service handle. |
136 MojoHandle handle = application_request.PassMessagePipe().release().value(); | 115 MojoHandle handle = application_request.PassMessagePipe().release().value(); |
137 MojoResult result = main_function(handle); | 116 MojoResult result = main_function(handle); |
138 if (result < MOJO_RESULT_OK) { | 117 if (result < MOJO_RESULT_OK) { |
139 LOG(ERROR) << "MojoMain returned error (result: " << result << ")"; | 118 LOG(ERROR) << "MojoMain returned error (result: " << result << ")"; |
140 } | 119 } |
141 return true; | 120 return true; |
142 } | 121 } |
143 | 122 |
144 } // namespace shell | 123 } // namespace shell |
145 } // namespace mojo | 124 } // namespace mojo |
OLD | NEW |