| 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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/android/base_jni_onload.h" | 10 #include "base/android/base_jni_onload.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 bool OnInitThread() { | 79 bool OnInitThread() { |
| 80 DCHECK(g_init_message_loop); | 80 DCHECK(g_init_message_loop); |
| 81 return g_init_message_loop == base::MessageLoop::current(); | 81 return g_init_message_loop == base::MessageLoop::current(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Checks the available version of JNI. Also, caches Java reflection artifacts. | 84 // Checks the available version of JNI. Also, caches Java reflection artifacts. |
| 85 jint CronetOnLoad(JavaVM* vm, void* reserved) { | 85 jint CronetOnLoad(JavaVM* vm, void* reserved) { |
| 86 base::android::InitVM(vm); | 86 base::android::InitVM(vm); |
| 87 JNIEnv* env = base::android::AttachCurrentThread(); | 87 JNIEnv* env = base::android::AttachCurrentThread(); |
| 88 if (!base::android::OnJNIOnLoadRegisterJNI(env) || !RegisterJNI(env) || | 88 if (!RegisterJNI(env) || !NativeInit()) { |
| 89 !NativeInit()) { | |
| 90 return -1; | 89 return -1; |
| 91 } | 90 } |
| 92 return JNI_VERSION_1_6; | 91 return JNI_VERSION_1_6; |
| 93 } | 92 } |
| 94 | 93 |
| 95 void CronetOnUnLoad(JavaVM* jvm, void* reserved) { | 94 void CronetOnUnLoad(JavaVM* jvm, void* reserved) { |
| 96 base::android::LibraryLoaderExitHook(); | 95 base::android::LibraryLoaderExitHook(); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void CronetInitOnInitThread(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { | 98 void CronetInitOnInitThread(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 116 g_network_change_notifier = net::NetworkChangeNotifier::Create(); | 115 g_network_change_notifier = net::NetworkChangeNotifier::Create(); |
| 117 } | 116 } |
| 118 | 117 |
| 119 ScopedJavaLocalRef<jstring> GetCronetVersion( | 118 ScopedJavaLocalRef<jstring> GetCronetVersion( |
| 120 JNIEnv* env, | 119 JNIEnv* env, |
| 121 const JavaParamRef<jclass>& jcaller) { | 120 const JavaParamRef<jclass>& jcaller) { |
| 122 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION); | 121 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION); |
| 123 } | 122 } |
| 124 | 123 |
| 125 } // namespace cronet | 124 } // namespace cronet |
| OLD | NEW |