| 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_onload.h" | 7 #include "base/android/base_jni_onload.h" |
| 8 #include "base/android/base_jni_registrar.h" | 8 #include "base/android/base_jni_registrar.h" |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_registrar.h" | 10 #include "base/android/jni_registrar.h" |
| 11 #include "base/android/library_loader/library_loader_hooks.h" | 11 #include "base/android/library_loader/library_loader_hooks.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "cronet_test_util.h" | 13 #include "cronet_test_util.h" |
| 14 #include "cronet_url_request_context_config_test.h" | 14 #include "cronet_url_request_context_config_test.h" |
| 15 #include "experimental_options_test.h" |
| 15 #include "mock_cert_verifier.h" | 16 #include "mock_cert_verifier.h" |
| 16 #include "mock_url_request_job_factory.h" | 17 #include "mock_url_request_job_factory.h" |
| 17 #include "native_test_server.h" | 18 #include "native_test_server.h" |
| 18 #include "quic_test_server.h" | 19 #include "quic_test_server.h" |
| 19 #include "sdch_test_util.h" | 20 #include "sdch_test_util.h" |
| 20 #include "test_upload_data_stream_handler.h" | 21 #include "test_upload_data_stream_handler.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = { | 25 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = { |
| 25 {"MockCertVerifier", cronet::RegisterMockCertVerifier}, | 26 {"MockCertVerifier", cronet::RegisterMockCertVerifier}, |
| 26 {"MockUrlRequestJobFactory", cronet::RegisterMockUrlRequestJobFactory}, | 27 {"MockUrlRequestJobFactory", cronet::RegisterMockUrlRequestJobFactory}, |
| 27 {"NativeTestServer", cronet::RegisterNativeTestServer}, | 28 {"NativeTestServer", cronet::RegisterNativeTestServer}, |
| 28 {"QuicTestServer", cronet::RegisterQuicTestServer}, | 29 {"QuicTestServer", cronet::RegisterQuicTestServer}, |
| 29 {"SdchTestUtil", cronet::RegisterSdchTestUtil}, | 30 {"SdchTestUtil", cronet::RegisterSdchTestUtil}, |
| 30 {"TestUploadDataStreamHandlerRegisterJni", | 31 {"TestUploadDataStreamHandlerRegisterJni", |
| 31 cronet::TestUploadDataStreamHandlerRegisterJni}, | 32 cronet::TestUploadDataStreamHandlerRegisterJni}, |
| 32 {"CronetUrlRequestContextConfigTest", | 33 {"CronetUrlRequestContextConfigTest", |
| 33 cronet::RegisterCronetUrlRequestContextConfigTest}, | 34 cronet::RegisterCronetUrlRequestContextConfigTest}, |
| 35 {"ExperimentalOptionsTest", cronet::RegisterExperimentalOptionsTest}, |
| 34 {"CronetTestUtil", cronet::TestUtil::Register}, | 36 {"CronetTestUtil", cronet::TestUtil::Register}, |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 } // namespace | 39 } // namespace |
| 38 | 40 |
| 39 // This is called by the VM when the shared library is first loaded. | 41 // This is called by the VM when the shared library is first loaded. |
| 40 // Checks the available version of JNI. Also, caches Java reflection artifacts. | 42 // Checks the available version of JNI. Also, caches Java reflection artifacts. |
| 41 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 43 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| 42 base::android::InitVM(vm); | 44 base::android::InitVM(vm); |
| 43 JNIEnv* env = base::android::AttachCurrentThread(); | 45 JNIEnv* env = base::android::AttachCurrentThread(); |
| 44 if (!base::android::OnJNIOnLoadInit()) { | 46 if (!base::android::OnJNIOnLoadInit()) { |
| 45 return -1; | 47 return -1; |
| 46 } | 48 } |
| 47 | 49 |
| 48 if (!base::android::RegisterNativeMethods( | 50 if (!base::android::RegisterNativeMethods( |
| 49 env, | 51 env, |
| 50 kCronetTestsRegisteredMethods, | 52 kCronetTestsRegisteredMethods, |
| 51 arraysize(kCronetTestsRegisteredMethods))) { | 53 arraysize(kCronetTestsRegisteredMethods))) { |
| 52 return -1; | 54 return -1; |
| 53 } | 55 } |
| 54 return JNI_VERSION_1_6; | 56 return JNI_VERSION_1_6; |
| 55 } | 57 } |
| 56 | 58 |
| 57 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) { | 59 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) { |
| 58 base::android::LibraryLoaderExitHook(); | 60 base::android::LibraryLoaderExitHook(); |
| 59 } | 61 } |
| OLD | NEW |