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

Unified Diff: components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java

Issue 2470903002: Add default implementation of experimental methods (Closed)
Patch Set: Code cleaning Created 4 years, 1 month 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: components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java
diff --git a/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java b/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java
index ad06db8d6bad74c59b266520a38c6ff63cc9ee59..da0a83acb1aedef957398cb44ebf32feb47f7b7c 100644
--- a/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java
+++ b/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java
@@ -346,7 +346,7 @@ public class CronetUrlRequestContext extends CronetEngineBase {
throw new IllegalStateException("Network quality estimator must be enabled");
}
synchronized (mNetworkQualityLock) {
- return mEffectiveConnectionType;
+ return convertConnectionTypeToApiValue(mEffectiveConnectionType);
}
}
@@ -356,7 +356,9 @@ public class CronetUrlRequestContext extends CronetEngineBase {
throw new IllegalStateException("Network quality estimator must be enabled");
}
synchronized (mNetworkQualityLock) {
- return mHttpRttMs;
+ return mHttpRttMs != RttThroughputValues.INVALID_RTT_THROUGHPUT
+ ? mHttpRttMs
+ : CONNECTION_METRIC_UNKNOWN;
}
}
@@ -366,7 +368,9 @@ public class CronetUrlRequestContext extends CronetEngineBase {
throw new IllegalStateException("Network quality estimator must be enabled");
}
synchronized (mNetworkQualityLock) {
- return mTransportRttMs;
+ return mTransportRttMs != RttThroughputValues.INVALID_RTT_THROUGHPUT
+ ? mTransportRttMs
+ : CONNECTION_METRIC_UNKNOWN;
}
}
@@ -376,7 +380,9 @@ public class CronetUrlRequestContext extends CronetEngineBase {
throw new IllegalStateException("Network quality estimator must be enabled");
}
synchronized (mNetworkQualityLock) {
- return mDownstreamThroughputKbps;
+ return mDownstreamThroughputKbps != RttThroughputValues.INVALID_RTT_THROUGHPUT
+ ? mDownstreamThroughputKbps
+ : CONNECTION_METRIC_UNKNOWN;
}
}
@@ -552,6 +558,24 @@ public class CronetUrlRequestContext extends CronetEngineBase {
return loggingLevel;
}
+ private static int convertConnectionTypeToApiValue(
+ @EffectiveConnectionType.EffectiveConnectionTypeEnum int type) {
+ switch (type) {
+ case EffectiveConnectionType.TYPE_OFFLINE:
+ return EFFECTIVE_CONNECTION_TYPE_OFFLINE;
+ case EffectiveConnectionType.TYPE_SLOW_2G:
+ return EFFECTIVE_CONNECTION_TYPE_SLOW_2G;
+ case EffectiveConnectionType.TYPE_2G:
+ return EFFECTIVE_CONNECTION_TYPE_2G;
+ case EffectiveConnectionType.TYPE_3G:
+ return EFFECTIVE_CONNECTION_TYPE_3G;
+ case EffectiveConnectionType.TYPE_4G:
+ return EFFECTIVE_CONNECTION_TYPE_4G;
+ default:
+ return EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
pauljensen 2016/11/11 15:13:23 can we change this to: case EffectiveConnectionT
kapishnikov 2016/11/11 16:55:22 Good idea! Done.
+ }
+ }
+
@SuppressWarnings("unused")
@CalledByNative
private void initNetworkThread() {

Powered by Google App Engine
This is Rietveld 408576698