| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 class NetworkChangeNotifierAndroid::DnsConfigServiceThread | 70 class NetworkChangeNotifierAndroid::DnsConfigServiceThread |
| 71 : public base::Thread { | 71 : public base::Thread { |
| 72 public: | 72 public: |
| 73 DnsConfigServiceThread() | 73 DnsConfigServiceThread() |
| 74 : base::Thread("DnsConfigService"), | 74 : base::Thread("DnsConfigService"), |
| 75 address_tracker_(base::Bind(base::DoNothing), | 75 address_tracker_(base::Bind(base::DoNothing), |
| 76 base::Bind(base::DoNothing), | 76 base::Bind(base::DoNothing), |
| 77 // We're only interested in tunnel interface changes. | 77 // We're only interested in tunnel interface changes. |
| 78 base::Bind(NotifyNetworkChangeNotifierObservers)) {} | 78 base::Bind(NotifyNetworkChangeNotifierObservers)) {} |
| 79 | 79 |
| 80 virtual ~DnsConfigServiceThread() { | 80 ~DnsConfigServiceThread() override { Stop(); } |
| 81 Stop(); | |
| 82 } | |
| 83 | 81 |
| 84 virtual void Init() override { | 82 void Init() override { |
| 85 address_tracker_.Init(); | 83 address_tracker_.Init(); |
| 86 dns_config_service_ = DnsConfigService::CreateSystemService(); | 84 dns_config_service_ = DnsConfigService::CreateSystemService(); |
| 87 dns_config_service_->WatchConfig( | 85 dns_config_service_->WatchConfig( |
| 88 base::Bind(&NetworkChangeNotifier::SetDnsConfig)); | 86 base::Bind(&NetworkChangeNotifier::SetDnsConfig)); |
| 89 } | 87 } |
| 90 | 88 |
| 91 virtual void CleanUp() override { | 89 void CleanUp() override { dns_config_service_.reset(); } |
| 92 dns_config_service_.reset(); | |
| 93 } | |
| 94 | 90 |
| 95 static void NotifyNetworkChangeNotifierObservers() { | 91 static void NotifyNetworkChangeNotifierObservers() { |
| 96 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); | 92 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); |
| 97 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); | 93 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); |
| 98 } | 94 } |
| 99 | 95 |
| 100 private: | 96 private: |
| 101 scoped_ptr<DnsConfigService> dns_config_service_; | 97 scoped_ptr<DnsConfigService> dns_config_service_; |
| 102 // Used to detect tunnel state changes. | 98 // Used to detect tunnel state changes. |
| 103 internal::AddressTrackerLinux address_tracker_; | 99 internal::AddressTrackerLinux address_tracker_; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // so delay IPAddressChanged so they get merged with the following | 147 // so delay IPAddressChanged so they get merged with the following |
| 152 // ConnectionTypeChanged signal. | 148 // ConnectionTypeChanged signal. |
| 153 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); | 149 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); |
| 154 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); | 150 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); |
| 155 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); | 151 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); |
| 156 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); | 152 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); |
| 157 return params; | 153 return params; |
| 158 } | 154 } |
| 159 | 155 |
| 160 } // namespace net | 156 } // namespace net |
| OLD | NEW |