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

Side by Side Diff: net/android/network_change_notifier_android.cc

Issue 1011683002: Lazily initialize MessageLoop for faster thread startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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 | « content/public/test/test_browser_thread.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 //////////////////////////////////////////////////////////////////////////////// 5 ////////////////////////////////////////////////////////////////////////////////
6 // Threading considerations: 6 // Threading considerations:
7 // 7 //
8 // This class is designed to meet various threading guarantees starting from the 8 // This class is designed to meet various threading guarantees starting from the
9 // ones imposed by NetworkChangeNotifier: 9 // ones imposed by NetworkChangeNotifier:
10 // - The notifier can be constructed on any thread. 10 // - The notifier can be constructed on any thread.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid( 165 NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid(
166 NetworkChangeNotifierDelegateAndroid* delegate, 166 NetworkChangeNotifierDelegateAndroid* delegate,
167 const DnsConfig* dns_config_for_testing) 167 const DnsConfig* dns_config_for_testing)
168 : NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()), 168 : NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()),
169 delegate_(delegate), 169 delegate_(delegate),
170 dns_config_service_thread_( 170 dns_config_service_thread_(
171 new DnsConfigServiceThread(dns_config_for_testing)) { 171 new DnsConfigServiceThread(dns_config_for_testing)) {
172 delegate_->AddObserver(this); 172 delegate_->AddObserver(this);
173 dns_config_service_thread_->StartWithOptions( 173 dns_config_service_thread_->StartWithOptions(
174 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 174 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
175 // Wait until Init is called on the DNS config thread before
176 // calling InitAfterStart.
177 dns_config_service_thread_->WaitUntilThreadStarted();
175 dns_config_service_thread_->InitAfterStart(); 178 dns_config_service_thread_->InitAfterStart();
176 } 179 }
177 180
178 // static 181 // static
179 NetworkChangeNotifier::NetworkChangeCalculatorParams 182 NetworkChangeNotifier::NetworkChangeCalculatorParams
180 NetworkChangeNotifierAndroid::NetworkChangeCalculatorParamsAndroid() { 183 NetworkChangeNotifierAndroid::NetworkChangeCalculatorParamsAndroid() {
181 NetworkChangeCalculatorParams params; 184 NetworkChangeCalculatorParams params;
182 // IPAddressChanged is produced immediately prior to ConnectionTypeChanged 185 // IPAddressChanged is produced immediately prior to ConnectionTypeChanged
183 // so delay IPAddressChanged so they get merged with the following 186 // so delay IPAddressChanged so they get merged with the following
184 // ConnectionTypeChanged signal. 187 // ConnectionTypeChanged signal.
185 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); 188 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1);
186 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); 189 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1);
187 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); 190 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0);
188 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); 191 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0);
189 return params; 192 return params;
190 } 193 }
191 194
192 } // namespace net 195 } // namespace net
OLDNEW
« no previous file with comments | « content/public/test/test_browser_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698