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 "test_upload_data_stream_handler.h"
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
},
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
) {
34 if (vm
->GetEnv(reinterpret_cast<void**>(&env
), JNI_VERSION_1_6
) != JNI_OK
) {
38 jint cronet_onload
= cronet::CronetOnLoad(vm
, reserved
);
39 if (cronet_onload
== -1)
42 if (!base::android::RegisterNativeMethods(
44 kCronetTestsRegisteredMethods
,
45 arraysize(kCronetTestsRegisteredMethods
))) {
51 extern "C" void JNI_OnUnLoad(JavaVM
* vm
, void* reserved
) {
52 cronet::CronetOnUnLoad(vm
, reserved
);