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 "third_party/WebKit/public/web/WebInputEvent.h" | 8 #include "third_party/WebKit/public/web/WebInputEvent.h" |
9 #include "webkit/child/fling_curve_configuration.h" | 9 #include "webkit/child/fling_curve_configuration.h" |
10 #include "webkit/child/web_discardable_memory_impl.h" | 10 #include "webkit/child/web_discardable_memory_impl.h" |
11 #include "webkit/child/webthread_impl.h" | 11 #include "webkit/child/webthread_impl.h" |
12 #include "webkit/child/worker_task_runner.h" | 12 #include "webkit/child/worker_task_runner.h" |
13 | 13 |
14 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
15 #include "webkit/child/fling_animator_impl_android.h" | 15 #include "webkit/child/fling_animator_impl_android.h" |
16 #endif | 16 #endif |
17 | 17 |
18 using WebKit::WebFallbackThemeEngine; | 18 using blink::WebFallbackThemeEngine; |
19 using WebKit::WebThemeEngine; | 19 using blink::WebThemeEngine; |
20 | 20 |
21 namespace webkit_glue { | 21 namespace webkit_glue { |
22 | 22 |
23 WebKitPlatformSupportChildImpl::WebKitPlatformSupportChildImpl() | 23 WebKitPlatformSupportChildImpl::WebKitPlatformSupportChildImpl() |
24 : current_thread_slot_(&DestroyCurrentThread), | 24 : current_thread_slot_(&DestroyCurrentThread), |
25 fling_curve_configuration_(new FlingCurveConfiguration) {} | 25 fling_curve_configuration_(new FlingCurveConfiguration) {} |
26 | 26 |
27 WebKitPlatformSupportChildImpl::~WebKitPlatformSupportChildImpl() {} | 27 WebKitPlatformSupportChildImpl::~WebKitPlatformSupportChildImpl() {} |
28 | 28 |
29 WebThemeEngine* WebKitPlatformSupportChildImpl::themeEngine() { | 29 WebThemeEngine* WebKitPlatformSupportChildImpl::themeEngine() { |
30 return &native_theme_engine_; | 30 return &native_theme_engine_; |
31 } | 31 } |
32 | 32 |
33 WebFallbackThemeEngine* WebKitPlatformSupportChildImpl::fallbackThemeEngine() { | 33 WebFallbackThemeEngine* WebKitPlatformSupportChildImpl::fallbackThemeEngine() { |
34 return &fallback_theme_engine_; | 34 return &fallback_theme_engine_; |
35 } | 35 } |
36 | 36 |
37 void WebKitPlatformSupportChildImpl::SetFlingCurveParameters( | 37 void WebKitPlatformSupportChildImpl::SetFlingCurveParameters( |
38 const std::vector<float>& new_touchpad, | 38 const std::vector<float>& new_touchpad, |
39 const std::vector<float>& new_touchscreen) { | 39 const std::vector<float>& new_touchscreen) { |
40 fling_curve_configuration_->SetCurveParameters(new_touchpad, new_touchscreen); | 40 fling_curve_configuration_->SetCurveParameters(new_touchpad, new_touchscreen); |
41 } | 41 } |
42 | 42 |
43 WebKit::WebGestureCurve* | 43 blink::WebGestureCurve* |
44 WebKitPlatformSupportChildImpl::createFlingAnimationCurve( | 44 WebKitPlatformSupportChildImpl::createFlingAnimationCurve( |
45 int device_source, | 45 int device_source, |
46 const WebKit::WebFloatPoint& velocity, | 46 const blink::WebFloatPoint& velocity, |
47 const WebKit::WebSize& cumulative_scroll) { | 47 const blink::WebSize& cumulative_scroll) { |
48 #if defined(OS_ANDROID) | 48 #if defined(OS_ANDROID) |
49 return FlingAnimatorImpl::CreateAndroidGestureCurve(velocity, | 49 return FlingAnimatorImpl::CreateAndroidGestureCurve(velocity, |
50 cumulative_scroll); | 50 cumulative_scroll); |
51 #endif | 51 #endif |
52 | 52 |
53 if (device_source == WebKit::WebGestureEvent::Touchscreen) | 53 if (device_source == blink::WebGestureEvent::Touchscreen) |
54 return fling_curve_configuration_->CreateForTouchScreen(velocity, | 54 return fling_curve_configuration_->CreateForTouchScreen(velocity, |
55 cumulative_scroll); | 55 cumulative_scroll); |
56 | 56 |
57 return fling_curve_configuration_->CreateForTouchPad(velocity, | 57 return fling_curve_configuration_->CreateForTouchPad(velocity, |
58 cumulative_scroll); | 58 cumulative_scroll); |
59 } | 59 } |
60 | 60 |
61 WebKit::WebThread* WebKitPlatformSupportChildImpl::createThread( | 61 blink::WebThread* WebKitPlatformSupportChildImpl::createThread( |
62 const char* name) { | 62 const char* name) { |
63 return new WebThreadImpl(name); | 63 return new WebThreadImpl(name); |
64 } | 64 } |
65 | 65 |
66 WebKit::WebThread* WebKitPlatformSupportChildImpl::currentThread() { | 66 blink::WebThread* WebKitPlatformSupportChildImpl::currentThread() { |
67 WebThreadImplForMessageLoop* thread = | 67 WebThreadImplForMessageLoop* thread = |
68 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); | 68 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); |
69 if (thread) | 69 if (thread) |
70 return (thread); | 70 return (thread); |
71 | 71 |
72 scoped_refptr<base::MessageLoopProxy> message_loop = | 72 scoped_refptr<base::MessageLoopProxy> message_loop = |
73 base::MessageLoopProxy::current(); | 73 base::MessageLoopProxy::current(); |
74 if (!message_loop.get()) | 74 if (!message_loop.get()) |
75 return NULL; | 75 return NULL; |
76 | 76 |
77 thread = new WebThreadImplForMessageLoop(message_loop.get()); | 77 thread = new WebThreadImplForMessageLoop(message_loop.get()); |
78 current_thread_slot_.Set(thread); | 78 current_thread_slot_.Set(thread); |
79 return thread; | 79 return thread; |
80 } | 80 } |
81 | 81 |
82 void WebKitPlatformSupportChildImpl::didStartWorkerRunLoop( | 82 void WebKitPlatformSupportChildImpl::didStartWorkerRunLoop( |
83 const WebKit::WebWorkerRunLoop& runLoop) { | 83 const blink::WebWorkerRunLoop& runLoop) { |
84 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 84 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); |
85 worker_task_runner->OnWorkerRunLoopStarted(runLoop); | 85 worker_task_runner->OnWorkerRunLoopStarted(runLoop); |
86 } | 86 } |
87 | 87 |
88 void WebKitPlatformSupportChildImpl::didStopWorkerRunLoop( | 88 void WebKitPlatformSupportChildImpl::didStopWorkerRunLoop( |
89 const WebKit::WebWorkerRunLoop& runLoop) { | 89 const blink::WebWorkerRunLoop& runLoop) { |
90 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 90 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); |
91 worker_task_runner->OnWorkerRunLoopStopped(runLoop); | 91 worker_task_runner->OnWorkerRunLoopStopped(runLoop); |
92 } | 92 } |
93 | 93 |
94 WebKit::WebDiscardableMemory* | 94 blink::WebDiscardableMemory* |
95 WebKitPlatformSupportChildImpl::allocateAndLockDiscardableMemory(size_t bytes) { | 95 WebKitPlatformSupportChildImpl::allocateAndLockDiscardableMemory(size_t bytes) { |
96 if (!base::DiscardableMemory::SupportedNatively()) | 96 if (!base::DiscardableMemory::SupportedNatively()) |
97 return NULL; | 97 return NULL; |
98 return WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); | 98 return WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); |
99 } | 99 } |
100 | 100 |
101 // static | 101 // static |
102 void WebKitPlatformSupportChildImpl::DestroyCurrentThread(void* thread) { | 102 void WebKitPlatformSupportChildImpl::DestroyCurrentThread(void* thread) { |
103 WebThreadImplForMessageLoop* impl = | 103 WebThreadImplForMessageLoop* impl = |
104 static_cast<WebThreadImplForMessageLoop*>(thread); | 104 static_cast<WebThreadImplForMessageLoop*>(thread); |
105 delete impl; | 105 delete impl; |
106 } | 106 } |
107 | 107 |
108 } // namespace webkit_glue | 108 } // namespace webkit_glue |
OLD | NEW |