Chromium Code Reviews| Index: components/cronet/android/api/src/org/chromium/net/EffectiveConnectionType.java |
| diff --git a/components/cronet/android/api/src/org/chromium/net/EffectiveConnectionType.java b/components/cronet/android/api/src/org/chromium/net/EffectiveConnectionType.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..99de52036902d543f47496e1a9024a705747b2e0 |
| --- /dev/null |
| +++ b/components/cronet/android/api/src/org/chromium/net/EffectiveConnectionType.java |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.net; |
| + |
| +/** |
| + * Different values of the effective connection type as computed by the network |
| + * quality estimator. EffectiveConnectionType is the connection type whose |
| + * typical performance is most similar to the measured performance of the |
| + * network in use. In many cases, the "effective" connection type and the actual |
| + * type of connection in use are the same, but often a network connection |
| + * performs significantly differently, usually worse, from its expected |
| + * capabilities. EffectiveConnectionType of a network is independent of if the |
| + * current connection is metered or not. For example, an unmetered slow |
| + * connection may have EFFECTIVE_CONNECTION_TYPE_SLOW_2G as its effective |
| + * connection type. |
| + * @hide as it's a prototype. |
| + */ |
| +public enum EffectiveConnectionType { |
|
xunjieli
2016/08/01 21:25:09
Prefer int over enum.
See: https://groups.google.
tbansal1
2016/08/02 19:03:11
Thanks, I was not aware of IntDefs.
Now this looks
|
| + EFFECTIVE_CONNECTION_TYPE_UNKNOWN, |
| + EFFECTIVE_CONNECTION_TYPE_OFFLINE, |
| + EFFECTIVE_CONNECTION_TYPE_SLOW_2G, |
| + EFFECTIVE_CONNECTION_TYPE_2G, |
| + EFFECTIVE_CONNECTION_TYPE_3G, |
| + EFFECTIVE_CONNECTION_TYPE_4G, |
| + EFFECTIVE_CONNECTION_TYPE_BROADBAND, |
| + EFFECTIVE_CONNECTION_TYPE_LAST; |
| + |
| + /** |
| + * Maps the effective connection type enum computed by the network quality |
| + * estimator to {@link EffectiveConnectionType}. |
| + * @param effectiveConnectionType Effective connection type enum computed by |
| + * the network quality estimator. |
| + * @return {@link EffectiveConnectionType} corresponding to the provided enum. |
| + */ |
| + public static EffectiveConnectionType getEffectiveConnectionType(int effectiveConnectionType) { |
| + switch (effectiveConnectionType) { |
| + case 0: |
|
xunjieli
2016/08/01 21:25:09
Please use generated ints and not the hardcoded va
tbansal1
2016/08/02 19:03:11
Using IntDef now (just like LoadState).
|
| + return EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_UNKNOWN; |
| + case 1: |
| + return EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_OFFLINE; |
| + case 2: |
| + return EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_SLOW_2G; |
| + case 3: |
| + return EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_2G; |
| + case 4: |
| + return EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_3G; |
| + case 5: |
| + return EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_4G; |
| + case 6: |
| + return EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_BROADBAND; |
| + case 7: |
| + return EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_LAST; |
| + } |
| + throw new IllegalStateException( |
| + "Effective connection type has an invalid value of " + effectiveConnectionType); |
| + } |
| +} |