OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/child/webkitplatformsupport_child_impl.h" | 5 #include "webkit/child/webkitplatformsupport_child_impl.h" |
6 | 6 |
7 #include "base/memory/discardable_memory.h" | 7 #include "base/memory/discardable_memory.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/synchronization/waitable_event.h" | |
10 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" | |
8 #include "third_party/WebKit/public/web/WebInputEvent.h" | 11 #include "third_party/WebKit/public/web/WebInputEvent.h" |
9 #include "webkit/child/fling_curve_configuration.h" | 12 #include "webkit/child/fling_curve_configuration.h" |
10 #include "webkit/child/web_discardable_memory_impl.h" | 13 #include "webkit/child/web_discardable_memory_impl.h" |
11 #include "webkit/child/webthread_impl.h" | 14 #include "webkit/child/webthread_impl.h" |
12 #include "webkit/child/worker_task_runner.h" | 15 #include "webkit/child/worker_task_runner.h" |
13 | 16 |
14 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
15 #include "webkit/child/fling_animator_impl_android.h" | 18 #include "webkit/child/fling_animator_impl_android.h" |
16 #endif | 19 #endif |
17 | 20 |
18 using blink::WebFallbackThemeEngine; | 21 using blink::WebFallbackThemeEngine; |
19 using blink::WebThemeEngine; | 22 using blink::WebThemeEngine; |
20 | 23 |
21 namespace webkit_glue { | 24 namespace webkit_glue { |
22 | 25 |
26 namespace { | |
27 | |
28 class WebWaitableEventImpl : public blink::WebWaitableEvent { | |
29 public: | |
30 WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {} | |
31 virtual ~WebWaitableEventImpl() {} | |
32 | |
33 virtual void wait() { impl_->Wait(); } | |
34 virtual void signal() { impl_->Signal(); } | |
35 | |
36 base::WaitableEvent* impl() { | |
37 return impl_.get(); | |
38 } | |
39 | |
40 private: | |
41 scoped_ptr<base::WaitableEvent> impl_; | |
42 }; | |
jochen (gone - plz use gerrit)
2014/01/14 15:29:12
disallow copy/assign
kinuko
2014/01/14 16:51:59
Done.
| |
43 | |
44 } // namespace | |
45 | |
23 WebKitPlatformSupportChildImpl::WebKitPlatformSupportChildImpl() | 46 WebKitPlatformSupportChildImpl::WebKitPlatformSupportChildImpl() |
24 : current_thread_slot_(&DestroyCurrentThread), | 47 : current_thread_slot_(&DestroyCurrentThread), |
25 fling_curve_configuration_(new FlingCurveConfiguration) {} | 48 fling_curve_configuration_(new FlingCurveConfiguration) {} |
26 | 49 |
27 WebKitPlatformSupportChildImpl::~WebKitPlatformSupportChildImpl() {} | 50 WebKitPlatformSupportChildImpl::~WebKitPlatformSupportChildImpl() {} |
28 | 51 |
29 WebThemeEngine* WebKitPlatformSupportChildImpl::themeEngine() { | 52 WebThemeEngine* WebKitPlatformSupportChildImpl::themeEngine() { |
30 return &native_theme_engine_; | 53 return &native_theme_engine_; |
31 } | 54 } |
32 | 55 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 scoped_refptr<base::MessageLoopProxy> message_loop = | 95 scoped_refptr<base::MessageLoopProxy> message_loop = |
73 base::MessageLoopProxy::current(); | 96 base::MessageLoopProxy::current(); |
74 if (!message_loop.get()) | 97 if (!message_loop.get()) |
75 return NULL; | 98 return NULL; |
76 | 99 |
77 thread = new WebThreadImplForMessageLoop(message_loop.get()); | 100 thread = new WebThreadImplForMessageLoop(message_loop.get()); |
78 current_thread_slot_.Set(thread); | 101 current_thread_slot_.Set(thread); |
79 return thread; | 102 return thread; |
80 } | 103 } |
81 | 104 |
105 blink::WebWaitableEvent* WebKitPlatformSupportChildImpl::createWaitableEvent() { | |
106 return new WebWaitableEventImpl(); | |
107 } | |
108 | |
109 blink::WebWaitableEvent* WebKitPlatformSupportChildImpl::waitMultipleEvents( | |
110 blink::WebWaitableEvent** web_events, | |
111 size_t event_count) { | |
jochen (gone - plz use gerrit)
2014/01/14 15:29:12
why not a WebVector?
kinuko
2014/01/14 16:51:59
Ah sure... sounds better. I was biased by base::Wa
| |
112 base::WaitableEvent** events = new base::WaitableEvent*[event_count]; | |
113 for (size_t i = 0; i < event_count; ++i) | |
114 events[i] = static_cast<WebWaitableEventImpl*>(web_events[i])->impl(); | |
115 size_t idx = base::WaitableEvent::WaitMany(events, event_count); | |
116 DCHECK_LT(idx, event_count); | |
117 return web_events[idx]; | |
118 } | |
119 | |
82 void WebKitPlatformSupportChildImpl::didStartWorkerRunLoop( | 120 void WebKitPlatformSupportChildImpl::didStartWorkerRunLoop( |
83 const blink::WebWorkerRunLoop& runLoop) { | 121 const blink::WebWorkerRunLoop& runLoop) { |
84 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 122 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); |
85 worker_task_runner->OnWorkerRunLoopStarted(runLoop); | 123 worker_task_runner->OnWorkerRunLoopStarted(runLoop); |
86 } | 124 } |
87 | 125 |
88 void WebKitPlatformSupportChildImpl::didStopWorkerRunLoop( | 126 void WebKitPlatformSupportChildImpl::didStopWorkerRunLoop( |
89 const blink::WebWorkerRunLoop& runLoop) { | 127 const blink::WebWorkerRunLoop& runLoop) { |
90 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 128 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); |
91 worker_task_runner->OnWorkerRunLoopStopped(runLoop); | 129 worker_task_runner->OnWorkerRunLoopStopped(runLoop); |
92 } | 130 } |
93 | 131 |
94 blink::WebDiscardableMemory* | 132 blink::WebDiscardableMemory* |
95 WebKitPlatformSupportChildImpl::allocateAndLockDiscardableMemory(size_t bytes) { | 133 WebKitPlatformSupportChildImpl::allocateAndLockDiscardableMemory(size_t bytes) { |
96 base::DiscardableMemoryType type = | 134 base::DiscardableMemoryType type = |
97 base::DiscardableMemory::GetPreferredType(); | 135 base::DiscardableMemory::GetPreferredType(); |
98 if (type == base::DISCARDABLE_MEMORY_TYPE_EMULATED) | 136 if (type == base::DISCARDABLE_MEMORY_TYPE_EMULATED) |
99 return NULL; | 137 return NULL; |
100 return WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); | 138 return WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); |
101 } | 139 } |
102 | 140 |
103 // static | 141 // static |
104 void WebKitPlatformSupportChildImpl::DestroyCurrentThread(void* thread) { | 142 void WebKitPlatformSupportChildImpl::DestroyCurrentThread(void* thread) { |
105 WebThreadImplForMessageLoop* impl = | 143 WebThreadImplForMessageLoop* impl = |
106 static_cast<WebThreadImplForMessageLoop*>(thread); | 144 static_cast<WebThreadImplForMessageLoop*>(thread); |
107 delete impl; | 145 delete impl; |
108 } | 146 } |
109 | 147 |
110 } // namespace webkit_glue | 148 } // namespace webkit_glue |
OLD | NEW |