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 "base/android/base_jni_registrar.h"
6 #include "base/android/jni_android.h"
7 #include "base/android/jni_registrar.h"
8 #include "base/at_exit.h"
9 #include "components/cronet/android/chromium_url_request.h"
10 #include "components/cronet/android/chromium_url_request_context.h"
11 #include "net/android/net_jni_registrar.h"
12 #include "url/android/url_jni_registrar.h"
14 #if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID)
15 #include "base/i18n/icu_util.h"
20 const base::android::RegistrationMethod kCronetRegisteredMethods
[] = {
21 {"BaseAndroid", base::android::RegisterJni
},
22 {"ChromiumUrlRequest", cronet::ChromiumUrlRequestRegisterJni
},
23 {"ChromiumUrlRequestContext", cronet::ChromiumUrlRequestContextRegisterJni
},
24 {"NetAndroid", net::android::RegisterJni
},
25 {"UrlAndroid", url::android::RegisterJni
},
28 base::AtExitManager
* g_at_exit_manager
= NULL
;
32 // Checks the available version of JNI. Also, caches Java reflection artifacts.
33 extern "C" jint
JNI_OnLoad(JavaVM
* vm
, void* reserved
) {
35 if (vm
->GetEnv(reinterpret_cast<void**>(&env
), JNI_VERSION_1_6
) != JNI_OK
) {
39 base::android::InitVM(vm
);
41 if (!base::android::RegisterNativeMethods(
42 env
, kCronetRegisteredMethods
, arraysize(kCronetRegisteredMethods
))) {
46 g_at_exit_manager
= new base::AtExitManager();
48 #if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID)
49 base::i18n::InitializeICU();
52 return JNI_VERSION_1_6
;
55 extern "C" void JNIEXPORT JNICALL
JNI_OnUnLoad(JavaVM
* jvm
, void* reserved
) {
56 if (g_at_exit_manager
) {
57 delete g_at_exit_manager
;
58 g_at_exit_manager
= NULL
;