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

Unified Diff: third_party/WebKit/Source/modules/netinfo/NetworkInformation.cpp

Issue 2903493002: NetInfo network quality extension: Add callbacks and Layout tests (Closed)
Patch Set: haraken comments Created 3 years, 7 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: third_party/WebKit/Source/modules/netinfo/NetworkInformation.cpp
diff --git a/third_party/WebKit/Source/modules/netinfo/NetworkInformation.cpp b/third_party/WebKit/Source/modules/netinfo/NetworkInformation.cpp
index 73a679425674ac7aa8211eaaacc921a6653c72ed..816d4188e469da17c9b99018155c72d8e5af91fe 100644
--- a/third_party/WebKit/Source/modules/netinfo/NetworkInformation.cpp
+++ b/third_party/WebKit/Source/modules/netinfo/NetworkInformation.cpp
@@ -150,19 +150,25 @@ void NetworkInformation::ConnectionChange(
const Optional<double>& downlink_mbps) {
DCHECK(GetExecutionContext()->IsContextThread());
- effective_type_ = effective_type;
- transport_rtt_msec_ = RoundRtt(transport_rtt);
- downlink_mbps_ = RoundMbps(downlink_mbps);
+ unsigned long new_transport_rtt_msec = RoundRtt(transport_rtt);
+ double new_downlink_mbps = RoundMbps(downlink_mbps);
// TODO(tbansal): https://crbug.com/719108. Dispatch |change| event if the
// expected network quality has changed.
// This can happen if the observer removes and then adds itself again
- // during notification, or if HTTP RTT was the only metric that changed.
- if (type_ == type && downlink_max_mbps_ == downlink_max_mbps)
+ // during notification, or if |http_rtt| was the only metric that changed.
+ if (type_ == type && downlink_max_mbps_ == downlink_max_mbps &&
+ effective_type_ == effective_type &&
+ transport_rtt_msec_ == new_transport_rtt_msec &&
+ downlink_mbps_ == new_downlink_mbps) {
return;
+ }
type_ = type;
downlink_max_mbps_ = downlink_max_mbps;
+ effective_type_ = effective_type;
+ transport_rtt_msec_ = new_transport_rtt_msec;
+ downlink_mbps_ = new_downlink_mbps;
DispatchEvent(Event::Create(EventTypeNames::typechange));
if (RuntimeEnabledFeatures::netInfoDownlinkMaxEnabled())

Powered by Google App Engine
This is Rietveld 408576698