Index: net/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CriteriaHelper.java |
diff --git a/net/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CriteriaHelper.java b/net/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CriteriaHelper.java |
index 1c593a4b33e5ed000e99954a1a4a6923daba446b..4dc4d5d5c8e09cbdb8f665c76dcd53b3924b9bda 100644 |
--- a/net/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CriteriaHelper.java |
+++ b/net/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CriteriaHelper.java |
@@ -10,25 +10,30 @@ import android.os.SystemClock; |
/** |
* Helper methods for creating and managing criteria. |
- * |
* <p> |
* If possible, use callbacks or testing delegates instead of criteria as they |
- * do not introduce any polling delays. Should only use Criteria if no suitable |
+ * do not introduce any polling delays. Should only use Criteria if no suitable |
* other approach exists. |
*/ |
public class CriteriaHelper { |
/** The default maximum time to wait for a criteria to become valid. */ |
public static final long DEFAULT_MAX_TIME_TO_POLL = scaleTimeout(3000); |
- /** The default polling interval to wait between checking for a satisfied criteria. */ |
+ |
+ /** |
+ * The default polling interval to wait between checking for a satisfied |
+ * criteria. |
+ */ |
public static final long DEFAULT_POLLING_INTERVAL = 50; |
/** |
- * Checks whether the given Criteria is satisfied at a given interval, until either |
- * the criteria is satisfied, or the specified maxTimeoutMs number of ms has elapsed. |
+ * Checks whether the given Criteria is satisfied at a given interval, until |
+ * either the criteria is satisfied, or the specified maxTimeoutMs number of |
+ * ms has elapsed. |
+ * |
* @param criteria The Criteria that will be checked. |
- * @param maxTimeoutMs The maximum number of ms that this check will be performed for |
- * before timeout. |
+ * @param maxTimeoutMs The maximum number of ms that this check will be |
+ * performed for before timeout. |
* @param checkIntervalMs The number of ms between checks. |
* @return true iff checking has ended with the criteria being satisfied. |
* @throws InterruptedException |
@@ -37,7 +42,8 @@ public class CriteriaHelper { |
long checkIntervalMs) throws InterruptedException { |
boolean isSatisfied = criteria.isSatisfied(); |
long startTime = SystemClock.uptimeMillis(); |
- while (!isSatisfied && SystemClock.uptimeMillis() - startTime < maxTimeoutMs) { |
+ while (!isSatisfied && |
+ SystemClock.uptimeMillis() - startTime < maxTimeoutMs) { |
Thread.sleep(checkIntervalMs); |
isSatisfied = criteria.isSatisfied(); |
} |
@@ -45,24 +51,29 @@ public class CriteriaHelper { |
} |
/** |
- * Checks whether the given Criteria is satisfied polling at a default interval. |
+ * Checks whether the given Criteria is satisfied polling at a default |
+ * interval. |
* |
* @param criteria The Criteria that will be checked. |
* @return iff checking has ended with the criteria being satisfied. |
* @throws InterruptedException |
* @see #pollForCriteria(Criteria, long, long) |
*/ |
- public static boolean pollForCriteria(Criteria criteria) throws InterruptedException { |
- return pollForCriteria(criteria, DEFAULT_MAX_TIME_TO_POLL, DEFAULT_POLLING_INTERVAL); |
+ public static boolean pollForCriteria(Criteria criteria) |
+ throws InterruptedException { |
+ return pollForCriteria(criteria, DEFAULT_MAX_TIME_TO_POLL, |
+ DEFAULT_POLLING_INTERVAL); |
} |
/** |
- * Performs the runnable action, then checks whether the given criteria are satisfied |
- * until the specified timeout, using the pollForCriteria method. If not, then the runnable |
- * action is performed again, to a maximum of maxAttempts tries. |
+ * Performs the runnable action, then checks whether the given criteria are |
+ * satisfied until the specified timeout, using the pollForCriteria method. |
+ * If not, then the runnable action is performed again, to a maximum of |
+ * maxAttempts tries. |
*/ |
public static boolean runUntilCriteria(Runnable runnable, Criteria criteria, |
- int maxAttempts, long maxTimeoutMs, long checkIntervalMs) throws InterruptedException { |
+ int maxAttempts, long maxTimeoutMs, long checkIntervalMs) |
+ throws InterruptedException { |
int count = 0; |
boolean success = false; |
while (count < maxAttempts && !success) { |