diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 05:39:15 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 05:39:15 +0000 |
commit | d01902d70e46a90fc24d3a442805a4a665d373ca (patch) | |
tree | 670155b3c91dabcfb60b01c0b16f2171b2a41d81 /webkit/glue/webkitclient_impl.cc | |
parent | 0fbb214b6345b8490e559c1a4f8f66d704df72d2 (diff) | |
download | chromium_src-d01902d70e46a90fc24d3a442805a4a665d373ca.zip chromium_src-d01902d70e46a90fc24d3a442805a4a665d373ca.tar.gz chromium_src-d01902d70e46a90fc24d3a442805a4a665d373ca.tar.bz2 |
Try reverting to the old shared timer implementation to see if it explains
the intl1 perf regression.
TBR=dglazkov
Review URL: http://codereview.chromium.org/39112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10874 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webkitclient_impl.cc')
-rw-r--r-- | webkit/glue/webkitclient_impl.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc index e726a6c..12a4d14 100644 --- a/webkit/glue/webkitclient_impl.cc +++ b/webkit/glue/webkitclient_impl.cc @@ -21,6 +21,66 @@ double WebKitClientImpl::currentTime() { return base::Time::Now().ToDoubleT(); } +// HACK to see if this code impacts the intl1 page cycler +#if defined(OS_WIN) +class SharedTimerTask; + +// We maintain a single active timer and a single active task for +// setting timers directly on the platform. +static SharedTimerTask* shared_timer_task; +static void (*shared_timer_function)(); + +// Timer task to run in the chrome message loop. +class SharedTimerTask : public Task { + public: + SharedTimerTask(void (*callback)()) : callback_(callback) {} + + virtual void Run() { + if (!callback_) + return; + // Since we only have one task running at a time, verify 'this' is it + DCHECK(shared_timer_task == this); + shared_timer_task = NULL; + callback_(); + } + + void Cancel() { + callback_ = NULL; + } + + private: + void (*callback_)(); + DISALLOW_COPY_AND_ASSIGN(SharedTimerTask); +}; + +void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { + shared_timer_function = func; +} + +void WebKitClientImpl::setSharedTimerFireTime(double fire_time) { + DCHECK(shared_timer_function); + int interval = static_cast<int>((fire_time - currentTime()) * 1000); + if (interval < 0) + interval = 0; + + stopSharedTimer(); + + // Verify that we didn't leak the task or timer objects. + DCHECK(shared_timer_task == NULL); + shared_timer_task = new SharedTimerTask(shared_timer_function); + MessageLoop::current()->PostDelayedTask(FROM_HERE, shared_timer_task, + interval); +} + +void WebKitClientImpl::stopSharedTimer() { + if (!shared_timer_task) + return; + shared_timer_task->Cancel(); + shared_timer_task = NULL; +} + +#else + void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { shared_timer_func_ = func; } @@ -39,6 +99,8 @@ void WebKitClientImpl::stopSharedTimer() { shared_timer_.Stop(); } +#endif + void WebKitClientImpl::callOnMainThread(void (*func)()) { main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); } |