OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """WatchdogTimer timeout objects.""" | 5 """WatchdogTimer timeout objects.""" |
6 | 6 |
7 import time | 7 import time |
8 | 8 |
9 | 9 |
10 class WatchdogTimer(object): | 10 class WatchdogTimer(object): |
(...skipping 19 matching lines...) Expand all Loading... |
30 """Returns the elapsed time of the watchdog.""" | 30 """Returns the elapsed time of the watchdog.""" |
31 return time.time() - self._start_time | 31 return time.time() - self._start_time |
32 | 32 |
33 def GetRemaining(self): | 33 def GetRemaining(self): |
34 """Returns the remaining time of the watchdog.""" | 34 """Returns the remaining time of the watchdog.""" |
35 if self._timeout: | 35 if self._timeout: |
36 return self._timeout - self.GetElapsed() | 36 return self._timeout - self.GetElapsed() |
37 else: | 37 else: |
38 return None | 38 return None |
39 | 39 |
| 40 def GetTimeout(self): |
| 41 """Returns the timout of the watchdog.""" |
| 42 return self._timeout |
| 43 |
40 def IsTimedOut(self): | 44 def IsTimedOut(self): |
41 """Whether the watchdog has timed out. | 45 """Whether the watchdog has timed out. |
42 | 46 |
43 Returns: | 47 Returns: |
44 True if the watchdog has timed out, False otherwise. | 48 True if the watchdog has timed out, False otherwise. |
45 """ | 49 """ |
46 remaining = self.GetRemaining() | 50 remaining = self.GetRemaining() |
47 return remaining is not None and remaining < 0 | 51 return remaining is not None and remaining < 0 |
OLD | NEW |