Make castv2 performance test work.
[chromium-blink-merge.git] / components / cronet / android / test / cronet_test_jni.cc
blob73649699458e8ce5f00ffed5a6ec6da5623a03ed
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.
5 #include <jni.h>
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_library_loader.h"
11 #include "mock_url_request_job_factory.h"
12 #include "native_test_server.h"
13 #include "network_change_notifier_util.h"
14 #include "quic_test_server.h"
15 #include "test_upload_data_stream_handler.h"
17 namespace {
19 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = {
20 {"MockUrlRequestJobFactory", cronet::RegisterMockUrlRequestJobFactory},
21 {"NativeTestServer", cronet::RegisterNativeTestServer},
22 {"QuicTestServer", cronet::RegisterQuicTestServer},
23 {"NetworkChangeNotifierUtil", cronet::RegisterNetworkChangeNotifierUtil},
24 {"TestUploadDataStreamHandlerRegisterJni",
25 cronet::TestUploadDataStreamHandlerRegisterJni},
28 } // namespace
30 // This is called by the VM when the shared library is first loaded.
31 // Checks the available version of JNI. Also, caches Java reflection artifacts.
32 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) {
33 JNIEnv* env;
34 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
35 return -1;
38 jint cronet_onload = cronet::CronetOnLoad(vm, reserved);
39 if (cronet_onload == -1)
40 return cronet_onload;
42 if (!base::android::RegisterNativeMethods(
43 env,
44 kCronetTestsRegisteredMethods,
45 arraysize(kCronetTestsRegisteredMethods))) {
46 return -1;
48 return cronet_onload;
51 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) {
52 cronet::CronetOnUnLoad(vm, reserved);