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

Unified Diff: components/cronet/android/cronet_library_loader.cc

Issue 2620303004: Remove JNI onload callback vector construction in favour of direct calls. (Closed)
Patch Set: rebase compile errors Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/app/android/cast_jni_loader.cc ('k') | components/cronet/android/test/cronet_test_jni.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/cronet_library_loader.cc
diff --git a/components/cronet/android/cronet_library_loader.cc b/components/cronet/android/cronet_library_loader.cc
index 607df9cac398744d0984a782d254439432a58984..6d4d11730c8c0cd7adb5e4f8711007a5841d9e15 100644
--- a/components/cronet/android/cronet_library_loader.cc
+++ b/components/cronet/android/cronet_library_loader.cc
@@ -63,7 +63,9 @@ bool RegisterJNI(JNIEnv* env) {
env, kCronetRegisteredMethods, arraysize(kCronetRegisteredMethods));
}
-bool Init() {
+bool NativeInit() {
+ if (!base::android::OnJNIOnLoadInit())
+ return false;
url::Initialize();
return true;
}
@@ -72,12 +74,10 @@ bool Init() {
// Checks the available version of JNI. Also, caches Java reflection artifacts.
jint CronetOnLoad(JavaVM* vm, void* reserved) {
- std::vector<base::android::RegisterCallback> register_callbacks;
- register_callbacks.push_back(base::Bind(&RegisterJNI));
- std::vector<base::android::InitCallback> init_callbacks;
- init_callbacks.push_back(base::Bind(&Init));
- if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
- !base::android::OnJNIOnLoadInit(init_callbacks)) {
+ base::android::InitVM(vm);
+ JNIEnv* env = base::android::AttachCurrentThread();
+ if (!base::android::OnJNIOnLoadRegisterJNI(env) || !RegisterJNI(env) ||
+ !NativeInit()) {
return -1;
}
return JNI_VERSION_1_6;
« no previous file with comments | « chromecast/app/android/cast_jni_loader.cc ('k') | components/cronet/android/test/cronet_test_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698