Chromium Code Reviews| 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 "content/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" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" | 10 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" |
| 11 #include "third_party/WebKit/public/web/WebInputEvent.h" | 11 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 12 #include "webkit/child/fling_curve_configuration.h" | 12 #include "webkit/child/fling_curve_configuration.h" |
| 13 #include "webkit/child/web_discardable_memory_impl.h" | 13 #include "webkit/child/web_discardable_memory_impl.h" |
| 14 #include "webkit/child/webthread_impl.h" | 14 #include "webkit/child/webthread_impl.h" |
| 15 #include "webkit/child/worker_task_runner.h" | 15 #include "webkit/child/worker_task_runner.h" |
| 16 | 16 |
| 17 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
| 18 #include "webkit/child/fling_animator_impl_android.h" | 18 #include "webkit/child/fling_animator_impl_android.h" |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 using blink::WebFallbackThemeEngine; | 21 using blink::WebFallbackThemeEngine; |
| 22 using blink::WebThemeEngine; | 22 using blink::WebThemeEngine; |
| 23 | 23 |
| 24 namespace webkit_glue { | 24 namespace content { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class WebWaitableEventImpl : public blink::WebWaitableEvent { | 28 class WebWaitableEventImpl : public blink::WebWaitableEvent { |
| 29 public: | 29 public: |
| 30 WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {} | 30 WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {} |
| 31 virtual ~WebWaitableEventImpl() {} | 31 virtual ~WebWaitableEventImpl() {} |
| 32 | 32 |
| 33 virtual void wait() { impl_->Wait(); } | 33 virtual void wait() { impl_->Wait(); } |
| 34 virtual void signal() { impl_->Signal(); } | 34 virtual void signal() { impl_->Signal(); } |
| 35 | 35 |
| 36 base::WaitableEvent* impl() { | 36 base::WaitableEvent* impl() { |
| 37 return impl_.get(); | 37 return impl_.get(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 scoped_ptr<base::WaitableEvent> impl_; | 41 scoped_ptr<base::WaitableEvent> impl_; |
| 42 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); | 42 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 WebKitPlatformSupportChildImpl::WebKitPlatformSupportChildImpl() | 47 WebKitPlatformSupportChildImpl::WebKitPlatformSupportChildImpl() |
| 48 : current_thread_slot_(&DestroyCurrentThread), | 48 : current_thread_slot_(&DestroyCurrentThread), |
| 49 fling_curve_configuration_(new FlingCurveConfiguration) {} | 49 fling_curve_configuration_(new webkit_glue::FlingCurveConfiguration) {} |
| 50 | 50 |
| 51 WebKitPlatformSupportChildImpl::~WebKitPlatformSupportChildImpl() {} | 51 WebKitPlatformSupportChildImpl::~WebKitPlatformSupportChildImpl() {} |
| 52 | 52 |
| 53 WebThemeEngine* WebKitPlatformSupportChildImpl::themeEngine() { | 53 WebThemeEngine* WebKitPlatformSupportChildImpl::themeEngine() { |
| 54 return &native_theme_engine_; | 54 return &native_theme_engine_; |
| 55 } | 55 } |
| 56 | 56 |
| 57 WebFallbackThemeEngine* WebKitPlatformSupportChildImpl::fallbackThemeEngine() { | 57 WebFallbackThemeEngine* WebKitPlatformSupportChildImpl::fallbackThemeEngine() { |
| 58 return &fallback_theme_engine_; | 58 return &fallback_theme_engine_; |
| 59 } | 59 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 77 if (device_source == blink::WebGestureEvent::Touchscreen) | 77 if (device_source == blink::WebGestureEvent::Touchscreen) |
| 78 return fling_curve_configuration_->CreateForTouchScreen(velocity, | 78 return fling_curve_configuration_->CreateForTouchScreen(velocity, |
| 79 cumulative_scroll); | 79 cumulative_scroll); |
| 80 | 80 |
| 81 return fling_curve_configuration_->CreateForTouchPad(velocity, | 81 return fling_curve_configuration_->CreateForTouchPad(velocity, |
| 82 cumulative_scroll); | 82 cumulative_scroll); |
| 83 } | 83 } |
| 84 | 84 |
| 85 blink::WebThread* WebKitPlatformSupportChildImpl::createThread( | 85 blink::WebThread* WebKitPlatformSupportChildImpl::createThread( |
| 86 const char* name) { | 86 const char* name) { |
| 87 return new WebThreadImpl(name); | 87 return new webkit_glue::WebThreadImpl(name); |
| 88 } | 88 } |
| 89 | 89 |
| 90 blink::WebThread* WebKitPlatformSupportChildImpl::currentThread() { | 90 blink::WebThread* WebKitPlatformSupportChildImpl::currentThread() { |
| 91 WebThreadImplForMessageLoop* thread = | 91 webkit_glue::WebThreadImplForMessageLoop* thread = |
|
darin (slow to review)
2014/01/29 17:58:11
nit: indent 2 spaces
then 4 spaces when you wrap
| |
| 92 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); | 92 static_cast<webkit_glue::WebThreadImplForMessageLoop*>( |
| 93 current_thread_slot_.Get()); | |
| 93 if (thread) | 94 if (thread) |
| 94 return (thread); | 95 return (thread); |
| 95 | 96 |
| 96 scoped_refptr<base::MessageLoopProxy> message_loop = | 97 scoped_refptr<base::MessageLoopProxy> message_loop = |
| 97 base::MessageLoopProxy::current(); | 98 base::MessageLoopProxy::current(); |
| 98 if (!message_loop.get()) | 99 if (!message_loop.get()) |
| 99 return NULL; | 100 return NULL; |
| 100 | 101 |
| 101 thread = new WebThreadImplForMessageLoop(message_loop.get()); | 102 thread = new webkit_glue::WebThreadImplForMessageLoop(message_loop.get()); |
| 102 current_thread_slot_.Set(thread); | 103 current_thread_slot_.Set(thread); |
| 103 return thread; | 104 return thread; |
| 104 } | 105 } |
| 105 | 106 |
| 106 blink::WebWaitableEvent* WebKitPlatformSupportChildImpl::createWaitableEvent() { | 107 blink::WebWaitableEvent* WebKitPlatformSupportChildImpl::createWaitableEvent() { |
| 107 return new WebWaitableEventImpl(); | 108 return new WebWaitableEventImpl(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 blink::WebWaitableEvent* WebKitPlatformSupportChildImpl::waitMultipleEvents( | 111 blink::WebWaitableEvent* WebKitPlatformSupportChildImpl::waitMultipleEvents( |
| 111 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { | 112 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { |
| 112 base::WaitableEvent** events = new base::WaitableEvent*[web_events.size()]; | 113 base::WaitableEvent** events = new base::WaitableEvent*[web_events.size()]; |
| 113 for (size_t i = 0; i < web_events.size(); ++i) | 114 for (size_t i = 0; i < web_events.size(); ++i) |
| 114 events[i] = static_cast<WebWaitableEventImpl*>(web_events[i])->impl(); | 115 events[i] = static_cast<WebWaitableEventImpl*>(web_events[i])->impl(); |
| 115 size_t idx = base::WaitableEvent::WaitMany(events, web_events.size()); | 116 size_t idx = base::WaitableEvent::WaitMany(events, web_events.size()); |
| 116 DCHECK_LT(idx, web_events.size()); | 117 DCHECK_LT(idx, web_events.size()); |
| 117 return web_events[idx]; | 118 return web_events[idx]; |
| 118 } | 119 } |
| 119 | 120 |
| 120 void WebKitPlatformSupportChildImpl::didStartWorkerRunLoop( | 121 void WebKitPlatformSupportChildImpl::didStartWorkerRunLoop( |
| 121 const blink::WebWorkerRunLoop& runLoop) { | 122 const blink::WebWorkerRunLoop& runLoop) { |
| 122 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 123 webkit_glue::WorkerTaskRunner* worker_task_runner = |
|
darin (slow to review)
2014/01/29 17:58:11
ditto
| |
| 124 webkit_glue::WorkerTaskRunner::Instance(); | |
| 123 worker_task_runner->OnWorkerRunLoopStarted(runLoop); | 125 worker_task_runner->OnWorkerRunLoopStarted(runLoop); |
| 124 } | 126 } |
| 125 | 127 |
| 126 void WebKitPlatformSupportChildImpl::didStopWorkerRunLoop( | 128 void WebKitPlatformSupportChildImpl::didStopWorkerRunLoop( |
| 127 const blink::WebWorkerRunLoop& runLoop) { | 129 const blink::WebWorkerRunLoop& runLoop) { |
| 128 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 130 webkit_glue::WorkerTaskRunner* worker_task_runner = |
|
darin (slow to review)
2014/01/29 17:58:11
ditto
| |
| 131 webkit_glue::WorkerTaskRunner::Instance(); | |
| 129 worker_task_runner->OnWorkerRunLoopStopped(runLoop); | 132 worker_task_runner->OnWorkerRunLoopStopped(runLoop); |
| 130 } | 133 } |
| 131 | 134 |
| 132 blink::WebDiscardableMemory* | 135 blink::WebDiscardableMemory* |
| 133 WebKitPlatformSupportChildImpl::allocateAndLockDiscardableMemory(size_t bytes) { | 136 WebKitPlatformSupportChildImpl::allocateAndLockDiscardableMemory(size_t bytes) { |
| 134 base::DiscardableMemoryType type = | 137 base::DiscardableMemoryType type = |
| 135 base::DiscardableMemory::GetPreferredType(); | 138 base::DiscardableMemory::GetPreferredType(); |
| 136 if (type == base::DISCARDABLE_MEMORY_TYPE_EMULATED) | 139 if (type == base::DISCARDABLE_MEMORY_TYPE_EMULATED) |
| 137 return NULL; | 140 return NULL; |
| 138 return WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); | 141 return webkit_glue::WebDiscardableMemoryImpl::CreateLockedMemory( |
| 142 bytes).release(); | |
|
darin (slow to review)
2014/01/29 17:58:11
ditto
| |
| 139 } | 143 } |
| 140 | 144 |
| 141 // static | 145 // static |
| 142 void WebKitPlatformSupportChildImpl::DestroyCurrentThread(void* thread) { | 146 void WebKitPlatformSupportChildImpl::DestroyCurrentThread(void* thread) { |
| 143 WebThreadImplForMessageLoop* impl = | 147 webkit_glue::WebThreadImplForMessageLoop* impl = |
|
darin (slow to review)
2014/01/29 17:58:11
ditto
| |
| 144 static_cast<WebThreadImplForMessageLoop*>(thread); | 148 static_cast<webkit_glue::WebThreadImplForMessageLoop*>(thread); |
| 145 delete impl; | 149 delete impl; |
| 146 } | 150 } |
| 147 | 151 |
| 148 } // namespace webkit_glue | 152 } // namespace content |
| OLD | NEW |