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(); | |
178 dns_config_service_thread_->InitAfterStart(); | 175 dns_config_service_thread_->InitAfterStart(); |
179 } | 176 } |
180 | 177 |
181 // static | 178 // static |
182 NetworkChangeNotifier::NetworkChangeCalculatorParams | 179 NetworkChangeNotifier::NetworkChangeCalculatorParams |
183 NetworkChangeNotifierAndroid::NetworkChangeCalculatorParamsAndroid() { | 180 NetworkChangeNotifierAndroid::NetworkChangeCalculatorParamsAndroid() { |
184 NetworkChangeCalculatorParams params; | 181 NetworkChangeCalculatorParams params; |
185 // IPAddressChanged is produced immediately prior to ConnectionTypeChanged | 182 // IPAddressChanged is produced immediately prior to ConnectionTypeChanged |
186 // so delay IPAddressChanged so they get merged with the following | 183 // so delay IPAddressChanged so they get merged with the following |
187 // ConnectionTypeChanged signal. | 184 // ConnectionTypeChanged signal. |
188 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); | 185 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); |
189 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); | 186 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); |
190 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); | 187 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); |
191 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); | 188 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); |
192 return params; | 189 return params; |
193 } | 190 } |
194 | 191 |
195 } // namespace net | 192 } // namespace net |
OLD | NEW |