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