| 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..88b2b8cf62041c896430ff1f6fec29f811d68fd1
|
| --- /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 JNI_OnUnLoad(JavaVM* vm, void* reserved) {
|
| + cronet::CronetOnUnLoad(vm, reserved);
|
| +}
|
| +
|
|
|