Simplify ScheduleDelayedWork implementation on Mac

Instead of round-tripping through Time::Exploded, which seems to be a legacy of the method having a different argument type, just calculate the new timer firing time directly from the difference in time ticks.

BUG=None
TEST=None


Review URL: http://codereview.chromium.org/10227001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133916 0039d316-1c4b-4281-b951-d872f2087c98
parent f1c31f74
...@@ -192,28 +192,8 @@ void MessagePumpCFRunLoopBase::ScheduleWork() { ...@@ -192,28 +192,8 @@ void MessagePumpCFRunLoopBase::ScheduleWork() {
// Must be called on the run loop thread. // Must be called on the run loop thread.
void MessagePumpCFRunLoopBase::ScheduleDelayedWork( void MessagePumpCFRunLoopBase::ScheduleDelayedWork(
const TimeTicks& delayed_work_time) { const TimeTicks& delayed_work_time) {
// TODO(jar): We may need a more efficient way to go between these times, but TimeDelta delta = delayed_work_time - TimeTicks::Now();
// the difference will change not only when we sleep/wake, it will also change delayed_work_fire_time_ = CFAbsoluteTimeGetCurrent() + delta.InSecondsF();
// when the user changes the wall clock time :-/.
Time absolute_work_time =
(delayed_work_time - TimeTicks::Now()) + Time::Now();
Time::Exploded exploded;
absolute_work_time.UTCExplode(&exploded);
double seconds = exploded.second +
(static_cast<double>((absolute_work_time.ToInternalValue()) %
Time::kMicrosecondsPerSecond) /
Time::kMicrosecondsPerSecond);
CFGregorianDate gregorian = {
exploded.year,
exploded.month,
exploded.day_of_month,
exploded.hour,
exploded.minute,
seconds
};
delayed_work_fire_time_ = CFGregorianDateGetAbsoluteTime(gregorian, NULL);
CFRunLoopTimerSetNextFireDate(delayed_work_timer_, delayed_work_fire_time_); CFRunLoopTimerSetNextFireDate(delayed_work_timer_, delayed_work_fire_time_);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment