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_onload_delegate.h"
9 #include "base/android/library_loader/library_loader_hooks.h"
16 // The JNIOnLoadDelegate implementation in base.
17 class BaseJNIOnLoadDelegate
: public JNIOnLoadDelegate
{
19 bool RegisterJNI(JNIEnv
* env
) override
;
23 bool BaseJNIOnLoadDelegate::RegisterJNI(JNIEnv
* env
) {
24 return RegisterLibraryLoaderEntryHook(env
);
27 bool BaseJNIOnLoadDelegate::Init() {
34 bool OnJNIOnLoad(JavaVM
* vm
,
35 std::vector
<JNIOnLoadDelegate
*>* delegates
) {
36 base::android::InitVM(vm
);
37 JNIEnv
* env
= base::android::AttachCurrentThread();
39 BaseJNIOnLoadDelegate delegate
;
40 delegates
->push_back(&delegate
);
42 for (std::vector
<JNIOnLoadDelegate
*>::reverse_iterator i
=
43 delegates
->rbegin(); i
!= delegates
->rend(); ++i
) {
44 if (!(*i
)->RegisterJNI(env
)) {
51 for (std::vector
<JNIOnLoadDelegate
*>::reverse_iterator i
=
52 delegates
->rbegin(); i
!= delegates
->rend(); ++i
) {
59 delegates
->pop_back();
63 } // namespace android