diff options
Diffstat (limited to 'webkit/port')
-rw-r--r-- | webkit/port/platform/SharedTimerWin.cpp | 53 | ||||
-rw-r--r-- | webkit/port/platform/SystemTimeWin.cpp | 3 |
2 files changed, 16 insertions, 40 deletions
diff --git a/webkit/port/platform/SharedTimerWin.cpp b/webkit/port/platform/SharedTimerWin.cpp index 385bae8..b7f3b08 100644 --- a/webkit/port/platform/SharedTimerWin.cpp +++ b/webkit/port/platform/SharedTimerWin.cpp @@ -30,9 +30,7 @@ #undef LOG -#include "base/timer.h" #include "base/message_loop.h" -#include <map> namespace WebCore { @@ -40,7 +38,6 @@ class WebkitTimerTask; // We maintain a single active timer and a single active task for // setting timers directly on the platform. -static Timer* msgLoopTimer; static WebkitTimerTask* msgLoopTask; static void (*sharedTimerFiredFunction)(); @@ -48,22 +45,25 @@ static void (*sharedTimerFiredFunction)(); class WebkitTimerTask : public Task { public: WebkitTimerTask(void (*callback)()) : m_callback(callback) {} + virtual void Run() { - MessageLoop* msgloop = MessageLoop::current(); - delete msgLoopTimer; - msgLoopTimer = NULL; + if (!m_callback) + return; // Since we only have one task running at a time, verify that it // is 'this'. ASSERT(msgLoopTask == this); msgLoopTask = NULL; m_callback(); - delete this; + } + + void Cancel() { + m_callback = NULL; } private: void (*m_callback)(); - DISALLOW_EVIL_CONSTRUCTORS(WebkitTimerTask); + DISALLOW_COPY_AND_ASSIGN(WebkitTimerTask); }; void setSharedTimerFiredFunction(void (*f)()) @@ -80,43 +80,20 @@ void setSharedTimerFireTime(double fireTime) stopSharedTimer(); - MessageLoop* msgloop = MessageLoop::current(); - TimerManager* mgr = msgloop->timer_manager(); - // Verify that we didn't leak the task or timer objects. - ASSERT(msgLoopTimer == NULL); ASSERT(msgLoopTask == NULL); - // Create a new task and timer. We are responsible for cleanup - // of each. msgLoopTask = new WebkitTimerTask(sharedTimerFiredFunction); - msgLoopTimer = mgr->StartTimer(interval, msgLoopTask, false); + MessageLoop::current()->PostDelayedTask(FROM_HERE, msgLoopTask, interval); } void stopSharedTimer() { - if (msgLoopTimer != NULL) { - // When we have a timer running, there must be an associated task. - ASSERT(msgLoopTask != NULL); - - MessageLoop* msgloop = MessageLoop::current(); - // msgloop can be NULL in one particular instance: - // KJS uses static GCController object, which has a Timer member, - // which attempts to stop() when it's destroyed, which calls this. - // But since the object is static, and the current MessageLoop can be - // scoped to main(), the static object can be destroyed (and this - // code can run) after the current MessageLoop is gone. - // TODO(evanm): look into whether there's a better solution for this. - if (msgloop) { - TimerManager* mgr = msgloop->timer_manager(); - mgr->StopTimer(msgLoopTimer); - } - - delete msgLoopTimer; - msgLoopTimer = NULL; - delete msgLoopTask; - msgLoopTask = NULL; - } -} + if (!msgLoopTask) + return; + msgLoopTask->Cancel(); + msgLoopTask = NULL; } + +} // namespace WebCore diff --git a/webkit/port/platform/SystemTimeWin.cpp b/webkit/port/platform/SystemTimeWin.cpp index 8a4f140..fe3f6d6 100644 --- a/webkit/port/platform/SystemTimeWin.cpp +++ b/webkit/port/platform/SystemTimeWin.cpp @@ -27,7 +27,6 @@ #include "SystemTime.h" #include "NotImplemented.h" -#include <windows.h> #include "base/time.h" namespace WebCore { @@ -35,7 +34,7 @@ namespace WebCore { // Get the current time in seconds since epoch. double currentTime() { - return Time::Now().ToDoubleT(); + return Time::Now().ToDoubleT(); } float userIdleTime() |