Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/net/qualityprovider/NetworkQualityProvider.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/net/qualityprovider/NetworkQualityProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/net/qualityprovider/NetworkQualityProvider.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7d9b11170dda454aa8fe3f54b5b93fff67b2ec3e |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/net/qualityprovider/NetworkQualityProvider.java |
| @@ -0,0 +1,92 @@ |
| +// Copyright 2015 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.chrome.browser.net.qualityprovider; |
| + |
| +import android.content.Context; |
| + |
| +import org.chromium.chrome.browser.util.NonThreadSafe; |
| + |
| +/** |
| + * This class provides a base class implementation and may be overridden on operating systems that |
| + * provide more useful APIs. This class is not thread safe. |
| + */ |
| +public class NetworkQualityProvider { |
| + private static NetworkQualityProvider sInstance = null; |
| + private static NonThreadSafe sThreadCheck = null; |
| + |
| + /** |
| + * Returns an instance of singleton NetworkQualityProvider. |
| + */ |
| + public static NetworkQualityProvider getInstance() { |
| + if (sThreadCheck == null) sThreadCheck = new NonThreadSafe(); |
|
bengr
2015/07/21 00:06:48
Add braces
tbansal1
2015/07/21 16:18:24
Umm, I may be incorrect but without braces shows 6
|
| + assert sThreadCheck.calledOnValidThread(); |
| + if (sInstance == null) sInstance = new NetworkQualityProvider(); |
|
bengr
2015/07/21 00:06:48
Add braces
tbansal1
2015/07/21 16:18:24
Please see above.
|
| + return sInstance; |
| + } |
| + |
| + /** |
|
bengr
2015/07/21 00:06:48
The comment indentation is busted on all of your c
tbansal1
2015/07/21 16:18:24
Done.
|
| + * Creates a instance of NetworkQualityProvider. |
| + */ |
| + protected NetworkQualityProvider() { |
| + assert sThreadCheck.calledOnValidThread(); |
| + assert sInstance != null; |
| + } |
| + |
| + /** |
| + * Initializes the provider with the context. |
| + */ |
| + public void initialize(Context context) { |
| + assert sThreadCheck.calledOnValidThread(); |
| + assert sInstance != null; |
| + } |
| + |
| + /** |
| + * Returns true if the network quality estimate is available. |
| + */ |
| + protected boolean isEstimateAvailable() { |
| + assert sThreadCheck.calledOnValidThread(); |
| + assert sInstance != null; |
| + return false; |
| + } |
| + |
| + /** |
| + * Returns the expected RTT duration in milliseconds. |
| + * Returns 0 if the estimate is unavailable. |
| + */ |
| + protected int getRTTMilliseconds() { |
| + assert sThreadCheck.calledOnValidThread(); |
| + assert sInstance != null; |
| + return 0; |
| + } |
| + |
| + /** |
| + * Returns the expected downstream throughput in Kbps. |
| + * Returns 0 if the estimate is unavailable. |
| + */ |
| + protected long getDownstreamThroughputKbps() { |
| + assert sThreadCheck.calledOnValidThread(); |
| + assert sInstance != null; |
| + return 0; |
| + } |
| + |
| + /** |
| + * Returns the expected upstream throughput in Kbps. |
| + * Returns 0 if the estimate is unavailable. |
| + */ |
| + protected long getUpstreamThroughputKbps() { |
| + assert sThreadCheck.calledOnValidThread(); |
| + assert sInstance != null; |
| + return 0; |
| + } |
| + |
| + /** |
| + * Returns time (in seconds) since the network quality was last updated. |
| + */ |
| + protected long getTimeSinceLastUpdateSeconds() { |
| + assert sThreadCheck.calledOnValidThread(); |
| + assert sInstance != null; |
| + return Long.MAX_VALUE; |
| + } |
| +} |