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

Unified Diff: third_party/WebKit/Source/platform/network/NetworkStateNotifier.h

Issue 2863973003: Expose RTT and downlink bandwidth using experimental Javascript API (Closed)
Patch Set: jkarlin 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/platform/network/NetworkStateNotifier.h
diff --git a/third_party/WebKit/Source/platform/network/NetworkStateNotifier.h b/third_party/WebKit/Source/platform/network/NetworkStateNotifier.h
index a1e80b24014c6728a9172c3dede398ae95a14e22..2ba678c10f54a9e001862e3ef41683cb74c79813 100644
--- a/third_party/WebKit/Source/platform/network/NetworkStateNotifier.h
+++ b/third_party/WebKit/Source/platform/network/NetworkStateNotifier.h
@@ -51,13 +51,19 @@ class PLATFORM_EXPORT NetworkStateNotifier {
bool connection_initialized = false;
WebConnectionType type = kWebConnectionTypeOther;
double max_bandwidth_mbps = kInvalidMaxBandwidth;
+ int http_rtt_msec = -1;
+ int transport_rtt_msec = -1;
+ double downlink_throughput_mbps = -1;
};
class NetworkStateObserver {
public:
// Will be called on the task runner that is passed in add*Observer.
virtual void ConnectionChange(WebConnectionType,
- double max_bandwidth_mbps) {}
+ double max_bandwidth_mbps,
+ int http_rtt_msec,
+ int transport_rtt_msec,
+ double downlink_throughput_mbps) {}
virtual void OnLineStateChange(bool on_line) {}
};
@@ -71,6 +77,27 @@ class PLATFORM_EXPORT NetworkStateNotifier {
return state.on_line;
}
+ int HttpRttMsec() const {
+ MutexLocker locker(mutex_);
+ const NetworkState& state = has_override_ ? override_ : state_;
+ DCHECK(state.on_line_initialized);
+ return state.http_rtt_msec;
+ }
+
+ int TransportRttMsec() const {
+ MutexLocker locker(mutex_);
+ const NetworkState& state = has_override_ ? override_ : state_;
+ DCHECK(state.on_line_initialized);
+ return state.transport_rtt_msec;
+ }
+
+ double DownlinkThroughputMbps() const {
+ MutexLocker locker(mutex_);
+ const NetworkState& state = has_override_ ? override_ : state_;
+ DCHECK(state.on_line_initialized);
+ return state.downlink_throughput_mbps;
+ }
+
void SetOnLine(bool);
// Can be called on any thread.
@@ -110,6 +137,9 @@ class PLATFORM_EXPORT NetworkStateNotifier {
}
void SetWebConnection(WebConnectionType, double max_bandwidth_mbps);
+ void SetWebNetworkQuality(int http_rtt_msec,
+ int transport_rtt_msec,
+ int downlink_throughput_kbps);
// When called, successive setWebConnectionType/setOnLine calls are stored,
// and supplied overridden values are used instead until clearOverride() is

Powered by Google App Engine
This is Rietveld 408576698