Remove obsolete entries from .gitignore.
[chromium-blink-merge.git] / components / cronet / android / test / cronet_test_jni.cc
bloba487bf2e2ca40892e8d62fd48c32beb75721c44e
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 "sdch_test_util.h"
16 #include "test_upload_data_stream_handler.h"
18 namespace {
20 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = {
21 {"MockUrlRequestJobFactory", cronet::RegisterMockUrlRequestJobFactory},
22 {"NativeTestServer", cronet::RegisterNativeTestServer},
23 {"NetworkChangeNotifierUtil", cronet::RegisterNetworkChangeNotifierUtil},
24 {"QuicTestServer", cronet::RegisterQuicTestServer},
25 {"SdchTestUtil", cronet::RegisterSdchTestUtil},
26 {"TestUploadDataStreamHandlerRegisterJni",
27 cronet::TestUploadDataStreamHandlerRegisterJni},
30 } // namespace
32 // This is called by the VM when the shared library is first loaded.
33 // Checks the available version of JNI. Also, caches Java reflection artifacts.
34 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) {
35 JNIEnv* env;
36 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
37 return -1;
40 jint cronet_onload = cronet::CronetOnLoad(vm, reserved);
41 if (cronet_onload == -1)
42 return cronet_onload;
44 if (!base::android::RegisterNativeMethods(
45 env,
46 kCronetTestsRegisteredMethods,
47 arraysize(kCronetTestsRegisteredMethods))) {
48 return -1;
50 return cronet_onload;
53 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) {
54 cronet::CronetOnUnLoad(vm, reserved);