Chromium Code Reviews| Index: media/base/clock.cc |
| diff --git a/media/base/clock.cc b/media/base/clock.cc |
| index aaa0c13e90741116039b8af04da6989260977a59..6e131c93ca880bbcf1d621234b5fc100dd37bede 100644 |
| --- a/media/base/clock.cc |
| +++ b/media/base/clock.cc |
| @@ -45,22 +45,30 @@ void Clock::SetPlaybackRate(float playback_rate) { |
| playback_rate_ = playback_rate; |
| } |
| -void Clock::SetTime(const base::TimeDelta& time) { |
| - if (time == kNoTimestamp) { |
| +void Clock::SetTime(base::TimeDelta current_time, base::TimeDelta max_time) { |
| + DCHECK_LE(current_time.ToInternalValue(), max_time.ToInternalValue()); |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
How about DCHECK(current_time <= max_time)? The To
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Done.
|
| + if (current_time == kNoTimestamp) { |
| NOTREACHED(); |
| return; |
| } |
| if (playing_) { |
| reference_ = GetTimeFromProvider(); |
| } |
| - media_time_ = time; |
| + media_time_ = current_time; |
| + max_time_ = max_time; |
| } |
| base::TimeDelta Clock::Elapsed() const { |
| - if (!playing_) { |
| - return media_time_; |
| - } |
| - return ElapsedViaProvidedTime(GetTimeFromProvider()); |
| + base::TimeDelta elapsed = |
| + playing_ ? ElapsedViaProvidedTime(GetTimeFromProvider()) : media_time_; |
| + |
| + if (max_time_.ToInternalValue() > 0) |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
How about using != kNoTimestamp instead of > 0?
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Done.
|
| + elapsed = std::min(elapsed, max_time_); |
| + |
| + if (duration_.ToInternalValue() > 0 && elapsed > duration_) |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
How about using != kNoTimestamp instead of > 0?
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Actually, I modified logic of this method to retur
|
| + return duration_; |
| + |
| + return elapsed; |
| } |
| base::TimeDelta Clock::ElapsedViaProvidedTime(const base::Time& time) const { |