Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "sky/shell/sky_main.h" | 5 #include "sky/shell/sky_main.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 using base::LazyInstance; | 24 using base::LazyInstance; |
| 25 | 25 |
| 26 namespace sky { | 26 namespace sky { |
| 27 namespace shell { | 27 namespace shell { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop = | 31 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop = |
| 32 LAZY_INSTANCE_INITIALIZER; | 32 LAZY_INSTANCE_INITIALIZER; |
| 33 | 33 |
| 34 LazyInstance<base::android::ScopedJavaGlobalRef<jobject>> g_main_activiy = | |
| 35 LAZY_INSTANCE_INITIALIZER; | |
| 36 | |
| 37 LazyInstance<scoped_ptr<Shell>> g_shell = LAZY_INSTANCE_INITIALIZER; | 34 LazyInstance<scoped_ptr<Shell>> g_shell = LAZY_INSTANCE_INITIALIZER; |
| 38 | 35 |
| 39 void InitializeLogging() { | 36 void InitializeLogging() { |
| 40 logging::LoggingSettings settings; | 37 logging::LoggingSettings settings; |
| 41 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 38 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 42 logging::InitLogging(settings); | 39 logging::InitLogging(settings); |
| 43 // To view log output with IDs and timestamps use "adb logcat -v threadtime". | 40 // To view log output with IDs and timestamps use "adb logcat -v threadtime". |
| 44 logging::SetLogItems(false, // Process ID | 41 logging::SetLogItems(false, // Process ID |
| 45 false, // Thread ID | 42 false, // Thread ID |
| 46 false, // Timestamp | 43 false, // Timestamp |
| 47 false); // Tick count | 44 false); // Tick count |
| 48 } | 45 } |
| 49 | 46 |
| 50 } // namespace | 47 } // namespace |
| 51 | 48 |
| 52 static void Init(JNIEnv* env, | 49 static void Init(JNIEnv* env, |
| 53 jclass clazz, | 50 jclass clazz, |
| 54 jobject activity) { | 51 jobject activity) { |
| 55 g_main_activiy.Get().Reset(env, activity); | |
| 56 | |
| 57 base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity); | 52 base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity); |
|
eseidel
2015/02/18 20:55:56
You mentioned you wanted to rename this to "applic
| |
| 58 base::android::InitApplicationContext(env, scoped_activity); | 53 base::android::InitApplicationContext(env, scoped_activity); |
| 59 | 54 |
| 60 base::CommandLine::Init(0, nullptr); | 55 base::CommandLine::Init(0, nullptr); |
| 61 | 56 |
| 62 InitializeLogging(); | 57 InitializeLogging(); |
| 63 | 58 |
| 64 g_java_message_loop.Get().reset(new base::MessageLoopForUI); | 59 g_java_message_loop.Get().reset(new base::MessageLoopForUI); |
| 65 base::MessageLoopForUI::current()->Start(); | 60 base::MessageLoopForUI::current()->Start(); |
| 66 | 61 |
| 67 base::i18n::InitializeICU(); | 62 base::i18n::InitializeICU(); |
| 68 gfx::GLSurface::InitializeOneOff(); | 63 gfx::GLSurface::InitializeOneOff(); |
| 69 | 64 |
| 70 g_shell.Get().reset(new Shell(g_java_message_loop.Get()->task_runner())); | 65 g_shell.Get().reset(new Shell(g_java_message_loop.Get()->task_runner())); |
| 71 | 66 g_shell.Get()->Init(); |
|
eseidel
2015/02/18 20:55:56
This can just be Shell::Init(), which creates g_sh
| |
| 72 g_java_message_loop.Get()->PostTask( | |
| 73 FROM_HERE, | |
| 74 base::Bind(&Shell::Init, base::Unretained(g_shell.Get().get()))); | |
| 75 } | |
| 76 | |
| 77 static jboolean Start(JNIEnv* env, jclass clazz) { | |
| 78 LOG(INFO) << "Native code started!"; | |
| 79 return true; | |
| 80 } | 67 } |
| 81 | 68 |
| 82 bool RegisterSkyMain(JNIEnv* env) { | 69 bool RegisterSkyMain(JNIEnv* env) { |
| 83 return RegisterNativesImpl(env); | 70 return RegisterNativesImpl(env); |
| 84 } | 71 } |
| 85 | 72 |
| 86 } // namespace sky | 73 } // namespace sky |
| 87 } // namespace mojo | 74 } // namespace mojo |
| OLD | NEW |