Chromium Code Reviews| 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..9e76e3da57ec952d351798891c11dfb3db368377 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._start_time + self._timeout - time.time() |
|
jbudorick
2014/10/30 19:00:14
nit: 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 |