Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: net/base/network_change_notifier.h

Issue 1047103002: Avoid initial NetworkChangeNotifier OnDNSChanged() signal on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert an accidental test enabling Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 private: 129 private:
130 DISALLOW_COPY_AND_ASSIGN(ConnectionTypeObserver); 130 DISALLOW_COPY_AND_ASSIGN(ConnectionTypeObserver);
131 }; 131 };
132 132
133 class NET_EXPORT DNSObserver { 133 class NET_EXPORT DNSObserver {
134 public: 134 public:
135 // Will be called when the DNS settings of the system may have changed. 135 // Will be called when the DNS settings of the system may have changed.
136 // Use GetDnsConfig to obtain the current settings. 136 // Use GetDnsConfig to obtain the current settings.
137 virtual void OnDNSChanged() = 0; 137 virtual void OnDNSChanged() = 0;
138 // Will be called when DNS settings of the system have been loaded.
139 // Use GetDnsConfig to obtain the current settings.
140 virtual void OnInitialDNSConfigRead();
138 141
139 protected: 142 protected:
140 DNSObserver() {} 143 DNSObserver() {}
141 virtual ~DNSObserver() {} 144 virtual ~DNSObserver() {}
142 145
143 private: 146 private:
144 DISALLOW_COPY_AND_ASSIGN(DNSObserver); 147 DISALLOW_COPY_AND_ASSIGN(DNSObserver);
145 }; 148 };
146 149
147 class NET_EXPORT NetworkChangeObserver { 150 class NET_EXPORT NetworkChangeObserver {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 static void RemoveConnectionTypeObserver(ConnectionTypeObserver* observer); 301 static void RemoveConnectionTypeObserver(ConnectionTypeObserver* observer);
299 static void RemoveDNSObserver(DNSObserver* observer); 302 static void RemoveDNSObserver(DNSObserver* observer);
300 static void RemoveNetworkChangeObserver(NetworkChangeObserver* observer); 303 static void RemoveNetworkChangeObserver(NetworkChangeObserver* observer);
301 static void RemoveMaxBandwidthObserver(MaxBandwidthObserver* observer); 304 static void RemoveMaxBandwidthObserver(MaxBandwidthObserver* observer);
302 305
303 // Allow unit tests to trigger notifications. 306 // Allow unit tests to trigger notifications.
304 static void NotifyObserversOfIPAddressChangeForTests(); 307 static void NotifyObserversOfIPAddressChangeForTests();
305 static void NotifyObserversOfConnectionTypeChangeForTests( 308 static void NotifyObserversOfConnectionTypeChangeForTests(
306 ConnectionType type); 309 ConnectionType type);
307 static void NotifyObserversOfNetworkChangeForTests(ConnectionType type); 310 static void NotifyObserversOfNetworkChangeForTests(ConnectionType type);
311 static void NotifyObserversOfInitialDNSConfigReadForTests();
308 312
309 // Enable or disable notifications from the host. After setting to true, be 313 // Enable or disable notifications from the host. After setting to true, be
310 // sure to pump the RunLoop until idle to finish any preexisting 314 // sure to pump the RunLoop until idle to finish any preexisting
311 // notifications. 315 // notifications.
312 static void SetTestNotificationsOnly(bool test_only); 316 static void SetTestNotificationsOnly(bool test_only);
313 317
314 // Return a string equivalent to |type|. 318 // Return a string equivalent to |type|.
315 static const char* ConnectionTypeToString(ConnectionType type); 319 static const char* ConnectionTypeToString(ConnectionType type);
316 320
317 // Let the NetworkChangeNotifier know we received some data. 321 // Let the NetworkChangeNotifier know we received some data.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // subtype. The mapping of connection type to maximum bandwidth is provided in 397 // subtype. The mapping of connection type to maximum bandwidth is provided in
394 // the NetInfo spec: http://w3c.github.io/netinfo/. 398 // the NetInfo spec: http://w3c.github.io/netinfo/.
395 static double GetMaxBandwidthForConnectionSubtype(ConnectionSubtype subtype); 399 static double GetMaxBandwidthForConnectionSubtype(ConnectionSubtype subtype);
396 400
397 // Broadcasts a notification to all registered observers. Note that this 401 // Broadcasts a notification to all registered observers. Note that this
398 // happens asynchronously, even for observers on the current thread, even in 402 // happens asynchronously, even for observers on the current thread, even in
399 // tests. 403 // tests.
400 static void NotifyObserversOfIPAddressChange(); 404 static void NotifyObserversOfIPAddressChange();
401 static void NotifyObserversOfConnectionTypeChange(); 405 static void NotifyObserversOfConnectionTypeChange();
402 static void NotifyObserversOfDNSChange(); 406 static void NotifyObserversOfDNSChange();
407 static void NotifyObserversOfInitialDNSConfigRead();
403 static void NotifyObserversOfNetworkChange(ConnectionType type); 408 static void NotifyObserversOfNetworkChange(ConnectionType type);
404 static void NotifyObserversOfMaxBandwidthChange(double max_bandwidth_mbps); 409 static void NotifyObserversOfMaxBandwidthChange(double max_bandwidth_mbps);
405 410
406 // Stores |config| in NetworkState and notifies observers. 411 // Stores |config| in NetworkState and notifies OnDNSChanged observers.
407 static void SetDnsConfig(const DnsConfig& config); 412 static void SetDnsConfig(const DnsConfig& config);
413 // Stores |config| in NetworkState and notifies OnInitialDNSConfigRead
414 // observers.
415 static void SetInitialDnsConfig(const DnsConfig& config);
408 416
409 private: 417 private:
410 friend class HostResolverImplDnsTest; 418 friend class HostResolverImplDnsTest;
411 friend class NetworkChangeNotifierAndroidTest; 419 friend class NetworkChangeNotifierAndroidTest;
412 friend class NetworkChangeNotifierLinuxTest; 420 friend class NetworkChangeNotifierLinuxTest;
413 friend class NetworkChangeNotifierWinTest; 421 friend class NetworkChangeNotifierWinTest;
414 422
415 class NetworkState; 423 class NetworkState;
416 class NetworkChangeCalculator; 424 class NetworkChangeCalculator;
417 425
418 void NotifyObserversOfIPAddressChangeImpl(); 426 void NotifyObserversOfIPAddressChangeImpl();
419 void NotifyObserversOfConnectionTypeChangeImpl(ConnectionType type); 427 void NotifyObserversOfConnectionTypeChangeImpl(ConnectionType type);
420 void NotifyObserversOfDNSChangeImpl(); 428 void NotifyObserversOfDNSChangeImpl();
429 void NotifyObserversOfInitialDNSConfigReadImpl();
421 void NotifyObserversOfNetworkChangeImpl(ConnectionType type); 430 void NotifyObserversOfNetworkChangeImpl(ConnectionType type);
422 void NotifyObserversOfMaxBandwidthChangeImpl(double max_bandwidth_mbps); 431 void NotifyObserversOfMaxBandwidthChangeImpl(double max_bandwidth_mbps);
423 432
424 const scoped_refptr<ObserverListThreadSafe<IPAddressObserver>> 433 const scoped_refptr<ObserverListThreadSafe<IPAddressObserver>>
425 ip_address_observer_list_; 434 ip_address_observer_list_;
426 const scoped_refptr<ObserverListThreadSafe<ConnectionTypeObserver>> 435 const scoped_refptr<ObserverListThreadSafe<ConnectionTypeObserver>>
427 connection_type_observer_list_; 436 connection_type_observer_list_;
428 const scoped_refptr<ObserverListThreadSafe<DNSObserver>> 437 const scoped_refptr<ObserverListThreadSafe<DNSObserver>>
429 resolver_state_observer_list_; 438 resolver_state_observer_list_;
430 const scoped_refptr<ObserverListThreadSafe<NetworkChangeObserver>> 439 const scoped_refptr<ObserverListThreadSafe<NetworkChangeObserver>>
(...skipping 12 matching lines...) Expand all
443 452
444 // Set true to disable non-test notifications (to prevent flakes in tests). 453 // Set true to disable non-test notifications (to prevent flakes in tests).
445 bool test_notifications_only_; 454 bool test_notifications_only_;
446 455
447 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); 456 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
448 }; 457 };
449 458
450 } // namespace net 459 } // namespace net
451 460
452 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 461 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
OLDNEW
« no previous file with comments | « net/android/network_change_notifier_factory_android.cc ('k') | net/base/network_change_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698