| 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" |
| 11 #include "base/android/base_jni_registrar.h" | 11 #include "base/android/base_jni_registrar.h" |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "base/android/jni_registrar.h" | 13 #include "base/android/jni_registrar.h" |
| 14 #include "base/android/jni_utils.h" | 14 #include "base/android/jni_utils.h" |
| 15 #include "base/android/library_loader/library_loader_hooks.h" | 15 #include "base/android/library_loader/library_loader_hooks.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/feature_list.h" | 17 #include "base/feature_list.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
| 21 #include "base/metrics/statistics_recorder.h" |
| 21 #include "components/cronet/android/cronet_bidirectional_stream_adapter.h" | 22 #include "components/cronet/android/cronet_bidirectional_stream_adapter.h" |
| 22 #include "components/cronet/android/cronet_upload_data_stream_adapter.h" | 23 #include "components/cronet/android/cronet_upload_data_stream_adapter.h" |
| 23 #include "components/cronet/android/cronet_url_request_adapter.h" | 24 #include "components/cronet/android/cronet_url_request_adapter.h" |
| 24 #include "components/cronet/android/cronet_url_request_context_adapter.h" | 25 #include "components/cronet/android/cronet_url_request_context_adapter.h" |
| 25 #include "components/cronet/version.h" | 26 #include "components/cronet/version.h" |
| 26 #include "jni/CronetLibraryLoader_jni.h" | 27 #include "jni/CronetLibraryLoader_jni.h" |
| 27 #include "net/android/net_jni_registrar.h" | 28 #include "net/android/net_jni_registrar.h" |
| 28 #include "net/android/network_change_notifier_factory_android.h" | 29 #include "net/android/network_change_notifier_factory_android.h" |
| 29 #include "net/base/network_change_notifier.h" | 30 #include "net/base/network_change_notifier.h" |
| 30 #include "url/url_features.h" | 31 #include "url/url_features.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 60 | 61 |
| 61 bool RegisterJNI(JNIEnv* env) { | 62 bool RegisterJNI(JNIEnv* env) { |
| 62 return base::android::RegisterNativeMethods( | 63 return base::android::RegisterNativeMethods( |
| 63 env, kCronetRegisteredMethods, arraysize(kCronetRegisteredMethods)); | 64 env, kCronetRegisteredMethods, arraysize(kCronetRegisteredMethods)); |
| 64 } | 65 } |
| 65 | 66 |
| 66 bool NativeInit() { | 67 bool NativeInit() { |
| 67 if (!base::android::OnJNIOnLoadInit()) | 68 if (!base::android::OnJNIOnLoadInit()) |
| 68 return false; | 69 return false; |
| 69 url::Initialize(); | 70 url::Initialize(); |
| 71 // Initializes the statistics recorder system. This needs to be done before |
| 72 // emitting histograms to prevent memory leaks (crbug.com/707836). |
| 73 base::StatisticsRecorder::Initialize(); |
| 70 return true; | 74 return true; |
| 71 } | 75 } |
| 72 | 76 |
| 73 } // namespace | 77 } // namespace |
| 74 | 78 |
| 75 // Checks the available version of JNI. Also, caches Java reflection artifacts. | 79 // Checks the available version of JNI. Also, caches Java reflection artifacts. |
| 76 jint CronetOnLoad(JavaVM* vm, void* reserved) { | 80 jint CronetOnLoad(JavaVM* vm, void* reserved) { |
| 77 base::android::InitVM(vm); | 81 base::android::InitVM(vm); |
| 78 JNIEnv* env = base::android::AttachCurrentThread(); | 82 JNIEnv* env = base::android::AttachCurrentThread(); |
| 79 if (!base::android::OnJNIOnLoadRegisterJNI(env) || !RegisterJNI(env) || | 83 if (!base::android::OnJNIOnLoadRegisterJNI(env) || !RegisterJNI(env) || |
| (...skipping 26 matching lines...) Expand all Loading... |
| 106 g_network_change_notifier = net::NetworkChangeNotifier::Create(); | 110 g_network_change_notifier = net::NetworkChangeNotifier::Create(); |
| 107 } | 111 } |
| 108 | 112 |
| 109 ScopedJavaLocalRef<jstring> GetCronetVersion( | 113 ScopedJavaLocalRef<jstring> GetCronetVersion( |
| 110 JNIEnv* env, | 114 JNIEnv* env, |
| 111 const JavaParamRef<jclass>& jcaller) { | 115 const JavaParamRef<jclass>& jcaller) { |
| 112 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION); | 116 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION); |
| 113 } | 117 } |
| 114 | 118 |
| 115 } // namespace cronet | 119 } // namespace cronet |
| OLD | NEW |