OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 WebKit::initialize(webkit_platform_support_.get()); | 722 WebKit::initialize(webkit_platform_support_.get()); |
723 WebKit::setSharedWorkerRepository( | 723 WebKit::setSharedWorkerRepository( |
724 webkit_platform_support_.get()->sharedWorkerRepository()); | 724 webkit_platform_support_.get()->sharedWorkerRepository()); |
725 WebKit::setIDBFactory( | 725 WebKit::setIDBFactory( |
726 webkit_platform_support_.get()->idbFactory()); | 726 webkit_platform_support_.get()->idbFactory()); |
727 | 727 |
728 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 728 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
729 | 729 |
730 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); | 730 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); |
731 if (enable) { | 731 if (enable) { |
732 MessageLoop* override_loop = | 732 base::MessageLoop* override_loop = |
733 GetContentClient()->renderer()->OverrideCompositorMessageLoop(); | 733 GetContentClient()->renderer()->OverrideCompositorMessageLoop(); |
734 if (override_loop) { | 734 if (override_loop) { |
735 compositor_message_loop_proxy_ = override_loop->message_loop_proxy(); | 735 compositor_message_loop_proxy_ = override_loop->message_loop_proxy(); |
736 } else { | 736 } else { |
737 compositor_thread_.reset(new base::Thread("Compositor")); | 737 compositor_thread_.reset(new base::Thread("Compositor")); |
738 compositor_thread_->Start(); | 738 compositor_thread_->Start(); |
739 compositor_message_loop_proxy_ = | 739 compositor_message_loop_proxy_ = |
740 compositor_thread_->message_loop_proxy(); | 740 compositor_thread_->message_loop_proxy(); |
741 } | 741 } |
742 | 742 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { | 847 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { |
848 if (size > static_cast<size_t>(std::numeric_limits<int>::max())) | 848 if (size > static_cast<size_t>(std::numeric_limits<int>::max())) |
849 return scoped_ptr<base::SharedMemory>(); | 849 return scoped_ptr<base::SharedMemory>(); |
850 | 850 |
851 base::SharedMemoryHandle handle; | 851 base::SharedMemoryHandle handle; |
852 bool success; | 852 bool success; |
853 IPC::Message* message = | 853 IPC::Message* message = |
854 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle); | 854 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle); |
855 | 855 |
856 // Allow calling this from the compositor thread. | 856 // Allow calling this from the compositor thread. |
857 if (MessageLoop::current() == message_loop()) | 857 if (base::MessageLoop::current() == message_loop()) |
858 success = ChildThread::Send(message); | 858 success = ChildThread::Send(message); |
859 else | 859 else |
860 success = sync_message_filter()->Send(message); | 860 success = sync_message_filter()->Send(message); |
861 | 861 |
862 if (!success) | 862 if (!success) |
863 return scoped_ptr<base::SharedMemory>(); | 863 return scoped_ptr<base::SharedMemory>(); |
864 | 864 |
865 if (!base::SharedMemory::IsHandleValid(handle)) | 865 if (!base::SharedMemory::IsHandleValid(handle)) |
866 return scoped_ptr<base::SharedMemory>(); | 866 return scoped_ptr<base::SharedMemory>(); |
867 | 867 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 return false; // We must be shutting down. | 1090 return false; // We must be shutting down. |
1091 | 1091 |
1092 return true; | 1092 return true; |
1093 } | 1093 } |
1094 | 1094 |
1095 bool RenderThreadImpl::IsMainThread() { | 1095 bool RenderThreadImpl::IsMainThread() { |
1096 return !!current(); | 1096 return !!current(); |
1097 } | 1097 } |
1098 | 1098 |
1099 bool RenderThreadImpl::IsIOThread() { | 1099 bool RenderThreadImpl::IsIOThread() { |
1100 return MessageLoop::current() == ChildProcess::current()->io_message_loop(); | 1100 return base::MessageLoop::current() == |
| 1101 ChildProcess::current()->io_message_loop(); |
1101 } | 1102 } |
1102 | 1103 |
1103 MessageLoop* RenderThreadImpl::GetMainLoop() { | 1104 MessageLoop* RenderThreadImpl::GetMainLoop() { |
1104 return message_loop(); | 1105 return message_loop(); |
1105 } | 1106 } |
1106 | 1107 |
1107 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { | 1108 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { |
1108 return ChildProcess::current()->io_message_loop_proxy(); | 1109 return ChildProcess::current()->io_message_loop_proxy(); |
1109 } | 1110 } |
1110 | 1111 |
(...skipping 14 matching lines...) Expand all Loading... |
1125 "surface_id", | 1126 "surface_id", |
1126 surface_id); | 1127 surface_id); |
1127 | 1128 |
1128 int32 route_id = MSG_ROUTING_NONE; | 1129 int32 route_id = MSG_ROUTING_NONE; |
1129 IPC::Message* message = new GpuHostMsg_CreateViewCommandBuffer( | 1130 IPC::Message* message = new GpuHostMsg_CreateViewCommandBuffer( |
1130 surface_id, | 1131 surface_id, |
1131 init_params, | 1132 init_params, |
1132 &route_id); | 1133 &route_id); |
1133 | 1134 |
1134 // Allow calling this from the compositor thread. | 1135 // Allow calling this from the compositor thread. |
1135 if (MessageLoop::current() == message_loop()) | 1136 if (base::MessageLoop::current() == message_loop()) |
1136 ChildThread::Send(message); | 1137 ChildThread::Send(message); |
1137 else | 1138 else |
1138 sync_message_filter()->Send(message); | 1139 sync_message_filter()->Send(message); |
1139 | 1140 |
1140 return route_id; | 1141 return route_id; |
1141 } | 1142 } |
1142 | 1143 |
1143 void RenderThreadImpl::CreateImage( | 1144 void RenderThreadImpl::CreateImage( |
1144 gfx::PluginWindowHandle window, | 1145 gfx::PluginWindowHandle window, |
1145 int32 image_id, | 1146 int32 image_id, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 GetContentClient()->SetActiveURL(data); | 1324 GetContentClient()->SetActiveURL(data); |
1324 CHECK(false); | 1325 CHECK(false); |
1325 } | 1326 } |
1326 | 1327 |
1327 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { | 1328 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { |
1328 ToggleWebKitSharedTimer(suspend); | 1329 ToggleWebKitSharedTimer(suspend); |
1329 } | 1330 } |
1330 | 1331 |
1331 scoped_refptr<base::MessageLoopProxy> | 1332 scoped_refptr<base::MessageLoopProxy> |
1332 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 1333 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
1333 DCHECK(message_loop() == MessageLoop::current()); | 1334 DCHECK(message_loop() == base::MessageLoop::current()); |
1334 if (!file_thread_) { | 1335 if (!file_thread_) { |
1335 file_thread_.reset(new base::Thread("Renderer::FILE")); | 1336 file_thread_.reset(new base::Thread("Renderer::FILE")); |
1336 file_thread_->Start(); | 1337 file_thread_->Start(); |
1337 } | 1338 } |
1338 return file_thread_->message_loop_proxy(); | 1339 return file_thread_->message_loop_proxy(); |
1339 } | 1340 } |
1340 | 1341 |
1341 void RenderThreadImpl::SetFlingCurveParameters( | 1342 void RenderThreadImpl::SetFlingCurveParameters( |
1342 const std::vector<float>& new_touchpad, | 1343 const std::vector<float>& new_touchpad, |
1343 const std::vector<float>& new_touchscreen) { | 1344 const std::vector<float>& new_touchscreen) { |
1344 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1345 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
1345 new_touchscreen); | 1346 new_touchscreen); |
1346 | 1347 |
1347 } | 1348 } |
1348 | 1349 |
1349 } // namespace content | 1350 } // namespace content |
OLD | NEW |