diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-20 04:59:33 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-20 04:59:33 +0000 |
commit | 617eecb08abd855140699389982288bd8c13769f (patch) | |
tree | 423bc932b700690a82c562aefcad017278cfd2f6 /webkit/child | |
parent | fe6f4e85e730c893dd51622d7236186203b089e2 (diff) | |
download | chromium_src-617eecb08abd855140699389982288bd8c13769f.zip chromium_src-617eecb08abd855140699389982288bd8c13769f.tar.gz chromium_src-617eecb08abd855140699389982288bd8c13769f.tar.bz2 |
Implement Platform::createWaitableEvent(): chromium side
blink side: https://codereview.chromium.org/138303002/
BUG=334263
Review URL: https://codereview.chromium.org/133493003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/child')
-rw-r--r-- | webkit/child/webkitplatformsupport_child_impl.cc | 38 | ||||
-rw-r--r-- | webkit/child/webkitplatformsupport_child_impl.h | 4 |
2 files changed, 42 insertions, 0 deletions
diff --git a/webkit/child/webkitplatformsupport_child_impl.cc b/webkit/child/webkitplatformsupport_child_impl.cc index 09cd0b2..7253540 100644 --- a/webkit/child/webkitplatformsupport_child_impl.cc +++ b/webkit/child/webkitplatformsupport_child_impl.cc @@ -5,6 +5,9 @@ #include "webkit/child/webkitplatformsupport_child_impl.h" #include "base/memory/discardable_memory.h" +#include "base/memory/scoped_ptr.h" +#include "base/synchronization/waitable_event.h" +#include "third_party/WebKit/public/platform/WebWaitableEvent.h" #include "third_party/WebKit/public/web/WebInputEvent.h" #include "webkit/child/fling_curve_configuration.h" #include "webkit/child/web_discardable_memory_impl.h" @@ -20,6 +23,27 @@ using blink::WebThemeEngine; namespace webkit_glue { +namespace { + +class WebWaitableEventImpl : public blink::WebWaitableEvent { + public: + WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {} + virtual ~WebWaitableEventImpl() {} + + virtual void wait() { impl_->Wait(); } + virtual void signal() { impl_->Signal(); } + + base::WaitableEvent* impl() { + return impl_.get(); + } + + private: + scoped_ptr<base::WaitableEvent> impl_; + DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); +}; + +} // namespace + WebKitPlatformSupportChildImpl::WebKitPlatformSupportChildImpl() : current_thread_slot_(&DestroyCurrentThread), fling_curve_configuration_(new FlingCurveConfiguration) {} @@ -79,6 +103,20 @@ blink::WebThread* WebKitPlatformSupportChildImpl::currentThread() { return thread; } +blink::WebWaitableEvent* WebKitPlatformSupportChildImpl::createWaitableEvent() { + return new WebWaitableEventImpl(); +} + +blink::WebWaitableEvent* WebKitPlatformSupportChildImpl::waitMultipleEvents( + const blink::WebVector<blink::WebWaitableEvent*>& web_events) { + base::WaitableEvent** events = new base::WaitableEvent*[web_events.size()]; + for (size_t i = 0; i < web_events.size(); ++i) + events[i] = static_cast<WebWaitableEventImpl*>(web_events[i])->impl(); + size_t idx = base::WaitableEvent::WaitMany(events, web_events.size()); + DCHECK_LT(idx, web_events.size()); + return web_events[idx]; +} + void WebKitPlatformSupportChildImpl::didStartWorkerRunLoop( const blink::WebWorkerRunLoop& runLoop) { WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); diff --git a/webkit/child/webkitplatformsupport_child_impl.h b/webkit/child/webkitplatformsupport_child_impl.h index 43e447d..1e83d3b 100644 --- a/webkit/child/webkitplatformsupport_child_impl.h +++ b/webkit/child/webkitplatformsupport_child_impl.h @@ -46,6 +46,10 @@ class WEBKIT_CHILD_EXPORT WebKitPlatformSupportChildImpl : virtual blink::WebThread* createThread(const char* name); virtual blink::WebThread* currentThread(); + virtual blink::WebWaitableEvent* createWaitableEvent(); + virtual blink::WebWaitableEvent* waitMultipleEvents( + const blink::WebVector<blink::WebWaitableEvent*>& events); + virtual void didStartWorkerRunLoop( const blink::WebWorkerRunLoop& runLoop) OVERRIDE; virtual void didStopWorkerRunLoop( |