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

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: Fixes 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..c41d83c781b0b65972ab3fa2662b97502890a4a0 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();
+void NetworkChangeNotifier::GetMaxBandwidthAndConnectionType(
+ double* max_bandwidth_mbps,
+ ConnectionType* connection_type) {
+ if (!g_network_change_notifier) {
+ *connection_type = CONNECTION_UNKNOWN;
+ *max_bandwidth_mbps = GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN);
+ }
+
pauljensen 2015/09/15 18:17:40 so if !g_network_change_notifier we dereference it
jkarlin 2015/09/16 12:12:22 Meant to have an early return, good catch. Thanks.
+ g_network_change_notifier->GetCurrentMaxBandwidthAndConnectionType(
+ max_bandwidth_mbps, connection_type);
}
// static
@@ -792,6 +798,15 @@ void NetworkChangeNotifier::NotifyObserversOfInitialDNSConfigReadForTests() {
}
// static
+void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeForTests(
+ ConnectionType type,
+ double max_bandwidth) {
pauljensen 2015/09/15 18:17:40 add _mbps suffix
jkarlin 2015/09/16 12:12:22 Done.
+ if (g_network_change_notifier)
pauljensen 2015/09/15 18:17:40 need curly braces when more than one line clause
jkarlin 2015/09/16 12:12:22 Done.
+ 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,17 @@ NetworkChangeNotifier::GetAddressTrackerInternal() const {
}
#endif
-double NetworkChangeNotifier::GetCurrentMaxBandwidth() const {
+void NetworkChangeNotifier::GetCurrentMaxBandwidthAndConnectionType(
+ double* max_bandwidth_mbps,
+ 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();
+ *connection_type = GetCurrentConnectionType();
+ *max_bandwidth_mbps =
+ *connection_type == CONNECTION_NONE
+ ? GetMaxBandwidthForConnectionSubtype(SUBTYPE_NONE)
+ : GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN);
}
// static
@@ -942,11 +961,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 +1035,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