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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeBackgroundServiceWaiter.java

Issue 2830843002: [Offline pages] Updates to background scheduling to use BTS (Closed)
Patch Set: Addressing code review comments Created 3 years, 7 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/ChromeBackgroundServiceWaiter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeBackgroundServiceWaiter.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeBackgroundServiceWaiter.java
deleted file mode 100644
index 5e1544f45e7abfdb65a09e1a3a551aad0db0c935..0000000000000000000000000000000000000000
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeBackgroundServiceWaiter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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.chrome.browser;
-
-import org.chromium.base.Log;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Class to wait for a task to complete before releasing control back to the caller.
- */
-public class ChromeBackgroundServiceWaiter {
- private static final String TAG = "CBSWaiter";
- /** Synchronization object to control the wait. */
- private final CountDownLatch mLatch;
- /** How long to wait for before giving up */
- private int mWakelockTimeoutSeconds;
-
- public ChromeBackgroundServiceWaiter(int wakelockTimeoutSeconds) {
- mWakelockTimeoutSeconds = wakelockTimeoutSeconds;
- mLatch = new CountDownLatch(1);
- }
-
- /**
- * Wait, blocking the current thread until another thread calls onWaitDone.
- */
- public void startWaiting() {
- try {
- boolean waitSucceeded = mLatch.await(mWakelockTimeoutSeconds, TimeUnit.SECONDS);
- if (!waitSucceeded) {
- Log.d(TAG, "waiting for latch timed out");
- }
- } catch (InterruptedException e) {
- Log.d(TAG, "ChromeBackgroundServiceWaiter interrupted while holding wake lock. " + e);
- }
- }
-
-
- /**
- * Called when the wait is complete.
- */
- public void onWaitDone() {
- // Release the waited thread to return to the caller, and thus release the wake lock held on
- // behalf of the Owner.
- mLatch.countDown();
- }
-}

Powered by Google App Engine
This is Rietveld 408576698