Chromium Code Reviews| Index: components/cronet/android/test/cronet_tests_jni.cc | 
| diff --git a/components/cronet/android/test/cronet_tests_jni.cc b/components/cronet/android/test/cronet_tests_jni.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..0e3ac5a2b5c9be5b122c0833b8b3418b7afc6d8f | 
| --- /dev/null | 
| +++ b/components/cronet/android/test/cronet_tests_jni.cc | 
| @@ -0,0 +1,44 @@ | 
| +// Copyright 2014 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#include <jni.h> | 
| + | 
| +#include "base/android/base_jni_registrar.h" | 
| +#include "base/android/jni_android.h" | 
| +#include "base/android/jni_registrar.h" | 
| +#include "components/cronet/android/cronet_loader.h" | 
| + | 
| +namespace { | 
| + | 
| +const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = { | 
| + {"BaseAndroid", base::android::RegisterJni}, | 
| 
 
mmenke
2014/09/11 18:05:24
nit: 2 space indent.
 
 | 
| +}; | 
| + | 
| +} // namespace | 
| + | 
| +// This is called by the VM when the shared library is first loaded. | 
| +// Checks the available version of JNI. Also, caches Java reflection artifacts. | 
| +extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 
| + JNIEnv* env; | 
| + 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
 
 | 
| + return -1; | 
| + } | 
| + | 
| + jint cronet_onload = cronet::CronetOnLoad(vm, reserved); | 
| + if (cronet_onload == -1) | 
| + return cronet_onload; | 
| + | 
| + if (!base::android::RegisterNativeMethods( | 
| + env, | 
| + kCronetTestsRegisteredMethods, | 
| + arraysize(kCronetTestsRegisteredMethods))) { | 
| + return -1; | 
| + } | 
| + return cronet_onload; | 
| +} | 
| + | 
| +extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM* vm, void* reserved) { | 
| + cronet::CronetOnUnLoad(vm, reserved); | 
| +} | 
| + |