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

Unified Diff: media/base/wall_clock_time_source.cc

Issue 1129323003: Allow callers of TimeSource::GetWallClockTime() to suspend time. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 7 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 | « media/base/wall_clock_time_source.h ('k') | media/base/wall_clock_time_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/wall_clock_time_source.cc
diff --git a/media/base/wall_clock_time_source.cc b/media/base/wall_clock_time_source.cc
index 036930671babe5bcac3cafc19f137c543c84ac94..bb5074936e82855b1433d82529aa4791912102cf 100644
--- a/media/base/wall_clock_time_source.cc
+++ b/media/base/wall_clock_time_source.cc
@@ -60,15 +60,27 @@ base::TimeDelta WallClockTimeSource::CurrentMediaTime() {
return CurrentMediaTime_Locked();
}
-base::TimeTicks WallClockTimeSource::GetWallClockTime(base::TimeDelta time) {
- base::AutoLock auto_lock(lock_);
- if (!ticking_ || playback_rate_ == 0.0)
+base::TimeTicks WallClockTimeSource::GetWallClockTime(base::TimeDelta time,
+ int request_flags) {
+ if (request_flags & SUSPEND_TIME)
+ lock_.Acquire();
+
+ lock_.AssertAcquired();
+ if (!ticking_ || playback_rate_ == 0.0) {
+ lock_.Release();
return base::TimeTicks();
+ }
// See notes about |time| values less than |base_time_| in TimeSource header.
- return reference_wall_ticks_ +
- base::TimeDelta::FromMicroseconds(
- (time - base_time_).InMicroseconds() / playback_rate_);
+ const base::TimeTicks result =
+ reference_wall_ticks_ +
+ base::TimeDelta::FromMicroseconds((time - base_time_).InMicroseconds() /
+ playback_rate_);
+
+ if (request_flags & RESUME_TIME)
+ lock_.Release();
+
+ return result;
}
void WallClockTimeSource::SetTickClockForTesting(
« no previous file with comments | « media/base/wall_clock_time_source.h ('k') | media/base/wall_clock_time_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698