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

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

Issue 2966283002: Remove the file thread dependency from FileNetLogObserver. (Closed)
Patch Set: init TaskScheduler on cronet Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/cronet/android/cronet_url_request_context_adapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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/feature_list.h" 16 #include "base/feature_list.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/metrics/statistics_recorder.h" 20 #include "base/metrics/statistics_recorder.h"
21 #include "base/task_scheduler/task_scheduler.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_jni_registration.h" 23 #include "components/cronet/android/cronet_jni_registration.h"
23 #include "components/cronet/android/cronet_upload_data_stream_adapter.h" 24 #include "components/cronet/android/cronet_upload_data_stream_adapter.h"
24 #include "components/cronet/android/cronet_url_request_adapter.h" 25 #include "components/cronet/android/cronet_url_request_adapter.h"
25 #include "components/cronet/android/cronet_url_request_context_adapter.h" 26 #include "components/cronet/android/cronet_url_request_context_adapter.h"
26 #include "components/cronet/version.h" 27 #include "components/cronet/version.h"
27 #include "jni/CronetLibraryLoader_jni.h" 28 #include "jni/CronetLibraryLoader_jni.h"
28 #include "net/android/net_jni_registrar.h" 29 #include "net/android/net_jni_registrar.h"
29 #include "net/android/network_change_notifier_factory_android.h" 30 #include "net/android/network_change_notifier_factory_android.h"
30 #include "net/base/network_change_notifier.h" 31 #include "net/base/network_change_notifier.h"
(...skipping 29 matching lines...) Expand all
60 net::NetworkChangeNotifier* g_network_change_notifier = nullptr; 61 net::NetworkChangeNotifier* g_network_change_notifier = nullptr;
61 62
62 bool RegisterJNI(JNIEnv* env) { 63 bool RegisterJNI(JNIEnv* env) {
63 return base::android::RegisterNativeMethods( 64 return base::android::RegisterNativeMethods(
64 env, kCronetRegisteredMethods, arraysize(kCronetRegisteredMethods)); 65 env, kCronetRegisteredMethods, arraysize(kCronetRegisteredMethods));
65 } 66 }
66 67
67 bool NativeInit() { 68 bool NativeInit() {
68 if (!base::android::OnJNIOnLoadInit()) 69 if (!base::android::OnJNIOnLoadInit())
69 return false; 70 return false;
71 base::TaskScheduler::CreateAndStartWithDefaultParams("Cronet");
mmenke 2017/07/06 01:50:01 I don't think we want to create another thread in
mmenke 2017/07/06 15:22:26 I think we'll need to talk about the Cronet folks
mef 2017/07/06 19:53:01 Good point. I didn't realize that base::TaskSched
72
70 url::Initialize(); 73 url::Initialize();
71 // Initializes the statistics recorder system. This needs to be done before 74 // Initializes the statistics recorder system. This needs to be done before
72 // emitting histograms to prevent memory leaks (crbug.com/707836). 75 // emitting histograms to prevent memory leaks (crbug.com/707836).
73 base::StatisticsRecorder::Initialize(); 76 base::StatisticsRecorder::Initialize();
74 return true; 77 return true;
75 } 78 }
76 79
77 } // namespace 80 } // namespace
78 81
79 bool OnInitThread() { 82 bool OnInitThread() {
(...skipping 10 matching lines...) Expand all
90 } 93 }
91 // TODO(agrieve): Delete this block, this is a no-op now. 94 // TODO(agrieve): Delete this block, this is a no-op now.
92 // https://crbug.com/683256. 95 // https://crbug.com/683256.
93 if (!RegisterJNI(env) || !NativeInit()) { 96 if (!RegisterJNI(env) || !NativeInit()) {
94 return -1; 97 return -1;
95 } 98 }
96 return JNI_VERSION_1_6; 99 return JNI_VERSION_1_6;
97 } 100 }
98 101
99 void CronetOnUnLoad(JavaVM* jvm, void* reserved) { 102 void CronetOnUnLoad(JavaVM* jvm, void* reserved) {
103 if (base::TaskScheduler::GetInstance())
104 base::TaskScheduler::GetInstance()->Shutdown();
105
100 base::android::LibraryLoaderExitHook(); 106 base::android::LibraryLoaderExitHook();
101 } 107 }
102 108
103 void CronetInitOnInitThread(JNIEnv* env, const JavaParamRef<jclass>& jcaller) { 109 void CronetInitOnInitThread(JNIEnv* env, const JavaParamRef<jclass>& jcaller) {
104 #if !BUILDFLAG(USE_PLATFORM_ICU_ALTERNATIVES) 110 #if !BUILDFLAG(USE_PLATFORM_ICU_ALTERNATIVES)
105 base::i18n::InitializeICU(); 111 base::i18n::InitializeICU();
106 #endif 112 #endif
107 113
108 base::FeatureList::InitializeInstance(std::string(), std::string()); 114 base::FeatureList::InitializeInstance(std::string(), std::string());
109 DCHECK(!base::MessageLoop::current()); 115 DCHECK(!base::MessageLoop::current());
110 DCHECK(!g_init_message_loop); 116 DCHECK(!g_init_message_loop);
111 g_init_message_loop = 117 g_init_message_loop =
112 new base::MessageLoop(base::MessageLoop::Type::TYPE_JAVA); 118 new base::MessageLoop(base::MessageLoop::Type::TYPE_JAVA);
113 static_cast<base::MessageLoopForUI*>(g_init_message_loop)->Start(); 119 static_cast<base::MessageLoopForUI*>(g_init_message_loop)->Start();
114 DCHECK(!g_network_change_notifier); 120 DCHECK(!g_network_change_notifier);
115 net::NetworkChangeNotifier::SetFactory( 121 net::NetworkChangeNotifier::SetFactory(
116 new net::NetworkChangeNotifierFactoryAndroid()); 122 new net::NetworkChangeNotifierFactoryAndroid());
117 g_network_change_notifier = net::NetworkChangeNotifier::Create(); 123 g_network_change_notifier = net::NetworkChangeNotifier::Create();
118 } 124 }
119 125
120 ScopedJavaLocalRef<jstring> GetCronetVersion( 126 ScopedJavaLocalRef<jstring> GetCronetVersion(
121 JNIEnv* env, 127 JNIEnv* env,
122 const JavaParamRef<jclass>& jcaller) { 128 const JavaParamRef<jclass>& jcaller) {
123 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION); 129 return base::android::ConvertUTF8ToJavaString(env, CRONET_VERSION);
124 } 130 }
125 131
126 } // namespace cronet 132 } // namespace cronet
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/cronet_url_request_context_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698