| 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 "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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 89 void CronetInitApplicationContext(JNIEnv* env, |
| 90 const JavaParamRef<jclass>& jcaller, | 90 const JavaParamRef<jclass>& jcaller, |
| 91 const JavaParamRef<jobject>& japp_context) { | 91 const JavaParamRef<jobject>& japp_context) { |
| 92 // Set application context. | 92 // Set application context. |
| 93 base::android::ScopedJavaLocalRef<jobject> scoped_app_context(env, | 93 base::android::InitApplicationContext(env, japp_context); |
| 94 japp_context); | |
| 95 base::android::InitApplicationContext(env, scoped_app_context); | |
| 96 } | 94 } |
| 97 | 95 |
| 98 void CronetInitOnMainThread(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { | 96 void CronetInitOnMainThread(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { |
| 99 #if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID) | 97 #if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID) |
| 100 base::i18n::InitializeICU(); | 98 base::i18n::InitializeICU(); |
| 101 #endif | 99 #endif |
| 102 | 100 |
| 103 // TODO(bengr): Remove once Data Reduction Proxy no longer needs this for | 101 // TODO(bengr): Remove once Data Reduction Proxy no longer needs this for |
| 104 // configuration information. | 102 // configuration information. |
| 105 base::CommandLine::Init(0, nullptr); | 103 base::CommandLine::Init(0, nullptr); |
| 106 DCHECK(!base::MessageLoop::current()); | 104 DCHECK(!base::MessageLoop::current()); |
| 107 DCHECK(!g_main_message_loop); | 105 DCHECK(!g_main_message_loop); |
| 108 g_main_message_loop = new base::MessageLoopForUI(); | 106 g_main_message_loop = new base::MessageLoopForUI(); |
| 109 base::MessageLoopForUI::current()->Start(); | 107 base::MessageLoopForUI::current()->Start(); |
| 110 DCHECK(!g_network_change_notifier); | 108 DCHECK(!g_network_change_notifier); |
| 111 net::NetworkChangeNotifier::SetFactory( | 109 net::NetworkChangeNotifier::SetFactory( |
| 112 new net::NetworkChangeNotifierFactoryAndroid()); | 110 new net::NetworkChangeNotifierFactoryAndroid()); |
| 113 g_network_change_notifier = net::NetworkChangeNotifier::Create(); | 111 g_network_change_notifier = net::NetworkChangeNotifier::Create(); |
| 114 } | 112 } |
| 115 | 113 |
| 116 ScopedJavaLocalRef<jstring> GetCronetVersion( | 114 ScopedJavaLocalRef<jstring> GetCronetVersion( |
| 117 JNIEnv* env, | 115 JNIEnv* env, |
| 118 const JavaParamRef<jclass>& jcaller) { | 116 const JavaParamRef<jclass>& jcaller) { |
| 119 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION); | 117 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION); |
| 120 } | 118 } |
| 121 | 119 |
| 122 } // namespace cronet | 120 } // namespace cronet |
| OLD | NEW |