Chromium Code Reviews| 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 "blimp/client/android/blimp_library_loader.h" | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/android/base_jni_onload.h" | |
| 10 #include "base/android/jni_android.h" | |
| 11 #include "base/android/library_loader/library_loader_hooks.h" | |
| 12 #include "base/bind.h" | |
| 13 #include "base/lazy_instance.h" | |
| 14 #include "base/logging.h" | |
| 15 #include "base/message_loop/message_loop.h" | |
| 16 #include "blimp/client/android/blimp_jni_registrar.h" | |
| 17 #include "jni/BlimpLibraryLoader_jni.h" | |
| 18 #include "ui/gl/gl_surface.h" | |
| 19 | |
| 20 namespace { | |
| 21 | |
| 22 base::LazyInstance<scoped_ptr<base::MessageLoopForUI>> g_main_message_loop = | |
| 23 LAZY_INSTANCE_INITIALIZER; | |
| 24 | |
| 25 bool LibraryLoaded(JNIEnv* env, jclass clazz) { | |
|
Wez
2015/08/27 02:01:50
nit: OnLibraryLoaded
David Trainor- moved to gerrit
2015/09/03 06:33:21
Done.
| |
| 26 logging::LoggingSettings settings; | |
| 27 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | |
| 28 logging::InitLogging(settings); | |
| 29 // To view log output with IDs and timestamps use "adb logcat -v threadtime". | |
| 30 logging::SetLogItems(false, // Process ID | |
| 31 false, // Thread ID | |
| 32 false, // Timestamp | |
| 33 false); // Tick count | |
| 34 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() | |
| 35 << ", default verbosity = " << logging::GetVlogVerbosity(); | |
| 36 | |
| 37 return true; | |
| 38 } | |
| 39 | |
| 40 bool InitBlimp() { | |
| 41 base::android::SetLibraryLoadedHook(&LibraryLoaded); | |
| 42 return true; | |
| 43 } | |
| 44 | |
| 45 } // namespace | |
| 46 | |
| 47 namespace blimp { | |
| 48 | |
| 49 static jboolean InitializeBlimp(JNIEnv* env, jclass clazz, jobject jcontext) { | |
| 50 base::android::ScopedJavaLocalRef<jobject> scoped_jcontext(env, jcontext); | |
| 51 base::android::InitApplicationContext(env, scoped_jcontext); | |
| 52 | |
| 53 // TODO(dtrainor): Start the runner? | |
| 54 return true; | |
| 55 } | |
| 56 | |
| 57 static jboolean StartBlimp(JNIEnv* env, jclass clazz) { | |
| 58 // TODO(dtrainor): Initialize ICU? | |
| 59 | |
| 60 if (!gfx::GLSurface::InitializeOneOff()) | |
| 61 return false; | |
| 62 | |
| 63 g_main_message_loop.Get().reset(new base::MessageLoopForUI); | |
| 64 base::MessageLoopForUI::current()->Start(); | |
|
Wez
2015/08/27 02:01:50
So.. this is some fun hack around us not actually
David Trainor- moved to gerrit
2015/09/03 06:33:21
This is because the message loop is actually drive
| |
| 65 | |
| 66 return true; | |
| 67 } | |
| 68 | |
| 69 bool RegisterBlimpLibraryLoaderJni(JNIEnv* env) { | |
| 70 return RegisterNativesImpl(env); | |
| 71 } | |
| 72 | |
| 73 } // namespace blimp | |
| 74 | |
| 75 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | |
| 76 std::vector<base::android::RegisterCallback> register_callbacks; | |
| 77 register_callbacks.push_back(base::Bind(&blimp::RegisterBlimpJni)); | |
| 78 | |
| 79 std::vector<base::android::InitCallback> init_callbacks; | |
| 80 init_callbacks.push_back(base::Bind(&InitBlimp)); | |
| 81 | |
| 82 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) || | |
| 83 !base::android::OnJNIOnLoadInit(init_callbacks)) { | |
| 84 return -1; | |
| 85 } | |
| 86 | |
| 87 return JNI_VERSION_1_4; | |
| 88 } | |
| OLD | NEW |