OLD | NEW |
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 "base/android/base_jni_onload.h" | 5 #include "base/android/base_jni_onload.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_onload_delegate.h" | 8 #include "base/android/jni_onload_delegate.h" |
| 9 #include "base/android/jni_utils.h" |
9 #include "base/android/library_loader/library_loader_hooks.h" | 10 #include "base/android/library_loader/library_loader_hooks.h" |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 namespace android { | 13 namespace android { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 // The JNIOnLoadDelegate implementation in base. | 17 // The JNIOnLoadDelegate implementation in base. |
17 class BaseJNIOnLoadDelegate : public JNIOnLoadDelegate { | 18 class BaseJNIOnLoadDelegate : public JNIOnLoadDelegate { |
18 public: | 19 public: |
19 bool RegisterJNI(JNIEnv* env) override; | 20 bool RegisterJNI(JNIEnv* env) override; |
20 bool Init() override; | 21 bool Init() override; |
21 }; | 22 }; |
22 | 23 |
23 bool BaseJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) { | 24 bool BaseJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) { |
24 return RegisterLibraryLoaderEntryHook(env); | 25 return RegisterLibraryLoaderEntryHook(env); |
25 } | 26 } |
26 | 27 |
27 bool BaseJNIOnLoadDelegate::Init() { | 28 bool BaseJNIOnLoadDelegate::Init() { |
| 29 JNIEnv* env = base::android::AttachCurrentThread(); |
| 30 |
| 31 base::android::InitReplacementClassLoader(env, |
| 32 base::android::GetClassLoader(env)); |
| 33 |
28 return true; | 34 return true; |
29 } | 35 } |
30 | 36 |
31 } // namespace | 37 } // namespace |
32 | 38 |
33 | 39 |
34 bool OnJNIOnLoad(JavaVM* vm, | 40 bool OnJNIOnLoad(JavaVM* vm, |
35 std::vector<JNIOnLoadDelegate*>* delegates) { | 41 std::vector<JNIOnLoadDelegate*>* delegates) { |
36 base::android::InitVM(vm); | 42 base::android::InitVM(vm); |
37 JNIEnv* env = base::android::AttachCurrentThread(); | 43 JNIEnv* env = base::android::AttachCurrentThread(); |
(...skipping 17 matching lines...) Expand all Loading... |
55 break; | 61 break; |
56 } | 62 } |
57 } | 63 } |
58 } | 64 } |
59 delegates->pop_back(); | 65 delegates->pop_back(); |
60 return ret; | 66 return ret; |
61 } | 67 } |
62 | 68 |
63 } // namespace android | 69 } // namespace android |
64 } // namespace base | 70 } // namespace base |
OLD | NEW |