Bug 842550: Simplify ScheduleDelayedWork implementation on Mac. rs=cjones

Imported from:
> From: stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
> Date: Wed, 25 Apr 2012 15:28:55 +0000 (+0000)
> Subject: Simplify ScheduleDelayedWork implementation on Mac
> X-Git-Url: http://git.chromium.org/gitweb/?p=chromium.git;a=commitdiff_plain;h=18e6c782965d2784995b011977777b10687bb9c0
>
> 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
This commit is contained in:
stuartmorgan@chromium.org 2013-02-21 18:10:59 -08:00
Родитель 8876f7e142
Коммит 81948a9656
1 изменённых файлов: 2 добавлений и 22 удалений

Просмотреть файл

@ -226,28 +226,8 @@ void MessagePumpCFRunLoopBase::ScheduleWork() {
// Must be called on the run loop thread.
void MessagePumpCFRunLoopBase::ScheduleDelayedWork(
const TimeTicks& delayed_work_time) {
// TODO(jar): We may need a more efficient way to go between these times, but
// the difference will change not only when we sleep/wake, it will also change
// 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);
TimeDelta delta = delayed_work_time - TimeTicks::Now();
delayed_work_fire_time_ = CFAbsoluteTimeGetCurrent() + delta.InSecondsF();
CFRunLoopTimerSetNextFireDate(delayed_work_timer_, delayed_work_fire_time_);
}