| 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 "shell/android/mojo_main.h" | 5 #include "shell/android/mojo_main.h" |
| 6 | 6 |
| 7 #include "base/android/command_line_android.h" | 7 #include "base/android/command_line_android.h" |
| 8 #include "base/android/java_handler_thread.h" | 8 #include "base/android/java_handler_thread.h" |
| 9 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 10 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
| 11 #include "base/bind.h" | 12 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 17 #include "jni/MojoMain_jni.h" | 18 #include "jni/MojoMain_jni.h" |
| 18 #include "mojo/application_manager/application_loader.h" | 19 #include "mojo/application_manager/application_loader.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 43 it != app_urls.end(); ++it) { | 44 it != app_urls.end(); ++it) { |
| 44 context->Run(*it); | 45 context->Run(*it); |
| 45 } | 46 } |
| 46 } | 47 } |
| 47 | 48 |
| 48 } // namespace | 49 } // namespace |
| 49 | 50 |
| 50 static void Init(JNIEnv* env, | 51 static void Init(JNIEnv* env, |
| 51 jclass clazz, | 52 jclass clazz, |
| 52 jobject context, | 53 jobject context, |
| 53 jobjectArray jparameters) { | 54 jobjectArray jparameters, |
| 55 jstring j_local_apps_directory) { |
| 54 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); | 56 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); |
| 55 | |
| 56 base::android::InitApplicationContext(env, scoped_context); | 57 base::android::InitApplicationContext(env, scoped_context); |
| 57 | 58 |
| 58 base::android::InitNativeCommandLineFromJavaArray(env, jparameters); | 59 base::android::InitNativeCommandLineFromJavaArray(env, jparameters); |
| 59 mojo::shell::InitializeLogging(); | 60 mojo::shell::InitializeLogging(); |
| 60 | 61 |
| 61 // We want ~MessageLoop to happen prior to ~Context. Initializing | 62 // We want ~MessageLoop to happen prior to ~Context. Initializing |
| 62 // LazyInstances is akin to stack-allocating objects; their destructors | 63 // LazyInstances is akin to stack-allocating objects; their destructors |
| 63 // will be invoked first-in-last-out. | 64 // will be invoked first-in-last-out. |
| 64 shell::Context* shell_context = new shell::Context(); | 65 shell::Context* shell_context = new shell::Context(); |
| 66 shell_context->mojo_url_resolver()->SetLocalAppsPath(base::FilePath( |
| 67 base::android::ConvertJavaStringToUTF8(env, j_local_apps_directory))); |
| 65 g_context.Get().reset(shell_context); | 68 g_context.Get().reset(shell_context); |
| 69 |
| 66 g_java_message_loop.Get().reset(new base::MessageLoopForUI); | 70 g_java_message_loop.Get().reset(new base::MessageLoopForUI); |
| 67 base::MessageLoopForUI::current()->Start(); | 71 base::MessageLoopForUI::current()->Start(); |
| 68 | 72 |
| 69 // TODO(abarth): At which point should we switch to cross-platform | 73 // TODO(abarth): At which point should we switch to cross-platform |
| 70 // initialization? | 74 // initialization? |
| 71 | 75 |
| 72 gfx::GLSurface::InitializeOneOff(); | 76 gfx::GLSurface::InitializeOneOff(); |
| 73 } | 77 } |
| 74 | 78 |
| 75 static void Start(JNIEnv* env, jclass clazz, jstring jurl) { | 79 static void Start(JNIEnv* env, jclass clazz, jstring jurl) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 88 g_shell_thread.Get()->Start(); | 92 g_shell_thread.Get()->Start(); |
| 89 g_shell_thread.Get()->message_loop()->PostTask( | 93 g_shell_thread.Get()->message_loop()->PostTask( |
| 90 FROM_HERE, base::Bind(&RunShell, app_urls)); | 94 FROM_HERE, base::Bind(&RunShell, app_urls)); |
| 91 } | 95 } |
| 92 | 96 |
| 93 bool RegisterMojoMain(JNIEnv* env) { | 97 bool RegisterMojoMain(JNIEnv* env) { |
| 94 return RegisterNativesImpl(env); | 98 return RegisterNativesImpl(env); |
| 95 } | 99 } |
| 96 | 100 |
| 97 } // namespace mojo | 101 } // namespace mojo |
| OLD | NEW |