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 virtual ~DnsConfigServiceThread() { Stop(); } |
81 Stop(); | |
82 } | |
83 | 81 |
84 virtual void Init() OVERRIDE { | 82 virtual 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 virtual 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // so delay IPAddressChanged so they get merged with the following | 137 // so delay IPAddressChanged so they get merged with the following |
142 // ConnectionTypeChanged signal. | 138 // ConnectionTypeChanged signal. |
143 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); | 139 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); |
144 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); | 140 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); |
145 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); | 141 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); |
146 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); | 142 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); |
147 return params; | 143 return params; |
148 } | 144 } |
149 | 145 |
150 } // namespace net | 146 } // namespace net |
OLD | NEW |