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

Unified Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 2903493002: NetInfo network quality extension: Add callbacks and Layout tests (Closed)
Patch Set: ps 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/core/testing/Internals.cpp
diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp
index 74b38a460e8554b99ce89bff02e1e8b2cbff684a..99d35049769c3f96b2e79acfc9565300dc179cf1 100644
--- a/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -3088,7 +3088,35 @@ void Internals::setNetworkConnectionInfoOverride(
ExceptionMessages::FailedToEnumerate("connection type", type));
return;
}
- GetNetworkStateNotifier().SetOverride(on_line, webtype, downlink_max_mbps);
+ GetNetworkStateNotifier().SetNetworkConnectionInfoOverride(on_line, webtype,
+ downlink_max_mbps);
+}
+
+void Internals::setNetworkQualityInfoOverride(const String& effective_type,
+ unsigned long transport_rtt_msec,
+ double downlink_throughput_mbps,
+ ExceptionState& exception_state) {
+ WebEffectiveConnectionType web_effective_type =
+ WebEffectiveConnectionType::kTypeUnknown;
+ if (effective_type == "offline") {
+ web_effective_type = WebEffectiveConnectionType::kTypeOffline;
+ } else if (effective_type == "slow-2g") {
+ web_effective_type = WebEffectiveConnectionType::kTypeSlow2G;
+ } else if (effective_type == "2g") {
+ web_effective_type = WebEffectiveConnectionType::kType2G;
+ } else if (effective_type == "3g") {
+ web_effective_type = WebEffectiveConnectionType::kType3G;
+ } else if (effective_type == "4g") {
+ web_effective_type = WebEffectiveConnectionType::kType4G;
+ } else if (effective_type != "unknown") {
+ exception_state.ThrowDOMException(
+ kNotFoundError, ExceptionMessages::FailedToEnumerate(
+ "effective connection type", effective_type));
+ return;
+ }
+
+ GetNetworkStateNotifier().SetNetworkQualityInfoOverride(
+ web_effective_type, transport_rtt_msec, downlink_throughput_mbps);
}
void Internals::clearNetworkConnectionInfoOverride() {

Powered by Google App Engine
This is Rietveld 408576698