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

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

Issue 1407233017: Define a Java-side global application context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo changes to ApplicationStatus Created 5 years, 1 month 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
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 "components/cronet/android/cronet_library_loader.h" 5 #include "components/cronet/android/cronet_library_loader.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/base_jni_onload.h" 9 #include "base/android/base_jni_onload.h"
10 #include "base/android/base_jni_registrar.h" 10 #include "base/android/base_jni_registrar.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 !base::android::OnJNIOnLoadInit(init_callbacks)) { 79 !base::android::OnJNIOnLoadInit(init_callbacks)) {
80 return -1; 80 return -1;
81 } 81 }
82 return JNI_VERSION_1_6; 82 return JNI_VERSION_1_6;
83 } 83 }
84 84
85 void CronetOnUnLoad(JavaVM* jvm, void* reserved) { 85 void CronetOnUnLoad(JavaVM* jvm, void* reserved) {
86 base::android::LibraryLoaderExitHook(); 86 base::android::LibraryLoaderExitHook();
87 } 87 }
88 88
89 void CronetInitApplicationContext(JNIEnv* env,
90 const JavaParamRef<jclass>& jcaller,
91 const JavaParamRef<jobject>& japp_context) {
92 // Set application context.
93 base::android::InitApplicationContext(env, japp_context);
94 }
95
96 void CronetInitOnMainThread(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { 89 void CronetInitOnMainThread(JNIEnv* env, const JavaParamRef<jclass>& jcaller) {
97 #if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID) 90 #if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID)
98 base::i18n::InitializeICU(); 91 base::i18n::InitializeICU();
99 #endif 92 #endif
100 93
101 // TODO(bengr): Remove once Data Reduction Proxy no longer needs this for 94 // TODO(bengr): Remove once Data Reduction Proxy no longer needs this for
102 // configuration information. 95 // configuration information.
103 base::CommandLine::Init(0, nullptr); 96 base::CommandLine::Init(0, nullptr);
104 DCHECK(!base::MessageLoop::current()); 97 DCHECK(!base::MessageLoop::current());
105 DCHECK(!g_main_message_loop); 98 DCHECK(!g_main_message_loop);
106 g_main_message_loop = new base::MessageLoopForUI(); 99 g_main_message_loop = new base::MessageLoopForUI();
107 base::MessageLoopForUI::current()->Start(); 100 base::MessageLoopForUI::current()->Start();
108 DCHECK(!g_network_change_notifier); 101 DCHECK(!g_network_change_notifier);
109 net::NetworkChangeNotifier::SetFactory( 102 net::NetworkChangeNotifier::SetFactory(
110 new net::NetworkChangeNotifierFactoryAndroid()); 103 new net::NetworkChangeNotifierFactoryAndroid());
111 g_network_change_notifier = net::NetworkChangeNotifier::Create(); 104 g_network_change_notifier = net::NetworkChangeNotifier::Create();
112 } 105 }
113 106
114 ScopedJavaLocalRef<jstring> GetCronetVersion( 107 ScopedJavaLocalRef<jstring> GetCronetVersion(
115 JNIEnv* env, 108 JNIEnv* env,
116 const JavaParamRef<jclass>& jcaller) { 109 const JavaParamRef<jclass>& jcaller) {
117 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION); 110 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION);
118 } 111 }
119 112
120 } // namespace cronet 113 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698