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

Unified Diff: build/android/pylib/utils/watchdog_timer.py

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 | « build/android/pylib/utils/timeout_retry.py ('k') | build/common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/watchdog_timer.py
diff --git a/build/android/pylib/utils/watchdog_timer.py b/build/android/pylib/utils/watchdog_timer.py
index d14dabb4dd7800eb1883fc7aae8cdc2b8f4a538f..2f4c46455be7c9751e9a570a8f41cac0e3430cf7 100644
--- a/build/android/pylib/utils/watchdog_timer.py
+++ b/build/android/pylib/utils/watchdog_timer.py
@@ -26,12 +26,22 @@ class WatchdogTimer(object):
"""Resets the timeout countdown."""
self._start_time = time.time()
+ def GetElapsed(self):
+ """Returns the elapsed time of the watchdog."""
+ return time.time() - self._start_time
+
+ def GetRemaining(self):
+ """Returns the remaining time of the watchdog."""
+ if self._timeout:
+ return self._timeout - self.GetElapsed()
+ else:
+ return None
+
def IsTimedOut(self):
"""Whether the watchdog has timed out.
Returns:
True if the watchdog has timed out, False otherwise.
"""
- if self._timeout is None:
- return False
- return time.time() - self._start_time > self._timeout
+ remaining = self.GetRemaining()
+ return remaining is not None and remaining < 0
« no previous file with comments | « build/android/pylib/utils/timeout_retry.py ('k') | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698