blob: e6a009f51a9d379329c73241c4f3af0ac7cca93e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "blimp/client/app/android/blimp_library_loader.h"
#include <vector>
#include "base/android/base_jni_onload.h"
#include "base/android/base_jni_registrar.h"
#include "base/android/jni_android.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "blimp/client/app/android/blimp_jni_registrar.h"
#include "blimp/client/app/blimp_startup.h"
#include "jni/BlimpLibraryLoader_jni.h"
#include "ui/gl/gl_surface.h"
namespace {
bool OnLibrariesLoaded(JNIEnv* env, jclass clazz) {
blimp::client::InitializeLogging();
return true;
}
bool OnJniInitializationComplete() {
base::android::SetLibraryLoadedHook(&OnLibrariesLoaded);
return true;
}
bool RegisterJni(JNIEnv* env) {
if (!base::android::RegisterJni(env))
return false;
if (!blimp::client::RegisterBlimpJni(env))
return false;
return true;
}
} // namespace
namespace blimp {
namespace client {
static jboolean StartBlimp(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
if (!InitializeMainMessageLoop())
return false;
base::MessageLoopForUI::current()->Start();
return true;
}
bool RegisterBlimpLibraryLoaderJni(JNIEnv* env) {
return RegisterNativesImpl(env);
}
} // namespace client
} // namespace blimp
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
std::vector<base::android::RegisterCallback> register_callbacks;
register_callbacks.push_back(base::Bind(&RegisterJni));
std::vector<base::android::InitCallback> init_callbacks;
init_callbacks.push_back(base::Bind(&OnJniInitializationComplete));
// Although we only need to register JNI for base/ and blimp/, this follows
// the general Chrome for Android pattern, to be future-proof against future
// changes to JNI.
if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
!base::android::OnJNIOnLoadInit(init_callbacks)) {
return -1;
}
return JNI_VERSION_1_4;
}
|