summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-30 00:22:48 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-30 00:22:48 +0000
commit9bcbf478c173d91958cdabc8a8902619392b7f1f (patch)
treebad2b3022719370e6eb01a66f94924a1f848a968 /webkit/port
parent3f9f500b82c82402d9eef92606ebd149762e9f0c (diff)
downloadchromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.zip
chromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.tar.gz
chromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.tar.bz2
Switch SharedTimerWin over to using PostDelayedTask. I made some tweaks to the
PostDelayedTask implementation to ensure that perf is still good. This involved recording the intended fire time of PostDelayedTask on the Task object so that it can be used to properly determine the delay passed to the StartTimer call. With this change, I am able to service timers (call DoDelayedWork) more often from within the MessagePump implementations. R=mbelshe BUG=1346553 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/platform/SharedTimerWin.cpp53
-rw-r--r--webkit/port/platform/SystemTimeWin.cpp3
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()