Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: blimp/client/android/blimp_library_loader.cc

Issue 1551683002: [Blimp Client] Land CL 1528243002 (Add a basic linux client for Blimp) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "blimp/client/android/blimp_library_loader.h" 5 #include "blimp/client/android/blimp_library_loader.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/android/base_jni_onload.h" 9 #include "base/android/base_jni_onload.h"
10 #include "base/android/base_jni_registrar.h" 10 #include "base/android/base_jni_registrar.h"
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/android/library_loader/library_loader_hooks.h" 12 #include "base/android/library_loader/library_loader_hooks.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/lazy_instance.h"
15 #include "base/logging.h"
16 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
17 #include "blimp/client/android/blimp_jni_registrar.h" 15 #include "blimp/client/android/blimp_jni_registrar.h"
16 #include "blimp/client/blimp_startup.h"
18 #include "jni/BlimpLibraryLoader_jni.h" 17 #include "jni/BlimpLibraryLoader_jni.h"
19 #include "ui/gl/gl_surface.h" 18 #include "ui/gl/gl_surface.h"
20 19
21 namespace { 20 namespace {
22 21
23 base::LazyInstance<scoped_ptr<base::MessageLoopForUI>> g_main_message_loop =
24 LAZY_INSTANCE_INITIALIZER;
25
26 bool OnLibrariesLoaded(JNIEnv* env, jclass clazz) { 22 bool OnLibrariesLoaded(JNIEnv* env, jclass clazz) {
27 logging::LoggingSettings settings; 23 blimp::InitializeLogging();
28 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
29 logging::InitLogging(settings);
30
31 // Disable process info prefixes on log lines. These can be obtained via "adb
32 // logcat -v threadtime".
33 logging::SetLogItems(false, // Process ID
34 false, // Thread ID
35 false, // Timestamp
36 false); // Tick count
37 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
38 << ", default verbosity = " << logging::GetVlogVerbosity();
39
40 return true; 24 return true;
41 } 25 }
42 26
43 bool OnJniInitializationComplete() { 27 bool OnJniInitializationComplete() {
44 base::android::SetLibraryLoadedHook(&OnLibrariesLoaded); 28 base::android::SetLibraryLoadedHook(&OnLibrariesLoaded);
45 return true; 29 return true;
46 } 30 }
47 31
48 bool RegisterJni(JNIEnv* env) { 32 bool RegisterJni(JNIEnv* env) {
49 if (!base::android::RegisterJni(env)) 33 if (!base::android::RegisterJni(env))
50 return false; 34 return false;
51 35
52 if (!blimp::RegisterBlimpJni(env)) 36 if (!blimp::RegisterBlimpJni(env))
53 return false; 37 return false;
54 38
55 return true; 39 return true;
56 } 40 }
57 41
58 } // namespace 42 } // namespace
59 43
60 namespace blimp { 44 namespace blimp {
61 45
62 static jboolean InitializeBlimp(JNIEnv* env,
63 const JavaParamRef<jclass>& clazz) {
64 // TODO(dtrainor): Start the runner?
65 return true;
66 }
67
68 static jboolean StartBlimp(JNIEnv* env, const JavaParamRef<jclass>& clazz) { 46 static jboolean StartBlimp(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
69 // TODO(dtrainor): Initialize ICU? 47 if (!blimp::InitializeMainMessageLoop())
70
71 if (!gfx::GLSurface::InitializeOneOff())
72 return false; 48 return false;
73 49
74 g_main_message_loop.Get().reset(new base::MessageLoopForUI);
75 base::MessageLoopForUI::current()->Start(); 50 base::MessageLoopForUI::current()->Start();
76 51
77 return true; 52 return true;
78 } 53 }
79 54
80 bool RegisterBlimpLibraryLoaderJni(JNIEnv* env) { 55 bool RegisterBlimpLibraryLoaderJni(JNIEnv* env) {
81 return RegisterNativesImpl(env); 56 return RegisterNativesImpl(env);
82 } 57 }
83 58
84 } // namespace blimp 59 } // namespace blimp
85 60
86 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { 61 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
87 std::vector<base::android::RegisterCallback> register_callbacks; 62 std::vector<base::android::RegisterCallback> register_callbacks;
88 register_callbacks.push_back(base::Bind(&RegisterJni)); 63 register_callbacks.push_back(base::Bind(&RegisterJni));
89 64
90 std::vector<base::android::InitCallback> init_callbacks; 65 std::vector<base::android::InitCallback> init_callbacks;
91 init_callbacks.push_back(base::Bind(&OnJniInitializationComplete)); 66 init_callbacks.push_back(base::Bind(&OnJniInitializationComplete));
92 67
93 // Although we only need to register JNI for base/ and blimp/, this follows 68 // Although we only need to register JNI for base/ and blimp/, this follows
94 // the general Chrome for Android pattern, to be future-proof against future 69 // the general Chrome for Android pattern, to be future-proof against future
95 // changes to JNI. 70 // changes to JNI.
96 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) || 71 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
97 !base::android::OnJNIOnLoadInit(init_callbacks)) { 72 !base::android::OnJNIOnLoadInit(init_callbacks)) {
98 return -1; 73 return -1;
99 } 74 }
100 75
101 return JNI_VERSION_1_4; 76 return JNI_VERSION_1_4;
102 } 77 }
OLDNEW
« no previous file with comments | « blimp/client/DEPS ('k') | blimp/client/android/java/src/org/chromium/blimp/BlimpLibraryLoader.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698