OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/runner/android/main.h" | 5 #include "mojo/runner/android/main.h" |
6 | 6 |
7 #include "base/android/fifo_utils.h" | 7 #include "base/android/fifo_utils.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
21 #include "base/threading/simple_thread.h" | 21 #include "base/threading/simple_thread.h" |
22 #include "jni/ShellMain_jni.h" | 22 #include "jni/ShellMain_jni.h" |
23 #include "mojo/common/message_pump_mojo.h" | 23 #include "mojo/common/message_pump_mojo.h" |
24 #include "mojo/runner/android/android_handler_loader.h" | 24 #include "mojo/runner/android/android_handler_loader.h" |
25 #include "mojo/runner/android/background_application_loader.h" | 25 #include "mojo/runner/android/background_application_loader.h" |
| 26 #include "mojo/runner/android/context_init.h" |
26 #include "mojo/runner/android/native_viewport_application_loader.h" | 27 #include "mojo/runner/android/native_viewport_application_loader.h" |
27 #include "mojo/runner/android/ui_application_loader_android.h" | 28 #include "mojo/runner/android/ui_application_loader_android.h" |
28 #include "mojo/runner/context.h" | 29 #include "mojo/runner/context.h" |
29 #include "mojo/runner/init.h" | 30 #include "mojo/runner/init.h" |
30 #include "mojo/shell/application_loader.h" | 31 #include "mojo/shell/application_loader.h" |
31 #include "ui/gl/gl_surface_egl.h" | 32 #include "ui/gl/gl_surface_egl.h" |
32 | 33 |
33 using base::LazyInstance; | 34 using base::LazyInstance; |
34 | 35 |
35 namespace mojo { | 36 namespace mojo { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 mojo::runner::WaitForDebuggerIfNecessary(); | 160 mojo::runner::WaitForDebuggerIfNecessary(); |
160 | 161 |
161 InitializeRedirection(); | 162 InitializeRedirection(); |
162 | 163 |
163 // We want ~MessageLoop to happen prior to ~Context. Initializing | 164 // We want ~MessageLoop to happen prior to ~Context. Initializing |
164 // LazyInstances is akin to stack-allocating objects; their destructors | 165 // LazyInstances is akin to stack-allocating objects; their destructors |
165 // will be invoked first-in-last-out. | 166 // will be invoked first-in-last-out. |
166 Context* shell_context = new Context(); | 167 Context* shell_context = new Context(); |
167 shell_context->SetShellFileRoot(base::FilePath( | 168 shell_context->SetShellFileRoot(base::FilePath( |
168 base::android::ConvertJavaStringToUTF8(env, j_local_apps_directory))); | 169 base::android::ConvertJavaStringToUTF8(env, j_local_apps_directory))); |
| 170 InitContext(shell_context); |
169 g_context.Get().reset(shell_context); | 171 g_context.Get().reset(shell_context); |
170 | 172 |
171 g_java_message_loop.Get().reset(new base::MessageLoopForUI); | 173 g_java_message_loop.Get().reset(new base::MessageLoopForUI); |
172 base::MessageLoopForUI::current()->Start(); | 174 base::MessageLoopForUI::current()->Start(); |
173 | 175 |
174 // TODO(abarth): At which point should we switch to cross-platform | 176 // TODO(abarth): At which point should we switch to cross-platform |
175 // initialization? | 177 // initialization? |
176 | 178 |
177 gfx::GLSurface::InitializeOneOff(); | 179 gfx::GLSurface::InitializeOneOff(); |
178 } | 180 } |
(...skipping 24 matching lines...) Expand all Loading... |
203 } | 205 } |
204 | 206 |
205 } // namespace runner | 207 } // namespace runner |
206 } // namespace mojo | 208 } // namespace mojo |
207 | 209 |
208 // TODO(vtl): Even though main() should never be called, mojo_shell fails to | 210 // TODO(vtl): Even though main() should never be called, mojo_shell fails to |
209 // link without it. Figure out if we can avoid this. | 211 // link without it. Figure out if we can avoid this. |
210 int main(int argc, char** argv) { | 212 int main(int argc, char** argv) { |
211 NOTREACHED(); | 213 NOTREACHED(); |
212 } | 214 } |
OLD | NEW |