Index: third_party/WebKit/Source/platform/network/NetworkStateNotifier.cpp |
diff --git a/third_party/WebKit/Source/platform/network/NetworkStateNotifier.cpp b/third_party/WebKit/Source/platform/network/NetworkStateNotifier.cpp |
index 800557c4944a1482b505a4102315481a86d2e06d..2f7553d732c5d75014b3edf101c4e1fbe7997a15 100644 |
--- a/third_party/WebKit/Source/platform/network/NetworkStateNotifier.cpp |
+++ b/third_party/WebKit/Source/platform/network/NetworkStateNotifier.cpp |
@@ -58,7 +58,10 @@ NetworkStateNotifier::ScopedNotifier::~ScopedNotifier() { |
const NetworkState& after = |
notifier_.has_override_ ? notifier_.override_ : notifier_.state_; |
if ((after.type != before_.type || |
- after.max_bandwidth_mbps != before_.max_bandwidth_mbps) && |
+ after.max_bandwidth_mbps != before_.max_bandwidth_mbps || |
+ after.http_rtt != before_.http_rtt || |
+ after.transport_rtt != before_.transport_rtt || |
+ after.downlink_throughput_mbps != before_.downlink_throughput_mbps) && |
before_.connection_initialized) { |
notifier_.NotifyObservers(notifier_.connection_observers_, |
ObserverType::CONNECTION_TYPE, after); |
@@ -91,6 +94,28 @@ void NetworkStateNotifier::SetWebConnection(WebConnectionType type, |
} |
} |
+void NetworkStateNotifier::SetNetworkQuality(TimeDelta http_rtt, |
+ TimeDelta transport_rtt, |
+ int downlink_throughput_kbps) { |
+ DCHECK(IsMainThread()); |
+ ScopedNotifier notifier(*this); |
+ { |
+ MutexLocker locker(mutex_); |
+ |
+ state_.http_rtt = |
+ http_rtt.InMilliseconds() < 0 ? Optional<TimeDelta>() : http_rtt; |
dcheng
2017/05/17 12:27:46
Nit: does nullopt instead of Optional<TimeDelta>()
tbansal1
2017/05/18 00:10:30
Done.
|
+ |
+ state_.transport_rtt = transport_rtt.InMilliseconds() < 0 |
+ ? Optional<TimeDelta>() |
+ : transport_rtt; |
+ |
+ state_.downlink_throughput_mbps = |
+ downlink_throughput_kbps < 0 |
+ ? Optional<double>() |
+ : static_cast<double>(downlink_throughput_kbps) / 1000; |
+ } |
+} |
+ |
void NetworkStateNotifier::AddConnectionObserver( |
NetworkStateObserver* observer, |
PassRefPtr<WebTaskRunner> task_runner) { |
@@ -180,8 +205,9 @@ void NetworkStateNotifier::NotifyObserversOnTaskRunner( |
observer_list->observers[i]->OnLineStateChange(state.on_line); |
continue; |
case ObserverType::CONNECTION_TYPE: |
- observer_list->observers[i]->ConnectionChange(state.type, |
- state.max_bandwidth_mbps); |
+ observer_list->observers[i]->ConnectionChange( |
+ state.type, state.max_bandwidth_mbps, state.http_rtt, |
+ state.transport_rtt, state.downlink_throughput_mbps); |
continue; |
} |
NOTREACHED(); |