| 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 #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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 void SetDnsConfig(const DnsConfig& dns_config) { | 380 void SetDnsConfig(const DnsConfig& dns_config) { |
| 381 base::AutoLock lock(lock_); | 381 base::AutoLock lock(lock_); |
| 382 dns_config_ = dns_config; | 382 dns_config_ = dns_config; |
| 383 } | 383 } |
| 384 | 384 |
| 385 private: | 385 private: |
| 386 mutable base::Lock lock_; | 386 mutable base::Lock lock_; |
| 387 DnsConfig dns_config_; | 387 DnsConfig dns_config_; |
| 388 }; | 388 }; |
| 389 | 389 |
| 390 NetworkChangeNotifier::WifiApInfo::WifiApInfo() { |
| 391 } |
| 392 |
| 393 NetworkChangeNotifier::WifiApInfo::~WifiApInfo() { |
| 394 } |
| 395 |
| 390 NetworkChangeNotifier::NetworkChangeCalculatorParams:: | 396 NetworkChangeNotifier::NetworkChangeCalculatorParams:: |
| 391 NetworkChangeCalculatorParams() { | 397 NetworkChangeCalculatorParams() { |
| 392 } | 398 } |
| 393 | 399 |
| 394 // Calculates NetworkChange signal from IPAddress and ConnectionType signals. | 400 // Calculates NetworkChange signal from IPAddress and ConnectionType signals. |
| 395 class NetworkChangeNotifier::NetworkChangeCalculator | 401 class NetworkChangeNotifier::NetworkChangeCalculator |
| 396 : public ConnectionTypeObserver, | 402 : public ConnectionTypeObserver, |
| 397 public IPAddressObserver { | 403 public IPAddressObserver { |
| 398 public: | 404 public: |
| 399 NetworkChangeCalculator(const NetworkChangeCalculatorParams& params) | 405 NetworkChangeCalculator(const NetworkChangeCalculatorParams& params) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 | 521 |
| 516 // static | 522 // static |
| 517 NetworkChangeNotifier::ConnectionType | 523 NetworkChangeNotifier::ConnectionType |
| 518 NetworkChangeNotifier::GetConnectionType() { | 524 NetworkChangeNotifier::GetConnectionType() { |
| 519 return g_network_change_notifier ? | 525 return g_network_change_notifier ? |
| 520 g_network_change_notifier->GetCurrentConnectionType() : | 526 g_network_change_notifier->GetCurrentConnectionType() : |
| 521 CONNECTION_UNKNOWN; | 527 CONNECTION_UNKNOWN; |
| 522 } | 528 } |
| 523 | 529 |
| 524 // static | 530 // static |
| 531 bool NetworkChangeNotifier::GetWifiApInfo(WifiApInfo &info) { |
| 532 return g_network_change_notifier ? |
| 533 g_network_change_notifier->GetCurrentWifiApInfo(info) : |
| 534 false; |
| 535 } |
| 536 |
| 537 // static |
| 525 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { | 538 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { |
| 526 if (!g_network_change_notifier) { | 539 if (!g_network_change_notifier) { |
| 527 *config = DnsConfig(); | 540 *config = DnsConfig(); |
| 528 } else { | 541 } else { |
| 529 g_network_change_notifier->network_state_->GetDnsConfig(config); | 542 g_network_change_notifier->network_state_->GetDnsConfig(config); |
| 530 } | 543 } |
| 531 } | 544 } |
| 532 | 545 |
| 533 // static | 546 // static |
| 534 const char* NetworkChangeNotifier::ConnectionTypeToString( | 547 const char* NetworkChangeNotifier::ConnectionTypeToString( |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 DCHECK(g_network_change_notifier); | 783 DCHECK(g_network_change_notifier); |
| 771 g_network_change_notifier = NULL; | 784 g_network_change_notifier = NULL; |
| 772 } | 785 } |
| 773 | 786 |
| 774 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 787 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
| 775 DCHECK(!g_network_change_notifier); | 788 DCHECK(!g_network_change_notifier); |
| 776 g_network_change_notifier = network_change_notifier_; | 789 g_network_change_notifier = network_change_notifier_; |
| 777 } | 790 } |
| 778 | 791 |
| 779 } // namespace net | 792 } // namespace net |
| OLD | NEW |