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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/net/qualityprovider/NetworkQualityProvider.java

Issue 1235373006: Upstream changes for NetworkQualityProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed helper class Created 5 years, 4 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: 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..553182efc5fd999cab7893e4d1d61bdf6cd3a7e0
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/net/qualityprovider/NetworkQualityProvider.java
@@ -0,0 +1,109 @@
+// 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.base.annotations.CalledByNative;
+import org.chromium.chrome.browser.ChromeApplication;
+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 NonThreadSafe sThreadCheck = null;
+
+ /**
+ * Value to return if a valid value is unavailable.
+ */
+ protected static final int NO_VALUE = -1;
+ private static NetworkQualityProvider sNetworkQualityProvider;
+ private static final Object sLock = new Object();
nyquist 2015/08/06 23:26:28 Nit: Could you put this final static member above
tbansal1 2015/08/07 00:52:02 Done.
+
+ @CalledByNative
+ private static NetworkQualityProvider create(Context context) {
+ synchronized (sLock) {
+ if (sNetworkQualityProvider == null) {
+ assert sThreadCheck == null;
+ assert sNetworkQualityProvider == null;
+ sThreadCheck = new NonThreadSafe();
+ sNetworkQualityProvider =
+ ((ChromeApplication) context).createNetworkQualityProvider();
+ }
+ }
+ return sNetworkQualityProvider;
+ }
+
+ /**
+ * Creates an instance of |@link #NetworkQualityProvider}.
+ */
+ public NetworkQualityProvider(Context context) {
nyquist 2015/08/06 23:26:28 I'm assuming the downstream code needs the context
tbansal1 2015/08/07 00:52:02 It is needed downstream. Done.
+ assert sThreadCheck.calledOnValidThread();
+ }
+
+ /**
+ * Returns true if the network quality estimate is available.
nyquist 2015/08/06 23:26:28 How do you feel about using "@return ..." form for
tbansal1 2015/08/07 00:52:02 Done.
+ */
+ @CalledByNative
+ protected boolean isEstimateAvailable() {
+ assert sThreadCheck.calledOnValidThread();
+ return false;
+ }
+
+ /**
+ * Requests the provider to update the network quality.
+ */
+ @CalledByNative
+ protected void requestUpdate() {
+ assert sThreadCheck.calledOnValidThread();
+ }
+
+ /**
+ * Returns the expected RTT duration in milliseconds.
+ * Returns {@link #NO_VALUE} if the estimate is unavailable.
+ */
+ @CalledByNative
+ protected int getRTTMilliseconds() {
+ assert sThreadCheck.calledOnValidThread();
+ return NO_VALUE;
+ }
+
+ /**
+ * Returns the expected downstream throughput in Kbps (Kilobits per second).
+ * Returns {@link #NO_VALUE} if the estimate is unavailable.
+ */
+ @CalledByNative
+ protected long getDownstreamThroughputKbps() {
+ assert sThreadCheck.calledOnValidThread();
+ return NO_VALUE;
+ }
+
+ /**
+ * Returns the expected upstream throughput in Kbps (Kilobits per second).
+ * Returns {@link #NO_VALUE} if the estimate is unavailable.
+ */
+ @CalledByNative
+ protected long getUpstreamThroughputKbps() {
+ assert sThreadCheck.calledOnValidThread();
+ return NO_VALUE;
+ }
+
+ /**
+ * Returns time (in seconds) since the network quality was last updated.
+ */
+ @CalledByNative
+ protected long getTimeSinceLastUpdateSeconds() {
+ assert sThreadCheck.calledOnValidThread();
+ return NO_VALUE;
+ }
+
+ @CalledByNative
+ private static int getNoValue() {
+ assert sThreadCheck.calledOnValidThread();
+ return NetworkQualityProvider.NO_VALUE;
nyquist 2015/08/06 23:26:27 Just return NO_VALUE;
tbansal1 2015/08/07 00:52:02 Done.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698