| 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 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/observer_list_threadsafe.h" | 9 #include "base/observer_list_threadsafe.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 | 12 |
| 13 class GURL; |
| 14 |
| 13 namespace net { | 15 namespace net { |
| 14 | 16 |
| 17 class HistogramWatcher; |
| 15 class NetworkChangeNotifierFactory; | 18 class NetworkChangeNotifierFactory; |
| 16 | 19 |
| 17 namespace internal { | 20 namespace internal { |
| 18 class DnsConfigWatcher; | 21 class DnsConfigWatcher; |
| 19 | 22 |
| 20 #if defined(OS_LINUX) | 23 #if defined(OS_LINUX) |
| 21 class AddressTrackerLinux; | 24 class AddressTrackerLinux; |
| 22 #endif | 25 #endif |
| 23 } | 26 } |
| 24 | 27 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // there's no reason to use the API in this risky way, so don't do it. | 173 // there's no reason to use the API in this risky way, so don't do it. |
| 171 static void RemoveIPAddressObserver(IPAddressObserver* observer); | 174 static void RemoveIPAddressObserver(IPAddressObserver* observer); |
| 172 static void RemoveConnectionTypeObserver(ConnectionTypeObserver* observer); | 175 static void RemoveConnectionTypeObserver(ConnectionTypeObserver* observer); |
| 173 static void RemoveDNSObserver(DNSObserver* observer); | 176 static void RemoveDNSObserver(DNSObserver* observer); |
| 174 | 177 |
| 175 // Allow unit tests to trigger notifications. | 178 // Allow unit tests to trigger notifications. |
| 176 static void NotifyObserversOfIPAddressChangeForTests() { | 179 static void NotifyObserversOfIPAddressChangeForTests() { |
| 177 NotifyObserversOfIPAddressChange(); | 180 NotifyObserversOfIPAddressChange(); |
| 178 } | 181 } |
| 179 | 182 |
| 183 // Let the NetworkChangeNotifier know we received some data. |
| 184 // This is used strictly for producing histogram data about the accuracy of |
| 185 // the NetworkChangenotifier's online detection. |
| 186 static void NotifyDataReceived(const GURL& source); |
| 187 |
| 188 // Register the Observer callbacks for producing histogram data. This |
| 189 // should be called from the network thread to avoid race conditions. |
| 190 static void InitHistogramWatcher(); |
| 191 |
| 180 protected: | 192 protected: |
| 181 friend class internal::DnsConfigWatcher; | 193 friend class internal::DnsConfigWatcher; |
| 182 | 194 |
| 183 NetworkChangeNotifier(); | 195 NetworkChangeNotifier(); |
| 184 | 196 |
| 185 #if defined(OS_LINUX) | 197 #if defined(OS_LINUX) |
| 186 // Returns the AddressTrackerLinux if present. | 198 // Returns the AddressTrackerLinux if present. |
| 187 virtual const internal::AddressTrackerLinux* | 199 virtual const internal::AddressTrackerLinux* |
| 188 GetAddressTrackerInternal() const; | 200 GetAddressTrackerInternal() const; |
| 189 #endif | 201 #endif |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 const scoped_refptr<ObserverListThreadSafe<DNSObserver> > | 235 const scoped_refptr<ObserverListThreadSafe<DNSObserver> > |
| 224 resolver_state_observer_list_; | 236 resolver_state_observer_list_; |
| 225 | 237 |
| 226 // True iff DNS watchers are operational. | 238 // True iff DNS watchers are operational. |
| 227 // Otherwise, OnDNSChanged might not be issued for future changes. | 239 // Otherwise, OnDNSChanged might not be issued for future changes. |
| 228 // TODO(szym): This is a temporary interface, consider restarting them. | 240 // TODO(szym): This is a temporary interface, consider restarting them. |
| 229 // http://crbug.com/116139 | 241 // http://crbug.com/116139 |
| 230 base::Lock watching_dns_lock_; | 242 base::Lock watching_dns_lock_; |
| 231 bool watching_dns_; | 243 bool watching_dns_; |
| 232 | 244 |
| 245 // A little-piggy-back observer that simply logs UMA histogram data. |
| 246 scoped_ptr<HistogramWatcher> histogram_watcher_; |
| 247 |
| 233 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 248 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
| 234 }; | 249 }; |
| 235 | 250 |
| 236 } // namespace net | 251 } // namespace net |
| 237 | 252 |
| 238 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 253 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| OLD | NEW |