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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/TestNetworkQualityThroughputListener.java

Issue 2852153002: Fix flaky NQE QUIC test (Closed)
Patch Set: pauljensen comments Created 3 years, 8 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
« no previous file with comments | « components/cronet/android/test/javatests/src/org/chromium/net/TestNetworkQualityRttListener.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/test/javatests/src/org/chromium/net/TestNetworkQualityThroughputListener.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/TestNetworkQualityThroughputListener.java b/components/cronet/android/test/javatests/src/org/chromium/net/TestNetworkQualityThroughputListener.java
index c4574a50f537fef4ac8026912a7173340a22aa69..5f64ac62356f6271352e3148770da0a25bacf7a6 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/TestNetworkQualityThroughputListener.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/TestNetworkQualityThroughputListener.java
@@ -13,21 +13,25 @@ import java.util.concurrent.Executor;
class TestNetworkQualityThroughputListener extends NetworkQualityThroughputListener {
// Lock to ensure that observation counts can be updated and read by different threads.
private final Object mLock = new Object();
- private final ConditionVariable mWaitForThroughput;
+
+ // Signals when the first throughput observation is received.
+ private final ConditionVariable mWaitForThroughput = new ConditionVariable();
+
private int mThroughputObservationCount;
private Thread mExecutorThread;
- TestNetworkQualityThroughputListener(Executor executor, ConditionVariable waitForThroughput) {
+ /*
+ * Constructs a NetworkQualityThroughputListener that can listen to the throughput observations.
+ * @param executor The executor on which the observations are reported.
+ */
+ TestNetworkQualityThroughputListener(Executor executor) {
super(executor);
- mWaitForThroughput = waitForThroughput;
}
@Override
public void onThroughputObservation(int throughputKbps, long when, int source) {
synchronized (mLock) {
- if (mWaitForThroughput != null) {
- mWaitForThroughput.open();
- }
+ mWaitForThroughput.open();
mThroughputObservationCount++;
if (mExecutorThread == null) {
mExecutorThread = Thread.currentThread();
@@ -37,6 +41,13 @@ class TestNetworkQualityThroughputListener extends NetworkQualityThroughputListe
}
}
+ /*
+ * Blocks until the first throughput observation is received.
+ */
+ public void waitUntilFirstThroughputObservationReceived() {
+ mWaitForThroughput.block();
+ }
+
public int throughputObservationCount() {
synchronized (mLock) {
return mThroughputObservationCount;
« no previous file with comments | « components/cronet/android/test/javatests/src/org/chromium/net/TestNetworkQualityRttListener.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698