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

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

Issue 11360108: Start calculating new combined NetworkChangeNotifier signal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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 #include "net/base/network_change_notifier.h" 5 #include "net/base/network_change_notifier.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/synchronization/lock.h" 8 #include "base/synchronization/lock.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 17 matching lines...) Expand all
28 // in ways that would require us to place locks around access to this object. 28 // in ways that would require us to place locks around access to this object.
29 // (The prohibition on global non-POD objects makes it tricky to do such a thing 29 // (The prohibition on global non-POD objects makes it tricky to do such a thing
30 // anyway.) 30 // anyway.)
31 NetworkChangeNotifier* g_network_change_notifier = NULL; 31 NetworkChangeNotifier* g_network_change_notifier = NULL;
32 32
33 // Class factory singleton. 33 // Class factory singleton.
34 NetworkChangeNotifierFactory* g_network_change_notifier_factory = NULL; 34 NetworkChangeNotifierFactory* g_network_change_notifier_factory = NULL;
35 35
36 class MockNetworkChangeNotifier : public NetworkChangeNotifier { 36 class MockNetworkChangeNotifier : public NetworkChangeNotifier {
37 public: 37 public:
38 MockNetworkChangeNotifier() : NetworkChangeNotifier(0, 0, 0, 0) {}
38 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE { 39 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE {
39 return CONNECTION_UNKNOWN; 40 return CONNECTION_UNKNOWN;
40 } 41 }
41 }; 42 };
42 43
43 } // namespace 44 } // namespace
44 45
45 // The main observer class that records UMAs for network events. 46 // The main observer class that records UMAs for network events.
46 class HistogramWatcher 47 class HistogramWatcher
47 : public NetworkChangeNotifier::ConnectionTypeObserver, 48 : public NetworkChangeNotifier::ConnectionTypeObserver,
48 public NetworkChangeNotifier::IPAddressObserver, 49 public NetworkChangeNotifier::IPAddressObserver,
49 public NetworkChangeNotifier::DNSObserver { 50 public NetworkChangeNotifier::DNSObserver,
51 public NetworkChangeNotifier::NetworkChangeObserver {
50 public: 52 public:
51 HistogramWatcher() 53 HistogramWatcher()
52 : last_ip_address_change_(base::TimeTicks::Now()), 54 : last_ip_address_change_(base::TimeTicks::Now()),
53 last_connection_change_(base::TimeTicks::Now()), 55 last_connection_change_(base::TimeTicks::Now()),
54 last_dns_change_(base::TimeTicks::Now()), 56 last_dns_change_(base::TimeTicks::Now()),
57 last_network_change_(base::TimeTicks::Now()),
55 last_connection_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN), 58 last_connection_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN),
56 offline_packets_received_(0) {} 59 offline_packets_received_(0) {}
57 60
58 // Registers our three Observer implementations. This is called from the 61 // Registers our three Observer implementations. This is called from the
59 // network thread so that our Observer implementations are also called 62 // network thread so that our Observer implementations are also called
60 // from the network thread. This avoids multi-threaded race conditions 63 // from the network thread. This avoids multi-threaded race conditions
61 // because the only other interface, |NotifyDataReceived| is also 64 // because the only other interface, |NotifyDataReceived| is also
62 // only called from the network thread. 65 // only called from the network thread.
63 void Init() { 66 void Init() {
64 NetworkChangeNotifier::AddConnectionTypeObserver(this); 67 NetworkChangeNotifier::AddConnectionTypeObserver(this);
65 NetworkChangeNotifier::AddIPAddressObserver(this); 68 NetworkChangeNotifier::AddIPAddressObserver(this);
66 NetworkChangeNotifier::AddDNSObserver(this); 69 NetworkChangeNotifier::AddDNSObserver(this);
70 NetworkChangeNotifier::AddNetworkChangeObserver(this);
67 } 71 }
68 72
69 virtual ~HistogramWatcher() {} 73 virtual ~HistogramWatcher() {}
70 74
71 // NetworkChangeNotifier::IPAddressObserver implementation. 75 // NetworkChangeNotifier::IPAddressObserver implementation.
72 virtual void OnIPAddressChanged() OVERRIDE { 76 virtual void OnIPAddressChanged() OVERRIDE {
73 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.IPAddressChange", 77 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.IPAddressChange",
74 SinceLast(&last_ip_address_change_)); 78 SinceLast(&last_ip_address_change_));
79 UMA_HISTOGRAM_MEDIUM_TIMES(
80 "NCN.ConnectionTypeChangeToIPAddressChange",
81 last_ip_address_change_ - last_connection_change_);
75 } 82 }
76 83
77 // NetworkChangeNotifier::ConnectionTypeObserver implementation. 84 // NetworkChangeNotifier::ConnectionTypeObserver implementation.
78 virtual void OnConnectionTypeChanged( 85 virtual void OnConnectionTypeChanged(
79 NetworkChangeNotifier::ConnectionType type) OVERRIDE { 86 NetworkChangeNotifier::ConnectionType type) OVERRIDE {
80 if (type != NetworkChangeNotifier::CONNECTION_NONE) { 87 if (type != NetworkChangeNotifier::CONNECTION_NONE) {
81 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OnlineChange", 88 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OnlineChange",
82 SinceLast(&last_connection_change_)); 89 SinceLast(&last_connection_change_));
83 90
84 if (offline_packets_received_) { 91 if (offline_packets_received_) {
85 if ((last_connection_change_ - last_offline_packet_received_) < 92 if ((last_connection_change_ - last_offline_packet_received_) <
86 base::TimeDelta::FromSeconds(5)) { 93 base::TimeDelta::FromSeconds(5)) {
87 // We can compare this sum with the sum of NCN.OfflineDataRecv. 94 // We can compare this sum with the sum of NCN.OfflineDataRecv.
88 UMA_HISTOGRAM_COUNTS_10000( 95 UMA_HISTOGRAM_COUNTS_10000(
89 "NCN.OfflineDataRecvAny5sBeforeOnline", 96 "NCN.OfflineDataRecvAny5sBeforeOnline",
90 offline_packets_received_); 97 offline_packets_received_);
91 } 98 }
92 99
93 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline", 100 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline",
94 last_connection_change_ - 101 last_connection_change_ -
95 last_offline_packet_received_); 102 last_offline_packet_received_);
96 } 103 }
97 } else { 104 } else {
98 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange", 105 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange",
99 SinceLast(&last_connection_change_)); 106 SinceLast(&last_connection_change_));
100 } 107 }
108 UMA_HISTOGRAM_MEDIUM_TIMES(
109 "NCN.IPAddressChangeToConnectionTypeChange",
110 last_connection_change_ - last_ip_address_change_);
101 111
102 offline_packets_received_ = 0; 112 offline_packets_received_ = 0;
103 last_connection_type_ = type; 113 last_connection_type_ = type;
104 polling_interval_ = base::TimeDelta::FromSeconds(1); 114 polling_interval_ = base::TimeDelta::FromSeconds(1);
105 } 115 }
106 116
107 // NetworkChangeNotifier::DNSObserver implementation. 117 // NetworkChangeNotifier::DNSObserver implementation.
108 virtual void OnDNSChanged() OVERRIDE { 118 virtual void OnDNSChanged() OVERRIDE {
109 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.DNSConfigChange", 119 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.DNSConfigChange",
110 SinceLast(&last_dns_change_)); 120 SinceLast(&last_dns_change_));
111 } 121 }
112 122
123 // NetworkChangeNotifier::NetworkChangeObserver implementation.
124 virtual void OnNetworkChanged(
125 NetworkChangeNotifier::ConnectionType type) OVERRIDE {
126 if (type != NetworkChangeNotifier::CONNECTION_NONE) {
127 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOnlineChange",
128 SinceLast(&last_network_change_));
129 } else {
130 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOfflineChange",
131 SinceLast(&last_network_change_));
132 }
133 }
134
113 // Record histogram data whenever we receive a packet but think we're 135 // Record histogram data whenever we receive a packet but think we're
114 // offline. Should only be called from the network thread. 136 // offline. Should only be called from the network thread.
115 void NotifyDataReceived(const GURL& source) { 137 void NotifyDataReceived(const GURL& source) {
116 if (last_connection_type_ != NetworkChangeNotifier::CONNECTION_NONE || 138 if (last_connection_type_ != NetworkChangeNotifier::CONNECTION_NONE ||
117 IsLocalhost(source.host()) || 139 IsLocalhost(source.host()) ||
118 !(source.SchemeIs("http") || source.SchemeIs("https"))) { 140 !(source.SchemeIs("http") || source.SchemeIs("https"))) {
119 return; 141 return;
120 } 142 }
121 143
122 base::TimeTicks current_time = base::TimeTicks::Now(); 144 base::TimeTicks current_time = base::TimeTicks::Now();
(...skipping 23 matching lines...) Expand all
146 static base::TimeDelta SinceLast(base::TimeTicks *last_time) { 168 static base::TimeDelta SinceLast(base::TimeTicks *last_time) {
147 base::TimeTicks current_time = base::TimeTicks::Now(); 169 base::TimeTicks current_time = base::TimeTicks::Now();
148 base::TimeDelta delta = current_time - *last_time; 170 base::TimeDelta delta = current_time - *last_time;
149 *last_time = current_time; 171 *last_time = current_time;
150 return delta; 172 return delta;
151 } 173 }
152 174
153 base::TimeTicks last_ip_address_change_; 175 base::TimeTicks last_ip_address_change_;
154 base::TimeTicks last_connection_change_; 176 base::TimeTicks last_connection_change_;
155 base::TimeTicks last_dns_change_; 177 base::TimeTicks last_dns_change_;
178 base::TimeTicks last_network_change_;
156 base::TimeTicks last_offline_packet_received_; 179 base::TimeTicks last_offline_packet_received_;
157 base::TimeTicks last_polled_connection_; 180 base::TimeTicks last_polled_connection_;
158 // |polling_interval_| is initialized by |OnConnectionTypeChanged| on our 181 // |polling_interval_| is initialized by |OnConnectionTypeChanged| on our
159 // first transition to offline and on subsequent transitions. Once offline, 182 // first transition to offline and on subsequent transitions. Once offline,
160 // |polling_interval_| doubles as offline data is received and we poll 183 // |polling_interval_| doubles as offline data is received and we poll
161 // with |NetworkChangeNotifier::GetConnectionType| to verify the connection 184 // with |NetworkChangeNotifier::GetConnectionType| to verify the connection
162 // state. 185 // state.
163 base::TimeDelta polling_interval_; 186 base::TimeDelta polling_interval_;
164 // |last_connection_type_| is the last value passed to 187 // |last_connection_type_| is the last value passed to
165 // |OnConnectionTypeChanged|. 188 // |OnConnectionTypeChanged|.
(...skipping 20 matching lines...) Expand all
186 void SetDnsConfig(const DnsConfig& dns_config) { 209 void SetDnsConfig(const DnsConfig& dns_config) {
187 base::AutoLock lock(lock_); 210 base::AutoLock lock(lock_);
188 dns_config_ = dns_config; 211 dns_config_ = dns_config;
189 } 212 }
190 213
191 private: 214 private:
192 mutable base::Lock lock_; 215 mutable base::Lock lock_;
193 DnsConfig dns_config_; 216 DnsConfig dns_config_;
194 }; 217 };
195 218
219 // Calculates NetworkChange signal from IPAddress and ConnectionType signals.
220 class NetworkChangeNotifier::NetworkChangeCalculator
221 : public ConnectionTypeObserver,
222 public IPAddressObserver {
223 public:
224 // Delay arguments control how many milliseconds to delay notifications
225 // so as to combine duplicates. |ip_address_offline_delay_ms| controls
226 // delay after OnIPAddressChanged when transitioning from an offline state.
227 // |ip_address_online_delay_ms| controls delay after OnIPAddressChanged when
228 // transitioning from an online state. |connection_type_offline_delay_ms|
229 // controls delay after OnConnectionTypeChanged when transitioning from an
230 // offline state. |connection_type_online_delay_ms| controls delay after
231 // OnConnectionTypeChanged when transitioning from an online state.
szym 2012/11/25 07:37:37 This comment needs to explain that the notificatio
232 NetworkChangeCalculator(uint32 ip_address_offline_delay_ms,
233 uint32 ip_address_online_delay_ms,
234 uint32 connection_type_offline_delay_ms,
235 uint32 connection_type_online_delay_ms)
236 : ip_address_offline_delay_(base::TimeDelta::FromMilliseconds(
237 ip_address_offline_delay_ms)),
238 ip_address_online_delay_(base::TimeDelta::FromMilliseconds(
239 ip_address_online_delay_ms)),
240 connection_type_offline_delay_(base::TimeDelta::FromMilliseconds(
241 connection_type_offline_delay_ms)),
242 connection_type_online_delay_(base::TimeDelta::FromMilliseconds(
243 connection_type_online_delay_ms)),
244 have_announced_(false),
245 last_announced_connection_type_(CONNECTION_NONE),
246 pending_connection_type_(CONNECTION_NONE) {}
247 void Init() {
248 AddConnectionTypeObserver(this);
249 AddIPAddressObserver(this);
250 }
251 virtual ~NetworkChangeCalculator() {
252 RemoveConnectionTypeObserver(this);
253 RemoveIPAddressObserver(this);
254 }
255
256 // NetworkChangeNotifier::IPAddressObserver implementation.
szym 2012/11/25 07:37:37 nit: no need for "implementation"
pauljensen 2012/11/27 21:47:42 I see a lot of people using "implementation": URLR
257 virtual void OnIPAddressChanged() OVERRIDE {
258 base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE
259 ? ip_address_offline_delay_ : ip_address_online_delay_;
260 timer_.Start(FROM_HERE, delay, this, &NetworkChangeCalculator::Notify);
szym 2012/11/25 07:37:37 Perhaps a note (a reminder really) that this cance
261 }
262
263 // NetworkChangeNotifier::ConnectionTypeObserver implementation.
264 virtual void OnConnectionTypeChanged(ConnectionType type) OVERRIDE {
265 pending_connection_type_ = type;
266 base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE
267 ? connection_type_offline_delay_ : connection_type_online_delay_;
268 timer_.Start(FROM_HERE, delay, this, &NetworkChangeCalculator::Notify);
269 }
270
271 private:
272 void Notify() {
273 // Don't bother signaling about dead connections.
274 if (have_announced_ && last_announced_connection_type_ == CONNECTION_NONE &&
szym 2012/11/25 07:37:37 suggest parens for readability
275 pending_connection_type_ == CONNECTION_NONE)
szym 2012/11/25 07:37:37 Could the same logic be accomplished by initializi
pauljensen 2012/11/27 21:47:42 The timeouts are essential for all announcements;
276 return;
szym 2012/11/25 07:37:37 use braces when if condition is multiline
277 have_announced_ = true;
278 last_announced_connection_type_ = pending_connection_type_;
279 // Immediately before sending out an online signal, send out an offline
280 // signal to perform any destructive actions before constructive actions.
281 if (pending_connection_type_ != CONNECTION_NONE)
282 NetworkChangeNotifier::NotifyObserversOfNetworkChange(CONNECTION_NONE);
283 NetworkChangeNotifier::NotifyObserversOfNetworkChange(
284 pending_connection_type_);
285 }
286
287 const base::TimeDelta ip_address_offline_delay_;
288 const base::TimeDelta ip_address_online_delay_;
289 const base::TimeDelta connection_type_offline_delay_;
290 const base::TimeDelta connection_type_online_delay_;
291
292 // Indicates if NotifyObserversOfNetworkChange has been called yet.
293 bool have_announced_;
294 // Last value passed to NotifyObserversOfNetworkChange.
295 ConnectionType last_announced_connection_type_;
296 // Value to pass to NotifyObserversOfNetworkChange when Notify is called.
297 ConnectionType pending_connection_type_;
298 // Used to delay notifications so duplicates can be combined.
299 base::OneShotTimer<NetworkChangeCalculator> timer_;
300 };
301
196 NetworkChangeNotifier::~NetworkChangeNotifier() { 302 NetworkChangeNotifier::~NetworkChangeNotifier() {
197 DCHECK_EQ(this, g_network_change_notifier); 303 DCHECK_EQ(this, g_network_change_notifier);
198 g_network_change_notifier = NULL; 304 g_network_change_notifier = NULL;
199 } 305 }
200 306
201 // static 307 // static
202 void NetworkChangeNotifier::SetFactory( 308 void NetworkChangeNotifier::SetFactory(
203 NetworkChangeNotifierFactory* factory) { 309 NetworkChangeNotifierFactory* factory) {
204 CHECK(!g_network_change_notifier_factory); 310 CHECK(!g_network_change_notifier_factory);
205 g_network_change_notifier_factory = factory; 311 g_network_change_notifier_factory = factory;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 445 }
340 } 446 }
341 447
342 void NetworkChangeNotifier::AddDNSObserver(DNSObserver* observer) { 448 void NetworkChangeNotifier::AddDNSObserver(DNSObserver* observer) {
343 if (g_network_change_notifier) { 449 if (g_network_change_notifier) {
344 g_network_change_notifier->resolver_state_observer_list_->AddObserver( 450 g_network_change_notifier->resolver_state_observer_list_->AddObserver(
345 observer); 451 observer);
346 } 452 }
347 } 453 }
348 454
455 void NetworkChangeNotifier::AddNetworkChangeObserver(
456 NetworkChangeObserver* observer) {
457 if (g_network_change_notifier) {
458 g_network_change_notifier->network_change_observer_list_->AddObserver(
459 observer);
460 }
461 }
462
349 void NetworkChangeNotifier::RemoveIPAddressObserver( 463 void NetworkChangeNotifier::RemoveIPAddressObserver(
350 IPAddressObserver* observer) { 464 IPAddressObserver* observer) {
351 if (g_network_change_notifier) { 465 if (g_network_change_notifier) {
352 g_network_change_notifier->ip_address_observer_list_->RemoveObserver( 466 g_network_change_notifier->ip_address_observer_list_->RemoveObserver(
353 observer); 467 observer);
354 } 468 }
355 } 469 }
356 470
357 void NetworkChangeNotifier::RemoveConnectionTypeObserver( 471 void NetworkChangeNotifier::RemoveConnectionTypeObserver(
358 ConnectionTypeObserver* observer) { 472 ConnectionTypeObserver* observer) {
359 if (g_network_change_notifier) { 473 if (g_network_change_notifier) {
360 g_network_change_notifier->connection_type_observer_list_->RemoveObserver( 474 g_network_change_notifier->connection_type_observer_list_->RemoveObserver(
361 observer); 475 observer);
362 } 476 }
363 } 477 }
364 478
365 void NetworkChangeNotifier::RemoveDNSObserver(DNSObserver* observer) { 479 void NetworkChangeNotifier::RemoveDNSObserver(DNSObserver* observer) {
366 if (g_network_change_notifier) { 480 if (g_network_change_notifier) {
367 g_network_change_notifier->resolver_state_observer_list_->RemoveObserver( 481 g_network_change_notifier->resolver_state_observer_list_->RemoveObserver(
368 observer); 482 observer);
369 } 483 }
370 } 484 }
371 485
372 NetworkChangeNotifier::NetworkChangeNotifier() 486 void NetworkChangeNotifier::RemoveNetworkChangeObserver(
487 NetworkChangeObserver* observer) {
488 if (g_network_change_notifier) {
489 g_network_change_notifier->network_change_observer_list_->RemoveObserver(
490 observer);
491 }
492 }
493
494 NetworkChangeNotifier::NetworkChangeNotifier(
495 uint32 ip_address_offline_delay_ms,
496 uint32 ip_address_online_delay_ms,
497 uint32 connection_type_offline_delay_ms,
498 uint32 connection_type_online_delay_ms)
373 : ip_address_observer_list_( 499 : ip_address_observer_list_(
374 new ObserverListThreadSafe<IPAddressObserver>( 500 new ObserverListThreadSafe<IPAddressObserver>(
375 ObserverListBase<IPAddressObserver>::NOTIFY_EXISTING_ONLY)), 501 ObserverListBase<IPAddressObserver>::NOTIFY_EXISTING_ONLY)),
376 connection_type_observer_list_( 502 connection_type_observer_list_(
377 new ObserverListThreadSafe<ConnectionTypeObserver>( 503 new ObserverListThreadSafe<ConnectionTypeObserver>(
378 ObserverListBase<ConnectionTypeObserver>::NOTIFY_EXISTING_ONLY)), 504 ObserverListBase<ConnectionTypeObserver>::NOTIFY_EXISTING_ONLY)),
379 resolver_state_observer_list_( 505 resolver_state_observer_list_(
380 new ObserverListThreadSafe<DNSObserver>( 506 new ObserverListThreadSafe<DNSObserver>(
381 ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)), 507 ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)),
508 network_change_observer_list_(
509 new ObserverListThreadSafe<NetworkChangeObserver>(
510 ObserverListBase<NetworkChangeObserver>::NOTIFY_EXISTING_ONLY)),
382 network_state_(new NetworkState()), 511 network_state_(new NetworkState()),
383 histogram_watcher_(new HistogramWatcher()) { 512 histogram_watcher_(new HistogramWatcher()),
513 network_change_calculator_(new NetworkChangeCalculator(
514 ip_address_offline_delay_ms,
515 ip_address_online_delay_ms,
516 connection_type_offline_delay_ms,
517 connection_type_online_delay_ms)) {
384 DCHECK(!g_network_change_notifier); 518 DCHECK(!g_network_change_notifier);
385 g_network_change_notifier = this; 519 g_network_change_notifier = this;
520 network_change_calculator_->Init();
386 } 521 }
387 522
388 #if defined(OS_LINUX) 523 #if defined(OS_LINUX)
389 const internal::AddressTrackerLinux* 524 const internal::AddressTrackerLinux*
390 NetworkChangeNotifier::GetAddressTrackerInternal() const { 525 NetworkChangeNotifier::GetAddressTrackerInternal() const {
391 return NULL; 526 return NULL;
392 } 527 }
393 #endif 528 #endif
394 529
395 // static 530 // static
(...skipping 21 matching lines...) Expand all
417 } 552 }
418 553
419 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() { 554 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() {
420 if (g_network_change_notifier) { 555 if (g_network_change_notifier) {
421 g_network_change_notifier->connection_type_observer_list_->Notify( 556 g_network_change_notifier->connection_type_observer_list_->Notify(
422 &ConnectionTypeObserver::OnConnectionTypeChanged, 557 &ConnectionTypeObserver::OnConnectionTypeChanged,
423 GetConnectionType()); 558 GetConnectionType());
424 } 559 }
425 } 560 }
426 561
562 void NetworkChangeNotifier::NotifyObserversOfNetworkChange(
563 ConnectionType type) {
564 if (g_network_change_notifier) {
565 g_network_change_notifier->network_change_observer_list_->Notify(
566 &NetworkChangeObserver::OnNetworkChanged,
567 type);
568 }
569 }
570
427 NetworkChangeNotifier::DisableForTest::DisableForTest() 571 NetworkChangeNotifier::DisableForTest::DisableForTest()
428 : network_change_notifier_(g_network_change_notifier) { 572 : network_change_notifier_(g_network_change_notifier) {
429 DCHECK(g_network_change_notifier); 573 DCHECK(g_network_change_notifier);
430 g_network_change_notifier = NULL; 574 g_network_change_notifier = NULL;
431 } 575 }
432 576
433 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 577 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
434 DCHECK(!g_network_change_notifier); 578 DCHECK(!g_network_change_notifier);
435 g_network_change_notifier = network_change_notifier_; 579 g_network_change_notifier = network_change_notifier_;
436 } 580 }
437 581
438 } // namespace net 582 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698