OLD | NEW |
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid( | 166 NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid( |
167 NetworkChangeNotifierDelegateAndroid* delegate, | 167 NetworkChangeNotifierDelegateAndroid* delegate, |
168 const DnsConfig* dns_config_for_testing) | 168 const DnsConfig* dns_config_for_testing) |
169 : NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()), | 169 : NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()), |
170 delegate_(delegate), | 170 delegate_(delegate), |
171 dns_config_service_thread_( | 171 dns_config_service_thread_( |
172 new DnsConfigServiceThread(dns_config_for_testing)) { | 172 new DnsConfigServiceThread(dns_config_for_testing)) { |
173 delegate_->AddObserver(this); | 173 delegate_->AddObserver(this); |
174 dns_config_service_thread_->StartWithOptions( | 174 dns_config_service_thread_->StartWithOptions( |
175 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 175 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 176 // Wait until Init is called on the DNS config thread before |
| 177 // calling InitAfterStart. |
| 178 dns_config_service_thread_->WaitUntilThreadStarted(); |
176 dns_config_service_thread_->InitAfterStart(); | 179 dns_config_service_thread_->InitAfterStart(); |
177 } | 180 } |
178 | 181 |
179 // static | 182 // static |
180 NetworkChangeNotifier::NetworkChangeCalculatorParams | 183 NetworkChangeNotifier::NetworkChangeCalculatorParams |
181 NetworkChangeNotifierAndroid::NetworkChangeCalculatorParamsAndroid() { | 184 NetworkChangeNotifierAndroid::NetworkChangeCalculatorParamsAndroid() { |
182 NetworkChangeCalculatorParams params; | 185 NetworkChangeCalculatorParams params; |
183 // IPAddressChanged is produced immediately prior to ConnectionTypeChanged | 186 // IPAddressChanged is produced immediately prior to ConnectionTypeChanged |
184 // so delay IPAddressChanged so they get merged with the following | 187 // so delay IPAddressChanged so they get merged with the following |
185 // ConnectionTypeChanged signal. | 188 // ConnectionTypeChanged signal. |
186 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); | 189 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); |
187 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); | 190 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); |
188 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); | 191 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); |
189 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); | 192 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); |
190 return params; | 193 return params; |
191 } | 194 } |
192 | 195 |
193 } // namespace net | 196 } // namespace net |
OLD | NEW |