Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: components/cronet/android/cronet_jni.cc

Issue 560153002: Add Cronet Test App that uses libcronet_tests.so with net test utilities. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove JNIEXPORT from JNI_OnUnload. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/cronet.gypi ('k') | components/cronet/android/cronet_loader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/android/base_jni_registrar.h" 5 #include "components/cronet/android/cronet_loader.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"
13 #include "url/url_util.h"
14 6
15 #if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID) 7 // This is called by the VM when the shared library is first loaded.
16 #include "base/i18n/icu_util.h"
17 #endif
18
19 namespace {
20
21 const base::android::RegistrationMethod kCronetRegisteredMethods[] = {
22 {"BaseAndroid", base::android::RegisterJni},
23 {"ChromiumUrlRequest", cronet::ChromiumUrlRequestRegisterJni},
24 {"ChromiumUrlRequestContext", cronet::ChromiumUrlRequestContextRegisterJni},
25 {"NetAndroid", net::android::RegisterJni},
26 {"UrlAndroid", url::android::RegisterJni},
27 };
28
29 base::AtExitManager* g_at_exit_manager = NULL;
30
31 } // namespace
32
33 // Checks the available version of JNI. Also, caches Java reflection artifacts.
34 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { 8 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) {
35 JNIEnv* env; 9 return cronet::CronetOnLoad(vm, reserved);
36 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
37 return -1;
38 }
39
40 base::android::InitVM(vm);
41
42 if (!base::android::RegisterNativeMethods(
43 env, kCronetRegisteredMethods, arraysize(kCronetRegisteredMethods))) {
44 return -1;
45 }
46
47 g_at_exit_manager = new base::AtExitManager();
48
49 #if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID)
50 base::i18n::InitializeICU();
51 #endif
52
53 url::Initialize();
54
55 return JNI_VERSION_1_6;
56 } 10 }
57 11
58 extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM* jvm, void* reserved) { 12 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) {
59 if (g_at_exit_manager) { 13 cronet::CronetOnUnLoad(vm, reserved);
60 delete g_at_exit_manager;
61 g_at_exit_manager = NULL;
62 }
63 } 14 }
64 15
OLDNEW
« no previous file with comments | « components/cronet.gypi ('k') | components/cronet/android/cronet_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698