Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: components/cronet/android/test/cronet_test_jni.cc

Issue 2620303004: Remove JNI onload callback vector construction in favour of direct calls. (Closed)
Patch Set: rebase compile errors Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698