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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 SUBTYPE_WIFI_G, | 95 SUBTYPE_WIFI_G, |
96 SUBTYPE_WIFI_N, | 96 SUBTYPE_WIFI_N, |
97 SUBTYPE_WIFI_AC, | 97 SUBTYPE_WIFI_AC, |
98 SUBTYPE_WIFI_AD, | 98 SUBTYPE_WIFI_AD, |
99 SUBTYPE_UNKNOWN, | 99 SUBTYPE_UNKNOWN, |
100 SUBTYPE_NONE, | 100 SUBTYPE_NONE, |
101 SUBTYPE_OTHER, | 101 SUBTYPE_OTHER, |
102 SUBTYPE_LAST = SUBTYPE_OTHER | 102 SUBTYPE_LAST = SUBTYPE_OTHER |
103 }; | 103 }; |
104 | 104 |
| 105 // Types of network changes specified to |
| 106 // NotifyObserversOfSpecificNetworkChange. |
| 107 enum NetworkChangeType { |
| 108 CONNECTED, |
| 109 DISCONNECTED, |
| 110 SOON_TO_DISCONNECT, |
| 111 MADE_DEFAULT |
| 112 }; |
| 113 |
105 class NET_EXPORT IPAddressObserver { | 114 class NET_EXPORT IPAddressObserver { |
106 public: | 115 public: |
107 // Will be called when the IP address of the primary interface changes. | 116 // Will be called when the IP address of the primary interface changes. |
108 // This includes when the primary interface itself changes. | 117 // This includes when the primary interface itself changes. |
109 virtual void OnIPAddressChanged() = 0; | 118 virtual void OnIPAddressChanged() = 0; |
110 | 119 |
111 protected: | 120 protected: |
112 IPAddressObserver() {} | 121 IPAddressObserver() {} |
113 virtual ~IPAddressObserver() {} | 122 virtual ~IPAddressObserver() {} |
114 | 123 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 static void RemoveDNSObserver(DNSObserver* observer); | 392 static void RemoveDNSObserver(DNSObserver* observer); |
384 static void RemoveNetworkChangeObserver(NetworkChangeObserver* observer); | 393 static void RemoveNetworkChangeObserver(NetworkChangeObserver* observer); |
385 static void RemoveMaxBandwidthObserver(MaxBandwidthObserver* observer); | 394 static void RemoveMaxBandwidthObserver(MaxBandwidthObserver* observer); |
386 static void RemoveNetworkObserver(NetworkObserver* observer); | 395 static void RemoveNetworkObserver(NetworkObserver* observer); |
387 | 396 |
388 // Allow unit tests to trigger notifications. | 397 // Allow unit tests to trigger notifications. |
389 static void NotifyObserversOfIPAddressChangeForTests(); | 398 static void NotifyObserversOfIPAddressChangeForTests(); |
390 static void NotifyObserversOfConnectionTypeChangeForTests( | 399 static void NotifyObserversOfConnectionTypeChangeForTests( |
391 ConnectionType type); | 400 ConnectionType type); |
392 static void NotifyObserversOfNetworkChangeForTests(ConnectionType type); | 401 static void NotifyObserversOfNetworkChangeForTests(ConnectionType type); |
| 402 static void NotifyObserversOfSpecificNetworkChangeForTests( |
| 403 NetworkChangeType type, |
| 404 NetworkHandle network); |
393 static void NotifyObserversOfInitialDNSConfigReadForTests(); | 405 static void NotifyObserversOfInitialDNSConfigReadForTests(); |
394 static void NotifyObserversOfMaxBandwidthChangeForTests( | 406 static void NotifyObserversOfMaxBandwidthChangeForTests( |
395 double max_bandwidth_mbps, | 407 double max_bandwidth_mbps, |
396 ConnectionType type); | 408 ConnectionType type); |
397 | 409 |
398 // Enable or disable notifications from the host. After setting to true, be | 410 // Enable or disable notifications from the host. After setting to true, be |
399 // sure to pump the RunLoop until idle to finish any preexisting | 411 // sure to pump the RunLoop until idle to finish any preexisting |
400 // notifications. To use this, it must must be called before a | 412 // notifications. To use this, it must must be called before a |
401 // NetworkChangeNotifier is created. | 413 // NetworkChangeNotifier is created. |
402 static void SetTestNotificationsOnly(bool test_only); | 414 static void SetTestNotificationsOnly(bool test_only); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 public: | 446 public: |
435 DisableForTest(); | 447 DisableForTest(); |
436 ~DisableForTest(); | 448 ~DisableForTest(); |
437 | 449 |
438 private: | 450 private: |
439 // The original NetworkChangeNotifier to be restored on destruction. | 451 // The original NetworkChangeNotifier to be restored on destruction. |
440 NetworkChangeNotifier* network_change_notifier_; | 452 NetworkChangeNotifier* network_change_notifier_; |
441 }; | 453 }; |
442 | 454 |
443 protected: | 455 protected: |
444 // Types of network changes specified to | |
445 // NotifyObserversOfSpecificNetworkChange. | |
446 enum NetworkChangeType { | |
447 CONNECTED, | |
448 DISCONNECTED, | |
449 SOON_TO_DISCONNECT, | |
450 MADE_DEFAULT | |
451 }; | |
452 | |
453 // NetworkChanged signal is calculated from the IPAddressChanged and | 456 // NetworkChanged signal is calculated from the IPAddressChanged and |
454 // ConnectionTypeChanged signals. Delay parameters control how long to delay | 457 // ConnectionTypeChanged signals. Delay parameters control how long to delay |
455 // producing NetworkChanged signal after particular input signals so as to | 458 // producing NetworkChanged signal after particular input signals so as to |
456 // combine duplicates. In other words if an input signal is repeated within | 459 // combine duplicates. In other words if an input signal is repeated within |
457 // the corresponding delay period, only one resulting NetworkChange signal is | 460 // the corresponding delay period, only one resulting NetworkChange signal is |
458 // produced. | 461 // produced. |
459 struct NET_EXPORT NetworkChangeCalculatorParams { | 462 struct NET_EXPORT NetworkChangeCalculatorParams { |
460 NetworkChangeCalculatorParams(); | 463 NetworkChangeCalculatorParams(); |
461 // Controls delay after OnIPAddressChanged when transitioning from an | 464 // Controls delay after OnIPAddressChanged when transitioning from an |
462 // offline state. | 465 // offline state. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 562 |
560 // Set true to disable non-test notifications (to prevent flakes in tests). | 563 // Set true to disable non-test notifications (to prevent flakes in tests). |
561 static bool test_notifications_only_; | 564 static bool test_notifications_only_; |
562 | 565 |
563 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 566 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
564 }; | 567 }; |
565 | 568 |
566 } // namespace net | 569 } // namespace net |
567 | 570 |
568 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 571 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
OLD | NEW |