Index: src/base/platform/elapsed-timer.h |
diff --git a/src/base/platform/elapsed-timer.h b/src/base/platform/elapsed-timer.h |
index f9a9ef43619c2650caf94bfdeefa71f969366db6..2a235e1282c8d07c6239155dfbfd4a26d451a312 100644 |
--- a/src/base/platform/elapsed-timer.h |
+++ b/src/base/platform/elapsed-timer.h |
@@ -52,9 +52,10 @@ class ElapsedTimer final { |
// and then starting the timer again, but does so in one single operation, |
// avoiding the need to obtain the clock value twice. It may only be called |
// on a previously started timer. |
- TimeDelta Restart() { |
+ TimeDelta Restart() { return Restart(Now()); } |
+ |
+ TimeDelta Restart(TimeTicks ticks) { |
Igor Sheludko
2016/11/18 18:56:27
s/ticks/now/ to be clear.
Camillo Bruni
2016/11/21 10:50:03
done.
|
DCHECK(IsStarted()); |
- TimeTicks ticks = Now(); |
TimeDelta elapsed = ticks - start_ticks_; |
DCHECK(elapsed.InMicroseconds() >= 0); |
start_ticks_ = ticks; |
@@ -71,6 +72,14 @@ class ElapsedTimer final { |
return elapsed; |
} |
+ // Move the start_ticks_ to adjust the current timer. |
+ void Subtract(TimeDelta delta) { |
+ DCHECK(IsStarted()); |
+ // If the delta is negative we want to make the elapsed time smaller, hence |
+ // we have to move the start_ticks_ in the opposite direction. |
+ start_ticks_ += delta; |
+ } |
+ |
// Returns |true| if the specified |time_delta| has elapsed since the |
// previous start, or |false| if not. This method may only be called on |
// a previously started timer. |