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..354ef9ab85e49e8a28bc29f12991e2f58ee32cd4 | 
| --- /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}, | 
| +}; | 
| + | 
| +} // 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) { | 
| + 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) { | 
| 
 
xunjieli
2014/09/11 22:36:22
I think JNIEXPORT and JNICALL are not defined in c
 
xunjieli
2014/09/12 13:46:19
I still have one question about JNIEXPORT and JNI_
 
mef
2014/09/12 13:54:30
I think you are right and  JNIEXPORT JNICALL are n
 
mef
2014/09/12 13:59:22
Done.
 
 | 
| + cronet::CronetOnUnLoad(vm, reserved); | 
| +} | 
| + |