| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <jni.h> | 5 #include <jni.h> |
| 6 | 6 |
| 7 #include "base/android/base_jni_registrar.h" | 7 #include "base/android/base_jni_registrar.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_registrar.h" | 9 #include "base/android/jni_registrar.h" |
| 10 #include "components/cronet/android/cronet_library_loader.h" | 10 #include "components/cronet/android/cronet_library_loader.h" |
| 11 #include "mock_url_request_job_factory.h" | 11 #include "mock_url_request_job_factory.h" |
| 12 #include "native_test_server.h" | 12 #include "native_test_server.h" |
| 13 #include "network_change_notifier_util.h" | 13 #include "network_change_notifier_util.h" |
| 14 #include "test_upload_data_stream_handler.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = { | 18 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = { |
| 18 {"MockUrlRequestJobFactory", cronet::RegisterMockUrlRequestJobFactory}, | 19 {"MockUrlRequestJobFactory", cronet::RegisterMockUrlRequestJobFactory}, |
| 19 {"RegisterNativeTestServer", cronet::RegisterNativeTestServer}, | 20 {"RegisterNativeTestServer", cronet::RegisterNativeTestServer}, |
| 20 {"NetworkChangeNotifierUtil", cronet::RegisterNetworkChangeNotifierUtil}, | 21 {"NetworkChangeNotifierUtil", cronet::RegisterNetworkChangeNotifierUtil}, |
| 22 {"TestUploadDataStreamHandlerRegisterJni", |
| 23 cronet::TestUploadDataStreamHandlerRegisterJni}, |
| 21 }; | 24 }; |
| 22 | 25 |
| 23 } // namespace | 26 } // namespace |
| 24 | 27 |
| 25 // This is called by the VM when the shared library is first loaded. | 28 // This is called by the VM when the shared library is first loaded. |
| 26 // Checks the available version of JNI. Also, caches Java reflection artifacts. | 29 // Checks the available version of JNI. Also, caches Java reflection artifacts. |
| 27 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 30 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| 28 JNIEnv* env; | 31 JNIEnv* env; |
| 29 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { | 32 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { |
| 30 return -1; | 33 return -1; |
| 31 } | 34 } |
| 32 | 35 |
| 33 jint cronet_onload = cronet::CronetOnLoad(vm, reserved); | 36 jint cronet_onload = cronet::CronetOnLoad(vm, reserved); |
| 34 if (cronet_onload == -1) | 37 if (cronet_onload == -1) |
| 35 return cronet_onload; | 38 return cronet_onload; |
| 36 | 39 |
| 37 if (!base::android::RegisterNativeMethods( | 40 if (!base::android::RegisterNativeMethods( |
| 38 env, | 41 env, |
| 39 kCronetTestsRegisteredMethods, | 42 kCronetTestsRegisteredMethods, |
| 40 arraysize(kCronetTestsRegisteredMethods))) { | 43 arraysize(kCronetTestsRegisteredMethods))) { |
| 41 return -1; | 44 return -1; |
| 42 } | 45 } |
| 43 return cronet_onload; | 46 return cronet_onload; |
| 44 } | 47 } |
| 45 | 48 |
| 46 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) { | 49 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) { |
| 47 cronet::CronetOnUnLoad(vm, reserved); | 50 cronet::CronetOnUnLoad(vm, reserved); |
| 48 } | 51 } |
| 49 | 52 |
| OLD | NEW |