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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |