OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <jni.h> | 5 #include <jni.h> |
6 | 6 |
7 #include "base/android/base_jni_onload.h" | 7 #include "base/android/base_jni_onload.h" |
8 #include "base/android/base_jni_registrar.h" | 8 #include "base/android/base_jni_registrar.h" |
9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 {"CronetUrlRequestContextConfigTest", | 34 {"CronetUrlRequestContextConfigTest", |
35 cronet::RegisterCronetUrlRequestContextConfigTest}, | 35 cronet::RegisterCronetUrlRequestContextConfigTest}, |
36 {"CronetTestUtil", cronet::TestUtil::Register}, | 36 {"CronetTestUtil", cronet::TestUtil::Register}, |
37 }; | 37 }; |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 // This is called by the VM when the shared library is first loaded. | 41 // This is called by the VM when the shared library is first loaded. |
42 // Checks the available version of JNI. Also, caches Java reflection artifacts. | 42 // Checks the available version of JNI. Also, caches Java reflection artifacts. |
43 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 43 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
44 JNIEnv* env; | 44 base::android::InitVM(vm); |
45 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { | 45 JNIEnv* env = base::android::AttachCurrentThread(); |
| 46 if (!base::android::OnJNIOnLoadRegisterJNI(env) || |
| 47 !base::android::OnJNIOnLoadInit()) { |
46 return -1; | 48 return -1; |
47 } | 49 } |
48 | 50 |
49 std::vector<base::android::RegisterCallback> register_callbacks; | |
50 std::vector<base::android::InitCallback> init_callbacks; | |
51 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) || | |
52 !base::android::OnJNIOnLoadInit(init_callbacks)) { | |
53 return -1; | |
54 } | |
55 | |
56 if (!base::android::RegisterNativeMethods( | 51 if (!base::android::RegisterNativeMethods( |
57 env, | 52 env, |
58 kCronetTestsRegisteredMethods, | 53 kCronetTestsRegisteredMethods, |
59 arraysize(kCronetTestsRegisteredMethods))) { | 54 arraysize(kCronetTestsRegisteredMethods))) { |
60 return -1; | 55 return -1; |
61 } | 56 } |
62 return JNI_VERSION_1_6; | 57 return JNI_VERSION_1_6; |
63 } | 58 } |
64 | 59 |
65 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) { | 60 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) { |
66 base::android::LibraryLoaderExitHook(); | 61 base::android::LibraryLoaderExitHook(); |
67 } | 62 } |
68 | |
OLD | NEW |