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.
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"
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
},
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
) {
36 if (vm
->GetEnv(reinterpret_cast<void**>(&env
), JNI_VERSION_1_6
) != JNI_OK
) {
40 jint cronet_onload
= cronet::CronetOnLoad(vm
, reserved
);
41 if (cronet_onload
== -1)
44 if (!base::android::RegisterNativeMethods(
46 kCronetTestsRegisteredMethods
,
47 arraysize(kCronetTestsRegisteredMethods
))) {
53 extern "C" void JNI_OnUnLoad(JavaVM
* vm
, void* reserved
) {
54 cronet::CronetOnUnLoad(vm
, reserved
);