Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <jni.h> | |
| 6 | |
| 7 #include "base/android/base_jni_registrar.h" | |
| 8 #include "base/android/jni_android.h" | |
| 9 #include "base/android/jni_registrar.h" | |
| 10 #include "components/cronet/android/cronet_loader.h" | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = { | |
| 15 {"BaseAndroid", base::android::RegisterJni}, | |
|
mmenke
2014/09/11 18:05:24
nit: 2 space indent.
| |
| 16 }; | |
| 17 | |
| 18 } // namespace | |
| 19 | |
| 20 // This is called by the VM when the shared library is first loaded. | |
| 21 // Checks the available version of JNI. Also, caches Java reflection artifacts. | |
| 22 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { | |
| 23 JNIEnv* env; | |
| 24 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { | |
|
mmenke
2014/09/11 18:05:24
This is already in CronetOnLoad. Should we duplic
mef
2014/09/11 18:37:54
This is needed to get env for the call to Register
mmenke
2014/09/11 18:54:41
Ah, right...This is fine. I hadn't realized we we
| |
| 25 return -1; | |
| 26 } | |
| 27 | |
| 28 jint cronet_onload = cronet::CronetOnLoad(vm, reserved); | |
| 29 if (cronet_onload == -1) | |
| 30 return cronet_onload; | |
| 31 | |
| 32 if (!base::android::RegisterNativeMethods( | |
| 33 env, | |
| 34 kCronetTestsRegisteredMethods, | |
| 35 arraysize(kCronetTestsRegisteredMethods))) { | |
| 36 return -1; | |
| 37 } | |
| 38 return cronet_onload; | |
| 39 } | |
| 40 | |
| 41 extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM* vm, void* reserved) { | |
| 42 cronet::CronetOnUnLoad(vm, reserved); | |
| 43 } | |
| 44 | |
| OLD | NEW |