| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/blink_platform_impl.h" | 5 #include "content/child/blink_platform_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "blink/public/resources/grit/blink_resources.h" | 28 #include "blink/public/resources/grit/blink_resources.h" |
| 29 #include "content/app/resources/grit/content_resources.h" | 29 #include "content/app/resources/grit/content_resources.h" |
| 30 #include "content/app/strings/grit/content_strings.h" | 30 #include "content/app/strings/grit/content_strings.h" |
| 31 #include "content/child/bluetooth/web_bluetooth_impl.h" | 31 #include "content/child/bluetooth/web_bluetooth_impl.h" |
| 32 #include "content/child/child_thread_impl.h" | 32 #include "content/child/child_thread_impl.h" |
| 33 #include "content/child/content_child_helpers.h" | 33 #include "content/child/content_child_helpers.h" |
| 34 #include "content/child/geofencing/web_geofencing_provider_impl.h" | 34 #include "content/child/geofencing/web_geofencing_provider_impl.h" |
| 35 #include "content/child/navigator_connect/navigator_connect_provider.h" | 35 #include "content/child/navigator_connect/navigator_connect_provider.h" |
| 36 #include "content/child/notifications/notification_dispatcher.h" | 36 #include "content/child/notifications/notification_dispatcher.h" |
| 37 #include "content/child/notifications/notification_manager.h" | 37 #include "content/child/notifications/notification_manager.h" |
| 38 #include "content/child/permissions/permission_manager.h" |
| 39 #include "content/child/permissions/permission_manager_thread_proxy.h" |
| 38 #include "content/child/push_messaging/push_dispatcher.h" | 40 #include "content/child/push_messaging/push_dispatcher.h" |
| 39 #include "content/child/push_messaging/push_provider.h" | 41 #include "content/child/push_messaging/push_provider.h" |
| 40 #include "content/child/thread_safe_sender.h" | 42 #include "content/child/thread_safe_sender.h" |
| 41 #include "content/child/web_discardable_memory_impl.h" | 43 #include "content/child/web_discardable_memory_impl.h" |
| 42 #include "content/child/web_gesture_curve_impl.h" | 44 #include "content/child/web_gesture_curve_impl.h" |
| 43 #include "content/child/web_url_loader_impl.h" | 45 #include "content/child/web_url_loader_impl.h" |
| 44 #include "content/child/websocket_bridge.h" | 46 #include "content/child/websocket_bridge.h" |
| 45 #include "content/child/webthread_impl.h" | 47 #include "content/child/webthread_impl.h" |
| 46 #include "content/child/worker_task_runner.h" | 48 #include "content/child/worker_task_runner.h" |
| 47 #include "content/public/common/content_client.h" | 49 #include "content/public/common/content_client.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // ChildThread may not exist in some tests. | 437 // ChildThread may not exist in some tests. |
| 436 if (ChildThreadImpl::current()) { | 438 if (ChildThreadImpl::current()) { |
| 437 geofencing_provider_.reset(new WebGeofencingProviderImpl( | 439 geofencing_provider_.reset(new WebGeofencingProviderImpl( |
| 438 ChildThreadImpl::current()->thread_safe_sender())); | 440 ChildThreadImpl::current()->thread_safe_sender())); |
| 439 bluetooth_.reset( | 441 bluetooth_.reset( |
| 440 new WebBluetoothImpl(ChildThreadImpl::current()->thread_safe_sender())); | 442 new WebBluetoothImpl(ChildThreadImpl::current()->thread_safe_sender())); |
| 441 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); | 443 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); |
| 442 notification_dispatcher_ = | 444 notification_dispatcher_ = |
| 443 ChildThreadImpl::current()->notification_dispatcher(); | 445 ChildThreadImpl::current()->notification_dispatcher(); |
| 444 push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher(); | 446 push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher(); |
| 447 permission_client_.reset(new PermissionManager( |
| 448 *ChildThreadImpl::current()->service_registry())); |
| 445 } | 449 } |
| 446 | 450 |
| 447 if (main_thread_task_runner_.get()) { | 451 if (main_thread_task_runner_.get()) { |
| 448 shared_timer_.SetTaskRunner(main_thread_task_runner_); | 452 shared_timer_.SetTaskRunner(main_thread_task_runner_); |
| 449 } | 453 } |
| 450 } | 454 } |
| 451 | 455 |
| 452 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) { | 456 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) { |
| 453 DCHECK(!current_thread_slot_.Get()); | 457 DCHECK(!current_thread_slot_.Get()); |
| 454 current_thread_slot_.Set(thread); | 458 current_thread_slot_.Set(thread); |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 | 1020 |
| 1017 void BlinkPlatformImpl::callOnMainThread( | 1021 void BlinkPlatformImpl::callOnMainThread( |
| 1018 void (*func)(void*), void* context) { | 1022 void (*func)(void*), void* context) { |
| 1019 main_thread_task_runner_->PostTask(FROM_HERE, base::Bind(func, context)); | 1023 main_thread_task_runner_->PostTask(FROM_HERE, base::Bind(func, context)); |
| 1020 } | 1024 } |
| 1021 | 1025 |
| 1022 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve( | 1026 blink::WebGestureCurve* BlinkPlatformImpl::createFlingAnimationCurve( |
| 1023 blink::WebGestureDevice device_source, | 1027 blink::WebGestureDevice device_source, |
| 1024 const blink::WebFloatPoint& velocity, | 1028 const blink::WebFloatPoint& velocity, |
| 1025 const blink::WebSize& cumulative_scroll) { | 1029 const blink::WebSize& cumulative_scroll) { |
| 1026 bool is_main_thread = | |
| 1027 main_thread_task_runner_.get() && | |
| 1028 main_thread_task_runner_->BelongsToCurrentThread(); | |
| 1029 return WebGestureCurveImpl::CreateFromDefaultPlatformCurve( | 1030 return WebGestureCurveImpl::CreateFromDefaultPlatformCurve( |
| 1030 gfx::Vector2dF(velocity.x, velocity.y), | 1031 gfx::Vector2dF(velocity.x, velocity.y), |
| 1031 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height), | 1032 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height), |
| 1032 is_main_thread).release(); | 1033 IsMainThread()).release(); |
| 1033 } | 1034 } |
| 1034 | 1035 |
| 1035 void BlinkPlatformImpl::didStartWorkerRunLoop() { | 1036 void BlinkPlatformImpl::didStartWorkerRunLoop() { |
| 1036 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 1037 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); |
| 1037 worker_task_runner->OnWorkerRunLoopStarted(); | 1038 worker_task_runner->OnWorkerRunLoopStarted(); |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1040 void BlinkPlatformImpl::didStopWorkerRunLoop() { | 1041 void BlinkPlatformImpl::didStopWorkerRunLoop() { |
| 1041 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); | 1042 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); |
| 1042 worker_task_runner->OnWorkerRunLoopStopped(); | 1043 worker_task_runner->OnWorkerRunLoopStopped(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 | 1076 |
| 1076 blink::WebNavigatorConnectProvider* | 1077 blink::WebNavigatorConnectProvider* |
| 1077 BlinkPlatformImpl::navigatorConnectProvider() { | 1078 BlinkPlatformImpl::navigatorConnectProvider() { |
| 1078 if (!thread_safe_sender_.get()) | 1079 if (!thread_safe_sender_.get()) |
| 1079 return nullptr; | 1080 return nullptr; |
| 1080 | 1081 |
| 1081 return NavigatorConnectProvider::ThreadSpecificInstance( | 1082 return NavigatorConnectProvider::ThreadSpecificInstance( |
| 1082 thread_safe_sender_.get(), main_thread_task_runner_); | 1083 thread_safe_sender_.get(), main_thread_task_runner_); |
| 1083 } | 1084 } |
| 1084 | 1085 |
| 1086 blink::WebPermissionClient* BlinkPlatformImpl::permissionClient() { |
| 1087 if (!permission_client_.get()) |
| 1088 return nullptr; |
| 1089 |
| 1090 if (IsMainThread()) |
| 1091 return permission_client_.get(); |
| 1092 |
| 1093 return PermissionManagerThreadProxy::GetThreadInstance( |
| 1094 main_thread_task_runner_.get(), permission_client_.get()); |
| 1095 } |
| 1096 |
| 1085 WebThemeEngine* BlinkPlatformImpl::themeEngine() { | 1097 WebThemeEngine* BlinkPlatformImpl::themeEngine() { |
| 1086 return &native_theme_engine_; | 1098 return &native_theme_engine_; |
| 1087 } | 1099 } |
| 1088 | 1100 |
| 1089 WebFallbackThemeEngine* BlinkPlatformImpl::fallbackThemeEngine() { | 1101 WebFallbackThemeEngine* BlinkPlatformImpl::fallbackThemeEngine() { |
| 1090 return &fallback_theme_engine_; | 1102 return &fallback_theme_engine_; |
| 1091 } | 1103 } |
| 1092 | 1104 |
| 1093 blink::Platform::FileHandle BlinkPlatformImpl::databaseOpenFile( | 1105 blink::Platform::FileHandle BlinkPlatformImpl::databaseOpenFile( |
| 1094 const blink::WebString& vfs_file_name, int desired_flags) { | 1106 const blink::WebString& vfs_file_name, int desired_flags) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 scoped_refptr<base::SingleThreadTaskRunner> | 1243 scoped_refptr<base::SingleThreadTaskRunner> |
| 1232 BlinkPlatformImpl::MainTaskRunnerForCurrentThread() { | 1244 BlinkPlatformImpl::MainTaskRunnerForCurrentThread() { |
| 1233 if (main_thread_task_runner_.get() && | 1245 if (main_thread_task_runner_.get() && |
| 1234 main_thread_task_runner_->BelongsToCurrentThread()) { | 1246 main_thread_task_runner_->BelongsToCurrentThread()) { |
| 1235 return main_thread_task_runner_; | 1247 return main_thread_task_runner_; |
| 1236 } else { | 1248 } else { |
| 1237 return base::MessageLoopProxy::current(); | 1249 return base::MessageLoopProxy::current(); |
| 1238 } | 1250 } |
| 1239 } | 1251 } |
| 1240 | 1252 |
| 1253 bool BlinkPlatformImpl::IsMainThread() const { |
| 1254 return main_thread_task_runner_.get() && |
| 1255 main_thread_task_runner_->BelongsToCurrentThread(); |
| 1256 } |
| 1257 |
| 1241 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { | 1258 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { |
| 1242 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( | 1259 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( |
| 1243 static_cast<ui::DomCode>(dom_code))); | 1260 static_cast<ui::DomCode>(dom_code))); |
| 1244 } | 1261 } |
| 1245 | 1262 |
| 1246 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { | 1263 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { |
| 1247 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( | 1264 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( |
| 1248 code.utf8().data())); | 1265 code.utf8().data())); |
| 1249 } | 1266 } |
| 1250 | 1267 |
| 1251 } // namespace content | 1268 } // namespace content |
| OLD | NEW |