OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "sky/shell/sky_main.h" |
| 6 |
| 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" |
| 10 #include "base/at_exit.h" |
| 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" |
| 13 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" |
| 15 #include "base/macros.h" |
| 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" |
| 18 #include "base/threading/simple_thread.h" |
| 19 #include "jni/SkyMain_jni.h" |
| 20 |
| 21 using base::LazyInstance; |
| 22 |
| 23 namespace sky { |
| 24 namespace shell { |
| 25 |
| 26 namespace { |
| 27 |
| 28 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop = |
| 29 LAZY_INSTANCE_INITIALIZER; |
| 30 |
| 31 LazyInstance<base::android::ScopedJavaGlobalRef<jobject>> g_main_activiy = |
| 32 LAZY_INSTANCE_INITIALIZER; |
| 33 |
| 34 void InitializeLogging() { |
| 35 logging::LoggingSettings settings; |
| 36 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 37 logging::InitLogging(settings); |
| 38 // To view log output with IDs and timestamps use "adb logcat -v threadtime". |
| 39 logging::SetLogItems(false, // Process ID |
| 40 false, // Thread ID |
| 41 false, // Timestamp |
| 42 false); // Tick count |
| 43 } |
| 44 |
| 45 } // namespace |
| 46 |
| 47 static void Init(JNIEnv* env, |
| 48 jclass clazz, |
| 49 jobject activity) { |
| 50 g_main_activiy.Get().Reset(env, activity); |
| 51 |
| 52 base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity); |
| 53 base::android::InitApplicationContext(env, scoped_activity); |
| 54 |
| 55 base::CommandLine::Init(0, nullptr); |
| 56 |
| 57 InitializeLogging(); |
| 58 |
| 59 g_java_message_loop.Get().reset(new base::MessageLoopForUI); |
| 60 base::MessageLoopForUI::current()->Start(); |
| 61 } |
| 62 |
| 63 static jboolean Start(JNIEnv* env, jclass clazz) { |
| 64 LOG(INFO) << "Native code started!"; |
| 65 return true; |
| 66 } |
| 67 |
| 68 bool RegisterSkyMain(JNIEnv* env) { |
| 69 return RegisterNativesImpl(env); |
| 70 } |
| 71 |
| 72 } // namespace sky |
| 73 } // namespace mojo |
OLD | NEW |