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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 // bandwidth, potentially based on underlying connection type, signal | 236 // bandwidth, potentially based on underlying connection type, signal |
237 // strength, or some other signal. Specifically, it returns +Infinity if there | 237 // strength, or some other signal. Specifically, it returns +Infinity if there |
238 // is a connection and 0.0 otherwise. The circumstances in which a more | 238 // is a connection and 0.0 otherwise. The circumstances in which a more |
239 // specific value is given are: Android cellular types, Android wifi types, | 239 // specific value is given are: Android cellular types, Android wifi types, |
240 // and ChromeOS cellular types. See the NetInfo spec for the mapping of | 240 // and ChromeOS cellular types. See the NetInfo spec for the mapping of |
241 // specific subtypes to bandwidth values: http://w3c.github.io/netinfo/. | 241 // specific subtypes to bandwidth values: http://w3c.github.io/netinfo/. |
242 // |connection_type| is set to the current ConnectionType. | 242 // |connection_type| is set to the current ConnectionType. |
243 static void GetMaxBandwidthAndConnectionType(double* max_bandwidth_mbps, | 243 static void GetMaxBandwidthAndConnectionType(double* max_bandwidth_mbps, |
244 ConnectionType* connection_type); | 244 ConnectionType* connection_type); |
245 | 245 |
246 // Returns a theoretical upper limit (in mbps) on download bandwidth given a | |
pauljensen
2015/09/15 17:39:24
mbps->Mbps
jkarlin
2015/09/15 17:51:49
Hmm, I believe they're the same. grep wars show 38
pauljensen
2015/09/15 17:58:32
Should be M. m=milli M=mega
https://en.wikipedia.
jkarlin
2015/09/15 18:07:19
Ah the elusive millibit. Fine fine. Done.
| |
247 // connection subtype. The mapping of connection type to maximum bandwidth is | |
248 // provided in the NetInfo spec: http://w3c.github.io/netinfo/. | |
249 static double GetMaxBandwidthForConnectionSubtype(ConnectionSubtype subtype); | |
250 | |
246 // Retrieve the last read DnsConfig. This could be expensive if the system has | 251 // Retrieve the last read DnsConfig. This could be expensive if the system has |
247 // a large HOSTS file. | 252 // a large HOSTS file. |
248 static void GetDnsConfig(DnsConfig* config); | 253 static void GetDnsConfig(DnsConfig* config); |
249 | 254 |
250 #if defined(OS_LINUX) | 255 #if defined(OS_LINUX) |
251 // Returns the AddressTrackerLinux if present. | 256 // Returns the AddressTrackerLinux if present. |
252 static const internal::AddressTrackerLinux* GetAddressTracker(); | 257 static const internal::AddressTrackerLinux* GetAddressTracker(); |
253 #endif | 258 #endif |
254 | 259 |
255 // Convenience method to determine if the user is offline. | 260 // Convenience method to determine if the user is offline. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 GetAddressTrackerInternal() const; | 397 GetAddressTrackerInternal() const; |
393 #endif | 398 #endif |
394 | 399 |
395 // See the description of NetworkChangeNotifier::GetMaxBandwidth(). | 400 // See the description of NetworkChangeNotifier::GetMaxBandwidth(). |
396 // Implementations must be thread-safe. Implementations must also be | 401 // Implementations must be thread-safe. Implementations must also be |
397 // cheap as it is called often. | 402 // cheap as it is called often. |
398 virtual void GetCurrentMaxBandwidthAndConnectionType( | 403 virtual void GetCurrentMaxBandwidthAndConnectionType( |
399 double* max_bandwidth_mbps, | 404 double* max_bandwidth_mbps, |
400 ConnectionType* connection_type) const; | 405 ConnectionType* connection_type) const; |
401 | 406 |
402 // Returns a theoretical upper limit on download bandwidth given a connection | |
403 // subtype. The mapping of connection type to maximum bandwidth is provided in | |
404 // the NetInfo spec: http://w3c.github.io/netinfo/. | |
405 static double GetMaxBandwidthForConnectionSubtype(ConnectionSubtype subtype); | |
406 | |
407 // Broadcasts a notification to all registered observers. Note that this | 407 // Broadcasts a notification to all registered observers. Note that this |
408 // happens asynchronously, even for observers on the current thread, even in | 408 // happens asynchronously, even for observers on the current thread, even in |
409 // tests. | 409 // tests. |
410 static void NotifyObserversOfIPAddressChange(); | 410 static void NotifyObserversOfIPAddressChange(); |
411 static void NotifyObserversOfConnectionTypeChange(); | 411 static void NotifyObserversOfConnectionTypeChange(); |
412 static void NotifyObserversOfDNSChange(); | 412 static void NotifyObserversOfDNSChange(); |
413 static void NotifyObserversOfInitialDNSConfigRead(); | 413 static void NotifyObserversOfInitialDNSConfigRead(); |
414 static void NotifyObserversOfNetworkChange(ConnectionType type); | 414 static void NotifyObserversOfNetworkChange(ConnectionType type); |
415 static void NotifyObserversOfMaxBandwidthChange(ConnectionType type, | 415 static void NotifyObserversOfMaxBandwidthChange(ConnectionType type, |
416 double max_bandwidth_mbps); | 416 double max_bandwidth_mbps); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 | 460 |
461 // Set true to disable non-test notifications (to prevent flakes in tests). | 461 // Set true to disable non-test notifications (to prevent flakes in tests). |
462 static bool test_notifications_only_; | 462 static bool test_notifications_only_; |
463 | 463 |
464 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 464 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
465 }; | 465 }; |
466 | 466 |
467 } // namespace net | 467 } // namespace net |
468 | 468 |
469 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 469 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
OLD | NEW |