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

Unified Diff: net/base/network_change_notifier.cc

Issue 1306653003: Add connection type to NCN::MaxBandwidthChanged (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment nit Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: net/base/network_change_notifier.cc
diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc
index 03502f6dbfd6a21daef19127e08348013198660d..ac4aed3789f49450e50e7a47f531b203fa7179db 100644
--- a/net/base/network_change_notifier.cc
+++ b/net/base/network_change_notifier.cc
@@ -542,10 +542,16 @@ NetworkChangeNotifier::GetConnectionType() {
}
// static
-double NetworkChangeNotifier::GetMaxBandwidth() {
- return g_network_change_notifier ?
- g_network_change_notifier->GetCurrentMaxBandwidth() :
- std::numeric_limits<double>::infinity();
+double NetworkChangeNotifier::GetMaxBandwidthAndConnectionType(
+ ConnectionType* connection_type) {
+ if (!g_network_change_notifier) {
+ if (connection_type != nullptr)
+ *connection_type = CONNECTION_UNKNOWN;
+ return GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN);
+ }
+
+ return g_network_change_notifier->GetCurrentMaxBandwidthAndConnectionType(
+ connection_type);
}
// static
@@ -792,6 +798,15 @@ void NetworkChangeNotifier::NotifyObserversOfInitialDNSConfigReadForTests() {
}
// static
+void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeForTests(
+ ConnectionType type,
+ double max_bandwidth) {
+ if (g_network_change_notifier)
+ g_network_change_notifier->NotifyObserversOfMaxBandwidthChangeImpl(
+ type, max_bandwidth);
+}
+
+// static
void NetworkChangeNotifier::SetTestNotificationsOnly(bool test_only) {
DCHECK(!g_network_change_notifier);
NetworkChangeNotifier::test_notifications_only_ = test_only;
@@ -830,13 +845,16 @@ NetworkChangeNotifier::GetAddressTrackerInternal() const {
}
#endif
-double NetworkChangeNotifier::GetCurrentMaxBandwidth() const {
+double NetworkChangeNotifier::GetCurrentMaxBandwidthAndConnectionType(
+ ConnectionType* connection_type) 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();
+ if (connection_type != nullptr)
+ *connection_type = GetCurrentConnectionType();
+ return *connection_type == CONNECTION_NONE
+ ? GetMaxBandwidthForConnectionSubtype(SUBTYPE_NONE)
+ : GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN);
}
// static
@@ -942,11 +960,12 @@ void NetworkChangeNotifier::NotifyObserversOfNetworkChange(
// static
void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChange(
+ ConnectionType type,
double max_bandwidth_mbps) {
if (g_network_change_notifier &&
!NetworkChangeNotifier::test_notifications_only_) {
g_network_change_notifier->NotifyObserversOfMaxBandwidthChangeImpl(
- max_bandwidth_mbps);
+ type, max_bandwidth_mbps);
}
}
@@ -1015,9 +1034,10 @@ void NetworkChangeNotifier::NotifyObserversOfInitialDNSConfigReadImpl() {
}
void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeImpl(
+ ConnectionType type,
double max_bandwidth_mbps) {
max_bandwidth_observer_list_->Notify(
- FROM_HERE, &MaxBandwidthObserver::OnMaxBandwidthChanged,
+ FROM_HERE, &MaxBandwidthObserver::OnMaxBandwidthChanged, type,
max_bandwidth_mbps);
}

Powered by Google App Engine
This is Rietveld 408576698