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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | 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 "base/threading/thread_checker.h" 9 #include "base/threading/thread_checker.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 27 matching lines...) Expand all
38 class MockNetworkChangeNotifier : public NetworkChangeNotifier { 38 class MockNetworkChangeNotifier : public NetworkChangeNotifier {
39 public: 39 public:
40 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE { 40 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE {
41 return CONNECTION_UNKNOWN; 41 return CONNECTION_UNKNOWN;
42 } 42 }
43 }; 43 };
44 44
45 } // namespace 45 } // namespace
46 46
47 // The main observer class that records UMAs for network events. 47 // The main observer class that records UMAs for network events.
48 class HistogramWatcher 48 class HistogramWatcher : public NetworkChangeNotifier::ConnectionTypeObserver,
49 : public NetworkChangeNotifier::ConnectionTypeObserver, 49 public NetworkChangeNotifier::IPAddressObserver,
50 public NetworkChangeNotifier::IPAddressObserver, 50 public NetworkChangeNotifier::DNSObserver,
51 public NetworkChangeNotifier::DNSObserver, 51 public NetworkChangeNotifier::NetworkChangeObserver {
52 public NetworkChangeNotifier::NetworkChangeObserver {
53 public: 52 public:
54 HistogramWatcher() 53 HistogramWatcher()
55 : last_ip_address_change_(base::TimeTicks::Now()), 54 : last_ip_address_change_(base::TimeTicks::Now()),
56 last_connection_change_(base::TimeTicks::Now()), 55 last_connection_change_(base::TimeTicks::Now()),
57 last_dns_change_(base::TimeTicks::Now()), 56 last_dns_change_(base::TimeTicks::Now()),
58 last_network_change_(base::TimeTicks::Now()), 57 last_network_change_(base::TimeTicks::Now()),
59 last_connection_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN), 58 last_connection_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN),
60 offline_packets_received_(0), 59 offline_packets_received_(0),
61 bytes_read_since_last_connection_change_(0), 60 bytes_read_since_last_connection_change_(0),
62 peak_kbps_since_last_connection_change_(0) {} 61 peak_kbps_since_last_connection_change_(0) {}
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 break; 209 break;
211 } 210 }
212 211
213 if (type != NetworkChangeNotifier::CONNECTION_NONE) { 212 if (type != NetworkChangeNotifier::CONNECTION_NONE) {
214 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OnlineChange", state_duration); 213 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OnlineChange", state_duration);
215 214
216 if (offline_packets_received_) { 215 if (offline_packets_received_) {
217 if ((now - last_offline_packet_received_) < 216 if ((now - last_offline_packet_received_) <
218 base::TimeDelta::FromSeconds(5)) { 217 base::TimeDelta::FromSeconds(5)) {
219 // We can compare this sum with the sum of NCN.OfflineDataRecv. 218 // We can compare this sum with the sum of NCN.OfflineDataRecv.
220 UMA_HISTOGRAM_COUNTS_10000( 219 UMA_HISTOGRAM_COUNTS_10000("NCN.OfflineDataRecvAny5sBeforeOnline",
221 "NCN.OfflineDataRecvAny5sBeforeOnline", 220 offline_packets_received_);
222 offline_packets_received_);
223 } 221 }
224 222
225 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline", 223 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline",
226 now - last_offline_packet_received_); 224 now - last_offline_packet_received_);
227 } 225 }
228 } else { 226 } else {
229 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange", state_duration); 227 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange", state_duration);
230 } 228 }
231 UMA_HISTOGRAM_MEDIUM_TIMES( 229 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.IPAddressChangeToConnectionTypeChange",
232 "NCN.IPAddressChangeToConnectionTypeChange", 230 now - last_ip_address_change_);
233 now - last_ip_address_change_);
234 231
235 offline_packets_received_ = 0; 232 offline_packets_received_ = 0;
236 bytes_read_since_last_connection_change_ = 0; 233 bytes_read_since_last_connection_change_ = 0;
237 peak_kbps_since_last_connection_change_ = 0; 234 peak_kbps_since_last_connection_change_ = 0;
238 last_connection_type_ = type; 235 last_connection_type_ = type;
239 polling_interval_ = base::TimeDelta::FromSeconds(1); 236 polling_interval_ = base::TimeDelta::FromSeconds(1);
240 } 237 }
241 238
242 // NetworkChangeNotifier::DNSObserver implementation. 239 // NetworkChangeNotifier::DNSObserver implementation.
243 virtual void OnDNSChanged() OVERRIDE { 240 virtual void OnDNSChanged() OVERRIDE {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 return; 288 return;
292 289
293 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecv", 290 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecv",
294 now - last_connection_change_); 291 now - last_connection_change_);
295 offline_packets_received_++; 292 offline_packets_received_++;
296 last_offline_packet_received_ = now; 293 last_offline_packet_received_ = now;
297 294
298 if ((now - last_polled_connection_) > polling_interval_) { 295 if ((now - last_polled_connection_) > polling_interval_) {
299 polling_interval_ *= 2; 296 polling_interval_ *= 2;
300 last_polled_connection_ = now; 297 last_polled_connection_ = now;
301 last_polled_connection_type_ = 298 last_polled_connection_type_ = NetworkChangeNotifier::GetConnectionType();
302 NetworkChangeNotifier::GetConnectionType();
303 } 299 }
304 if (last_polled_connection_type_ == 300 if (last_polled_connection_type_ ==
305 NetworkChangeNotifier::CONNECTION_NONE) { 301 NetworkChangeNotifier::CONNECTION_NONE) {
306 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.PollingOfflineDataRecv", 302 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.PollingOfflineDataRecv",
307 now - last_connection_change_); 303 now - last_connection_change_);
308 } 304 }
309 } 305 }
310 306
311 private: 307 private:
312 static base::TimeDelta SinceLast(base::TimeTicks *last_time) { 308 static base::TimeDelta SinceLast(base::TimeTicks* last_time) {
313 base::TimeTicks current_time = base::TimeTicks::Now(); 309 base::TimeTicks current_time = base::TimeTicks::Now();
314 base::TimeDelta delta = current_time - *last_time; 310 base::TimeDelta delta = current_time - *last_time;
315 *last_time = current_time; 311 *last_time = current_time;
316 return delta; 312 return delta;
317 } 313 }
318 314
319 base::TimeTicks last_ip_address_change_; 315 base::TimeTicks last_ip_address_change_;
320 base::TimeTicks last_connection_change_; 316 base::TimeTicks last_connection_change_;
321 base::TimeTicks last_dns_change_; 317 base::TimeTicks last_dns_change_;
322 base::TimeTicks last_network_change_; 318 base::TimeTicks last_network_change_;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 DCHECK(thread_checker_.CalledOnValidThread()); 400 DCHECK(thread_checker_.CalledOnValidThread());
405 DCHECK(g_network_change_notifier); 401 DCHECK(g_network_change_notifier);
406 RemoveConnectionTypeObserver(this); 402 RemoveConnectionTypeObserver(this);
407 RemoveIPAddressObserver(this); 403 RemoveIPAddressObserver(this);
408 } 404 }
409 405
410 // NetworkChangeNotifier::IPAddressObserver implementation. 406 // NetworkChangeNotifier::IPAddressObserver implementation.
411 virtual void OnIPAddressChanged() OVERRIDE { 407 virtual void OnIPAddressChanged() OVERRIDE {
412 DCHECK(thread_checker_.CalledOnValidThread()); 408 DCHECK(thread_checker_.CalledOnValidThread());
413 base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE 409 base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE
414 ? params_.ip_address_offline_delay_ : params_.ip_address_online_delay_; 410 ? params_.ip_address_offline_delay_
411 : params_.ip_address_online_delay_;
415 // Cancels any previous timer. 412 // Cancels any previous timer.
416 timer_.Start(FROM_HERE, delay, this, &NetworkChangeCalculator::Notify); 413 timer_.Start(FROM_HERE, delay, this, &NetworkChangeCalculator::Notify);
417 } 414 }
418 415
419 // NetworkChangeNotifier::ConnectionTypeObserver implementation. 416 // NetworkChangeNotifier::ConnectionTypeObserver implementation.
420 virtual void OnConnectionTypeChanged(ConnectionType type) OVERRIDE { 417 virtual void OnConnectionTypeChanged(ConnectionType type) OVERRIDE {
421 DCHECK(thread_checker_.CalledOnValidThread()); 418 DCHECK(thread_checker_.CalledOnValidThread());
422 pending_connection_type_ = type; 419 pending_connection_type_ = type;
423 base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE 420 base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE
424 ? params_.connection_type_offline_delay_ 421 ? params_.connection_type_offline_delay_
425 : params_.connection_type_online_delay_; 422 : params_.connection_type_online_delay_;
426 // Cancels any previous timer. 423 // Cancels any previous timer.
427 timer_.Start(FROM_HERE, delay, this, &NetworkChangeCalculator::Notify); 424 timer_.Start(FROM_HERE, delay, this, &NetworkChangeCalculator::Notify);
428 } 425 }
429 426
430 private: 427 private:
431 void Notify() { 428 void Notify() {
432 DCHECK(thread_checker_.CalledOnValidThread()); 429 DCHECK(thread_checker_.CalledOnValidThread());
433 // Don't bother signaling about dead connections. 430 // Don't bother signaling about dead connections.
434 if (have_announced_ && 431 if (have_announced_ &&
435 (last_announced_connection_type_ == CONNECTION_NONE) && 432 (last_announced_connection_type_ == CONNECTION_NONE) &&
(...skipping 26 matching lines...) Expand all
462 DISALLOW_COPY_AND_ASSIGN(NetworkChangeCalculator); 459 DISALLOW_COPY_AND_ASSIGN(NetworkChangeCalculator);
463 }; 460 };
464 461
465 NetworkChangeNotifier::~NetworkChangeNotifier() { 462 NetworkChangeNotifier::~NetworkChangeNotifier() {
466 network_change_calculator_.reset(); 463 network_change_calculator_.reset();
467 DCHECK_EQ(this, g_network_change_notifier); 464 DCHECK_EQ(this, g_network_change_notifier);
468 g_network_change_notifier = NULL; 465 g_network_change_notifier = NULL;
469 } 466 }
470 467
471 // static 468 // static
472 void NetworkChangeNotifier::SetFactory( 469 void NetworkChangeNotifier::SetFactory(NetworkChangeNotifierFactory* factory) {
473 NetworkChangeNotifierFactory* factory) {
474 CHECK(!g_network_change_notifier_factory); 470 CHECK(!g_network_change_notifier_factory);
475 g_network_change_notifier_factory = factory; 471 g_network_change_notifier_factory = factory;
476 } 472 }
477 473
478 // static 474 // static
479 NetworkChangeNotifier* NetworkChangeNotifier::Create() { 475 NetworkChangeNotifier* NetworkChangeNotifier::Create() {
480 if (g_network_change_notifier_factory) 476 if (g_network_change_notifier_factory)
481 return g_network_change_notifier_factory->CreateInstance(); 477 return g_network_change_notifier_factory->CreateInstance();
482 478
483 #if defined(OS_WIN) 479 #if defined(OS_WIN)
484 NetworkChangeNotifierWin* network_change_notifier = 480 NetworkChangeNotifierWin* network_change_notifier =
485 new NetworkChangeNotifierWin(); 481 new NetworkChangeNotifierWin();
486 network_change_notifier->WatchForAddressChange(); 482 network_change_notifier->WatchForAddressChange();
487 return network_change_notifier; 483 return network_change_notifier;
488 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID) 484 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID)
489 // ChromeOS and Android builds MUST use their own class factory. 485 // ChromeOS and Android builds MUST use their own class factory.
490 #if !defined(OS_CHROMEOS) 486 #if !defined(OS_CHROMEOS)
491 // TODO(oshima): ash_shell do not have access to chromeos'es 487 // TODO(oshima): ash_shell do not have access to chromeos'es
492 // notifier yet. Re-enable this when chromeos'es notifier moved to 488 // notifier yet. Re-enable this when chromeos'es notifier moved to
493 // chromeos root directory. crbug.com/119298. 489 // chromeos root directory. crbug.com/119298.
494 CHECK(false); 490 CHECK(false);
495 #endif 491 #endif
496 return NULL; 492 return NULL;
497 #elif defined(OS_LINUX) 493 #elif defined(OS_LINUX)
498 return NetworkChangeNotifierLinux::Create(); 494 return NetworkChangeNotifierLinux::Create();
499 #elif defined(OS_MACOSX) 495 #elif defined(OS_MACOSX)
500 return new NetworkChangeNotifierMac(); 496 return new NetworkChangeNotifierMac();
501 #else 497 #else
502 NOTIMPLEMENTED(); 498 NOTIMPLEMENTED();
503 return NULL; 499 return NULL;
504 #endif 500 #endif
505 } 501 }
506 502
507 // static 503 // static
508 NetworkChangeNotifier::ConnectionType 504 NetworkChangeNotifier::ConnectionType
509 NetworkChangeNotifier::GetConnectionType() { 505 NetworkChangeNotifier::GetConnectionType() {
510 return g_network_change_notifier ? 506 return g_network_change_notifier
511 g_network_change_notifier->GetCurrentConnectionType() : 507 ? g_network_change_notifier->GetCurrentConnectionType()
512 CONNECTION_UNKNOWN; 508 : CONNECTION_UNKNOWN;
513 } 509 }
514 510
515 // static 511 // static
516 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { 512 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) {
517 if (!g_network_change_notifier) { 513 if (!g_network_change_notifier) {
518 *config = DnsConfig(); 514 *config = DnsConfig();
519 } else { 515 } else {
520 g_network_change_notifier->network_state_->GetDnsConfig(config); 516 g_network_change_notifier->network_state_->GetDnsConfig(config);
521 } 517 }
522 } 518 }
523 519
524 // static 520 // static
525 const char* NetworkChangeNotifier::ConnectionTypeToString( 521 const char* NetworkChangeNotifier::ConnectionTypeToString(ConnectionType type) {
526 ConnectionType type) {
527 static const char* kConnectionTypeNames[] = { 522 static const char* kConnectionTypeNames[] = {
528 "CONNECTION_UNKNOWN", 523 "CONNECTION_UNKNOWN", "CONNECTION_ETHERNET", "CONNECTION_WIFI",
529 "CONNECTION_ETHERNET", 524 "CONNECTION_2G", "CONNECTION_3G", "CONNECTION_4G",
530 "CONNECTION_WIFI", 525 "CONNECTION_NONE"};
531 "CONNECTION_2G", 526 COMPILE_ASSERT(arraysize(kConnectionTypeNames) ==
532 "CONNECTION_3G", 527 NetworkChangeNotifier::CONNECTION_NONE + 1,
533 "CONNECTION_4G", 528 ConnectionType_name_count_mismatch);
534 "CONNECTION_NONE"
535 };
536 COMPILE_ASSERT(
537 arraysize(kConnectionTypeNames) ==
538 NetworkChangeNotifier::CONNECTION_NONE + 1,
539 ConnectionType_name_count_mismatch);
540 if (type < CONNECTION_UNKNOWN || type > CONNECTION_NONE) { 529 if (type < CONNECTION_UNKNOWN || type > CONNECTION_NONE) {
541 NOTREACHED(); 530 NOTREACHED();
542 return "CONNECTION_INVALID"; 531 return "CONNECTION_INVALID";
543 } 532 }
544 return kConnectionTypeNames[type]; 533 return kConnectionTypeNames[type];
545 } 534 }
546 535
547 // static 536 // static
548 void NetworkChangeNotifier::NotifyDataReceived(const URLRequest& request, 537 void NetworkChangeNotifier::NotifyDataReceived(const URLRequest& request,
549 int bytes_read) { 538 int bytes_read) {
(...skipping 17 matching lines...) Expand all
567 void NetworkChangeNotifier::ShutdownHistogramWatcher() { 556 void NetworkChangeNotifier::ShutdownHistogramWatcher() {
568 if (!g_network_change_notifier) 557 if (!g_network_change_notifier)
569 return; 558 return;
570 g_network_change_notifier->histogram_watcher_.reset(); 559 g_network_change_notifier->histogram_watcher_.reset();
571 } 560 }
572 561
573 #if defined(OS_LINUX) 562 #if defined(OS_LINUX)
574 // static 563 // static
575 const internal::AddressTrackerLinux* 564 const internal::AddressTrackerLinux*
576 NetworkChangeNotifier::GetAddressTracker() { 565 NetworkChangeNotifier::GetAddressTracker() {
577 return g_network_change_notifier ? 566 return g_network_change_notifier
578 g_network_change_notifier->GetAddressTrackerInternal() : NULL; 567 ? g_network_change_notifier->GetAddressTrackerInternal()
568 : NULL;
579 } 569 }
580 #endif 570 #endif
581 571
582 // static 572 // static
583 bool NetworkChangeNotifier::IsOffline() { 573 bool NetworkChangeNotifier::IsOffline() {
584 return GetConnectionType() == CONNECTION_NONE; 574 return GetConnectionType() == CONNECTION_NONE;
585 } 575 }
586 576
587 // static 577 // static
588 bool NetworkChangeNotifier::IsConnectionCellular(ConnectionType type) { 578 bool NetworkChangeNotifier::IsConnectionCellular(ConnectionType type) {
589 bool is_cellular = false; 579 bool is_cellular = false;
590 switch (type) { 580 switch (type) {
591 case CONNECTION_2G: 581 case CONNECTION_2G:
592 case CONNECTION_3G: 582 case CONNECTION_3G:
593 case CONNECTION_4G: 583 case CONNECTION_4G:
594 is_cellular = true; 584 is_cellular = true;
595 break; 585 break;
596 case CONNECTION_UNKNOWN: 586 case CONNECTION_UNKNOWN:
597 case CONNECTION_ETHERNET: 587 case CONNECTION_ETHERNET:
598 case CONNECTION_WIFI: 588 case CONNECTION_WIFI:
599 case CONNECTION_NONE: 589 case CONNECTION_NONE:
600 is_cellular = false; 590 is_cellular = false;
601 break; 591 break;
602 } 592 }
603 return is_cellular; 593 return is_cellular;
604 } 594 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 void NetworkChangeNotifier::RemoveNetworkChangeObserver( 652 void NetworkChangeNotifier::RemoveNetworkChangeObserver(
663 NetworkChangeObserver* observer) { 653 NetworkChangeObserver* observer) {
664 if (g_network_change_notifier) { 654 if (g_network_change_notifier) {
665 g_network_change_notifier->network_change_observer_list_->RemoveObserver( 655 g_network_change_notifier->network_change_observer_list_->RemoveObserver(
666 observer); 656 observer);
667 } 657 }
668 } 658 }
669 659
670 NetworkChangeNotifier::NetworkChangeNotifier( 660 NetworkChangeNotifier::NetworkChangeNotifier(
671 const NetworkChangeCalculatorParams& params 661 const NetworkChangeCalculatorParams& params
672 /*= NetworkChangeCalculatorParams()*/) 662 /*= NetworkChangeCalculatorParams()*/)
673 : ip_address_observer_list_( 663 : ip_address_observer_list_(new ObserverListThreadSafe<IPAddressObserver>(
674 new ObserverListThreadSafe<IPAddressObserver>( 664 ObserverListBase<IPAddressObserver>::NOTIFY_EXISTING_ONLY)),
675 ObserverListBase<IPAddressObserver>::NOTIFY_EXISTING_ONLY)),
676 connection_type_observer_list_( 665 connection_type_observer_list_(
677 new ObserverListThreadSafe<ConnectionTypeObserver>( 666 new ObserverListThreadSafe<ConnectionTypeObserver>(
678 ObserverListBase<ConnectionTypeObserver>::NOTIFY_EXISTING_ONLY)), 667 ObserverListBase<ConnectionTypeObserver>::NOTIFY_EXISTING_ONLY)),
679 resolver_state_observer_list_( 668 resolver_state_observer_list_(new ObserverListThreadSafe<DNSObserver>(
680 new ObserverListThreadSafe<DNSObserver>( 669 ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)),
681 ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)),
682 network_change_observer_list_( 670 network_change_observer_list_(
683 new ObserverListThreadSafe<NetworkChangeObserver>( 671 new ObserverListThreadSafe<NetworkChangeObserver>(
684 ObserverListBase<NetworkChangeObserver>::NOTIFY_EXISTING_ONLY)), 672 ObserverListBase<NetworkChangeObserver>::NOTIFY_EXISTING_ONLY)),
685 network_state_(new NetworkState()), 673 network_state_(new NetworkState()),
686 network_change_calculator_(new NetworkChangeCalculator(params)) { 674 network_change_calculator_(new NetworkChangeCalculator(params)) {
687 DCHECK(!g_network_change_notifier); 675 DCHECK(!g_network_change_notifier);
688 g_network_change_notifier = this; 676 g_network_change_notifier = this;
689 network_change_calculator_->Init(); 677 network_change_calculator_->Init();
690 } 678 }
691 679
692 #if defined(OS_LINUX) 680 #if defined(OS_LINUX)
693 const internal::AddressTrackerLinux* 681 const internal::AddressTrackerLinux*
694 NetworkChangeNotifier::GetAddressTrackerInternal() const { 682 NetworkChangeNotifier::GetAddressTrackerInternal() const {
(...skipping 21 matching lines...) Expand all
716 void NetworkChangeNotifier::SetDnsConfig(const DnsConfig& config) { 704 void NetworkChangeNotifier::SetDnsConfig(const DnsConfig& config) {
717 if (!g_network_change_notifier) 705 if (!g_network_change_notifier)
718 return; 706 return;
719 g_network_change_notifier->network_state_->SetDnsConfig(config); 707 g_network_change_notifier->network_state_->SetDnsConfig(config);
720 NotifyObserversOfDNSChange(); 708 NotifyObserversOfDNSChange();
721 } 709 }
722 710
723 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() { 711 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() {
724 if (g_network_change_notifier) { 712 if (g_network_change_notifier) {
725 g_network_change_notifier->connection_type_observer_list_->Notify( 713 g_network_change_notifier->connection_type_observer_list_->Notify(
726 &ConnectionTypeObserver::OnConnectionTypeChanged, 714 &ConnectionTypeObserver::OnConnectionTypeChanged, GetConnectionType());
727 GetConnectionType());
728 } 715 }
729 } 716 }
730 717
731 void NetworkChangeNotifier::NotifyObserversOfNetworkChange( 718 void NetworkChangeNotifier::NotifyObserversOfNetworkChange(
732 ConnectionType type) { 719 ConnectionType type) {
733 if (g_network_change_notifier) { 720 if (g_network_change_notifier) {
734 g_network_change_notifier->network_change_observer_list_->Notify( 721 g_network_change_notifier->network_change_observer_list_->Notify(
735 &NetworkChangeObserver::OnNetworkChanged, 722 &NetworkChangeObserver::OnNetworkChanged, type);
736 type);
737 } 723 }
738 } 724 }
739 725
740 NetworkChangeNotifier::DisableForTest::DisableForTest() 726 NetworkChangeNotifier::DisableForTest::DisableForTest()
741 : network_change_notifier_(g_network_change_notifier) { 727 : network_change_notifier_(g_network_change_notifier) {
742 DCHECK(g_network_change_notifier); 728 DCHECK(g_network_change_notifier);
743 g_network_change_notifier = NULL; 729 g_network_change_notifier = NULL;
744 } 730 }
745 731
746 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 732 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
747 DCHECK(!g_network_change_notifier); 733 DCHECK(!g_network_change_notifier);
748 g_network_change_notifier = network_change_notifier_; 734 g_network_change_notifier = network_change_notifier_;
749 } 735 }
750 736
751 } // namespace net 737 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698