#include "net/base/network_change_notifier.h"
+#include <limits>
+
#include "base/metrics/histogram.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
class MockNetworkChangeNotifier : public NetworkChangeNotifier {
public:
- virtual ConnectionType GetCurrentConnectionType() const OVERRIDE {
+ ConnectionType GetCurrentConnectionType() const override {
return CONNECTION_UNKNOWN;
}
};
NetworkChangeNotifier::AddNetworkChangeObserver(this);
}
- virtual ~HistogramWatcher() {
+ ~HistogramWatcher() override {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(g_network_change_notifier);
NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
}
// NetworkChangeNotifier::IPAddressObserver implementation.
- virtual void OnIPAddressChanged() OVERRIDE {
+ void OnIPAddressChanged() override {
DCHECK(thread_checker_.CalledOnValidThread());
UMA_HISTOGRAM_MEDIUM_TIMES("NCN.IPAddressChange",
SinceLast(&last_ip_address_change_));
}
// NetworkChangeNotifier::ConnectionTypeObserver implementation.
- virtual void OnConnectionTypeChanged(
- NetworkChangeNotifier::ConnectionType type) OVERRIDE {
+ void OnConnectionTypeChanged(
+ NetworkChangeNotifier::ConnectionType type) override {
DCHECK(thread_checker_.CalledOnValidThread());
base::TimeTicks now = base::TimeTicks::Now();
int32 kilobytes_read = bytes_read_since_last_connection_change_ / 1000;
}
// NetworkChangeNotifier::DNSObserver implementation.
- virtual void OnDNSChanged() OVERRIDE {
+ void OnDNSChanged() override {
DCHECK(thread_checker_.CalledOnValidThread());
UMA_HISTOGRAM_MEDIUM_TIMES("NCN.DNSConfigChange",
SinceLast(&last_dns_change_));
}
// NetworkChangeNotifier::NetworkChangeObserver implementation.
- virtual void OnNetworkChanged(
- NetworkChangeNotifier::ConnectionType type) OVERRIDE {
+ void OnNetworkChanged(NetworkChangeNotifier::ConnectionType type) override {
DCHECK(thread_checker_.CalledOnValidThread());
if (type != NetworkChangeNotifier::CONNECTION_NONE) {
UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOnlineChange",
AddIPAddressObserver(this);
}
- virtual ~NetworkChangeCalculator() {
+ ~NetworkChangeCalculator() override {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(g_network_change_notifier);
RemoveConnectionTypeObserver(this);
}
// NetworkChangeNotifier::IPAddressObserver implementation.
- virtual void OnIPAddressChanged() OVERRIDE {
+ void OnIPAddressChanged() override {
DCHECK(thread_checker_.CalledOnValidThread());
base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE
? params_.ip_address_offline_delay_ : params_.ip_address_online_delay_;
}
// NetworkChangeNotifier::ConnectionTypeObserver implementation.
- virtual void OnConnectionTypeChanged(ConnectionType type) OVERRIDE {
+ void OnConnectionTypeChanged(ConnectionType type) override {
DCHECK(thread_checker_.CalledOnValidThread());
pending_connection_type_ = type;
base::TimeDelta delay = last_announced_connection_type_ == CONNECTION_NONE
}
// static
+double NetworkChangeNotifier::GetMaxBandwidth() {
+ return g_network_change_notifier ?
+ g_network_change_notifier->GetCurrentMaxBandwidth() :
+ std::numeric_limits<double>::infinity();
+}
+
+// static
void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) {
if (!g_network_change_notifier) {
*config = DnsConfig();
}
#endif
+double NetworkChangeNotifier::GetCurrentMaxBandwidth() const {
+ // This default implementation conforms to the NetInfo V3 specification but
+ // should be overridden to provide specific bandwidth data based on the
+ // platform.
+ if (GetCurrentConnectionType() == CONNECTION_NONE)
+ return 0.0;
+ return std::numeric_limits<double>::infinity();
+}
+
// static
void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() {
if (g_network_change_notifier &&