ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / base / android / base_jni_onload.cc
blobc3a65d40cb1740eb5c784fb9441aa130cbdd7819
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.
5 #include "base/android/base_jni_onload.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_utils.h"
9 #include "base/android/library_loader/library_loader_hooks.h"
10 #include "base/bind.h"
12 namespace base {
13 namespace android {
15 namespace {
17 bool RegisterJNI(JNIEnv* env) {
18 return RegisterLibraryLoaderEntryHook(env);
21 bool Init() {
22 JNIEnv* env = base::android::AttachCurrentThread();
23 base::android::InitReplacementClassLoader(env,
24 base::android::GetClassLoader(env));
25 return true;
28 } // namespace
31 bool OnJNIOnLoadRegisterJNI(JavaVM* vm,
32 std::vector<RegisterCallback> callbacks) {
33 base::android::InitVM(vm);
34 JNIEnv* env = base::android::AttachCurrentThread();
36 callbacks.push_back(base::Bind(&RegisterJNI));
37 for (std::vector<RegisterCallback>::reverse_iterator i =
38 callbacks.rbegin(); i != callbacks.rend(); ++i) {
39 if (!i->Run(env))
40 return false;
42 return true;
45 bool OnJNIOnLoadInit(std::vector<InitCallback> callbacks) {
46 callbacks.push_back(base::Bind(&Init));
47 for (std::vector<InitCallback>::reverse_iterator i =
48 callbacks.rbegin(); i != callbacks.rend(); ++i) {
49 if (!i->Run())
50 return false;
52 return true;
55 } // namespace android
56 } // namespace base