| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 NetworkChangeNotifier* g_network_change_notifier = NULL; | 41 NetworkChangeNotifier* g_network_change_notifier = NULL; |
| 42 | 42 |
| 43 // Class factory singleton. | 43 // Class factory singleton. |
| 44 NetworkChangeNotifierFactory* g_network_change_notifier_factory = NULL; | 44 NetworkChangeNotifierFactory* g_network_change_notifier_factory = NULL; |
| 45 | 45 |
| 46 class MockNetworkChangeNotifier : public NetworkChangeNotifier { | 46 class MockNetworkChangeNotifier : public NetworkChangeNotifier { |
| 47 public: | 47 public: |
| 48 ConnectionType GetCurrentConnectionType() const override { | 48 ConnectionType GetCurrentConnectionType() const override { |
| 49 return CONNECTION_UNKNOWN; | 49 return CONNECTION_UNKNOWN; |
| 50 } | 50 } |
| 51 std::string GetCurrentWiFiSSID() const override { return ""; } |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 } // namespace | 54 } // namespace |
| 54 | 55 |
| 55 // The main observer class that records UMAs for network events. | 56 // The main observer class that records UMAs for network events. |
| 56 class HistogramWatcher | 57 class HistogramWatcher |
| 57 : public NetworkChangeNotifier::ConnectionTypeObserver, | 58 : public NetworkChangeNotifier::ConnectionTypeObserver, |
| 58 public NetworkChangeNotifier::IPAddressObserver, | 59 public NetworkChangeNotifier::IPAddressObserver, |
| 59 public NetworkChangeNotifier::DNSObserver, | 60 public NetworkChangeNotifier::DNSObserver, |
| 60 public NetworkChangeNotifier::NetworkChangeObserver { | 61 public NetworkChangeNotifier::NetworkChangeObserver { |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 } | 530 } |
| 530 | 531 |
| 531 // static | 532 // static |
| 532 NetworkChangeNotifier::ConnectionType | 533 NetworkChangeNotifier::ConnectionType |
| 533 NetworkChangeNotifier::GetConnectionType() { | 534 NetworkChangeNotifier::GetConnectionType() { |
| 534 return g_network_change_notifier ? | 535 return g_network_change_notifier ? |
| 535 g_network_change_notifier->GetCurrentConnectionType() : | 536 g_network_change_notifier->GetCurrentConnectionType() : |
| 536 CONNECTION_UNKNOWN; | 537 CONNECTION_UNKNOWN; |
| 537 } | 538 } |
| 538 | 539 |
| 540 std::string NetworkChangeNotifier::GetWiFiSSID() { |
| 541 return g_network_change_notifier |
| 542 ? g_network_change_notifier->GetCurrentWiFiSSID() |
| 543 : ""; |
| 544 } |
| 545 |
| 539 // static | 546 // static |
| 540 double NetworkChangeNotifier::GetMaxBandwidth() { | 547 double NetworkChangeNotifier::GetMaxBandwidth() { |
| 541 return g_network_change_notifier ? | 548 return g_network_change_notifier ? |
| 542 g_network_change_notifier->GetCurrentMaxBandwidth() : | 549 g_network_change_notifier->GetCurrentMaxBandwidth() : |
| 543 std::numeric_limits<double>::infinity(); | 550 std::numeric_limits<double>::infinity(); |
| 544 } | 551 } |
| 545 | 552 |
| 546 // static | 553 // static |
| 547 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { | 554 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { |
| 548 if (!g_network_change_notifier) { | 555 if (!g_network_change_notifier) { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 DCHECK(g_network_change_notifier); | 986 DCHECK(g_network_change_notifier); |
| 980 g_network_change_notifier = NULL; | 987 g_network_change_notifier = NULL; |
| 981 } | 988 } |
| 982 | 989 |
| 983 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 990 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
| 984 DCHECK(!g_network_change_notifier); | 991 DCHECK(!g_network_change_notifier); |
| 985 g_network_change_notifier = network_change_notifier_; | 992 g_network_change_notifier = network_change_notifier_; |
| 986 } | 993 } |
| 987 | 994 |
| 988 } // namespace net | 995 } // namespace net |
| OLD | NEW |