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 16 matching lines...) Expand all Loading... |
27 #include "base/threading/thread_restrictions.h" | 27 #include "base/threading/thread_restrictions.h" |
28 #include "base/values.h" | 28 #include "base/values.h" |
29 #include "content/child/appcache_dispatcher.h" | 29 #include "content/child/appcache_dispatcher.h" |
30 #include "content/child/child_histogram_message_filter.h" | 30 #include "content/child/child_histogram_message_filter.h" |
31 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 31 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
32 #include "content/child/indexed_db/indexed_db_message_filter.h" | 32 #include "content/child/indexed_db/indexed_db_message_filter.h" |
33 #include "content/child/npobject_util.h" | 33 #include "content/child/npobject_util.h" |
34 #include "content/child/plugin_messages.h" | 34 #include "content/child/plugin_messages.h" |
35 #include "content/child/resource_dispatcher.h" | 35 #include "content/child/resource_dispatcher.h" |
36 #include "content/child/runtime_features.h" | 36 #include "content/child/runtime_features.h" |
| 37 #include "content/child/thread_safe_sender.h" |
37 #include "content/child/web_database_observer_impl.h" | 38 #include "content/child/web_database_observer_impl.h" |
38 #include "content/common/child_process_messages.h" | 39 #include "content/common/child_process_messages.h" |
39 #include "content/common/database_messages.h" | 40 #include "content/common/database_messages.h" |
40 #include "content/common/db_message_filter.h" | 41 #include "content/common/db_message_filter.h" |
41 #include "content/common/dom_storage_messages.h" | 42 #include "content/common/dom_storage_messages.h" |
42 #include "content/common/gpu/client/context_provider_command_buffer.h" | 43 #include "content/common/gpu/client/context_provider_command_buffer.h" |
43 #include "content/common/gpu/client/gpu_channel_host.h" | 44 #include "content/common/gpu/client/gpu_channel_host.h" |
44 #include "content/common/gpu/gpu_messages.h" | 45 #include "content/common/gpu/gpu_messages.h" |
45 #include "content/common/resource_messages.h" | 46 #include "content/common/resource_messages.h" |
46 #include "content/common/view_messages.h" | 47 #include "content/common/view_messages.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 ChildProcess::current()->set_main_thread(this); | 338 ChildProcess::current()->set_main_thread(this); |
338 | 339 |
339 // In single process the single process is all there is. | 340 // In single process the single process is all there is. |
340 suspend_webkit_shared_timer_ = true; | 341 suspend_webkit_shared_timer_ = true; |
341 notify_webkit_of_modal_loop_ = true; | 342 notify_webkit_of_modal_loop_ = true; |
342 widget_count_ = 0; | 343 widget_count_ = 0; |
343 hidden_widget_count_ = 0; | 344 hidden_widget_count_ = 0; |
344 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 345 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
345 idle_notifications_to_skip_ = 0; | 346 idle_notifications_to_skip_ = 0; |
346 layout_test_mode_ = false; | 347 layout_test_mode_ = false; |
| 348 shutdown_event_ = NULL; |
347 | 349 |
348 appcache_dispatcher_.reset( | 350 appcache_dispatcher_.reset( |
349 new AppCacheDispatcher(Get(), new appcache::AppCacheFrontendImpl())); | 351 new AppCacheDispatcher(Get(), new appcache::AppCacheFrontendImpl())); |
350 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); | 352 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); |
351 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher()); | 353 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher()); |
352 | 354 |
353 media_stream_center_ = NULL; | 355 media_stream_center_ = NULL; |
354 | 356 |
355 db_message_filter_ = new DBMessageFilter(); | 357 db_message_filter_ = new DBMessageFilter(); |
356 AddFilter(db_message_filter_.get()); | 358 AddFilter(db_message_filter_.get()); |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { | 999 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
998 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); | 1000 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |
999 } | 1001 } |
1000 | 1002 |
1001 void RenderThreadImpl::ReleaseCachedFonts() { | 1003 void RenderThreadImpl::ReleaseCachedFonts() { |
1002 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); | 1004 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); |
1003 } | 1005 } |
1004 | 1006 |
1005 #endif // OS_WIN | 1007 #endif // OS_WIN |
1006 | 1008 |
1007 bool RenderThreadImpl::IsWebFrameValid(WebKit::WebFrame* web_frame) { | |
1008 if (!web_frame) | |
1009 return false; // We must be shutting down. | |
1010 | |
1011 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | |
1012 if (!render_view) | |
1013 return false; // We must be shutting down. | |
1014 | |
1015 return true; | |
1016 } | |
1017 | |
1018 bool RenderThreadImpl::IsMainThread() { | 1009 bool RenderThreadImpl::IsMainThread() { |
1019 return !!current(); | 1010 return !!current(); |
1020 } | 1011 } |
1021 | 1012 |
1022 base::MessageLoop* RenderThreadImpl::GetMainLoop() { | 1013 base::MessageLoop* RenderThreadImpl::GetMainLoop() { |
1023 return message_loop(); | 1014 return message_loop(); |
1024 } | 1015 } |
1025 | 1016 |
1026 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { | 1017 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { |
1027 return ChildProcess::current()->io_message_loop_proxy(); | 1018 return io_message_loop_proxy_; |
1028 } | 1019 } |
1029 | 1020 |
1030 base::WaitableEvent* RenderThreadImpl::GetShutDownEvent() { | 1021 base::WaitableEvent* RenderThreadImpl::GetShutDownEvent() { |
1031 return ChildProcess::current()->GetShutDownEvent(); | 1022 return shutdown_event_; |
1032 } | 1023 } |
1033 | 1024 |
1034 scoped_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( | 1025 scoped_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( |
1035 size_t size) { | 1026 size_t size) { |
1036 return scoped_ptr<base::SharedMemory>( | 1027 return scoped_ptr<base::SharedMemory>( |
1037 HostAllocateSharedMemoryBuffer(size)); | 1028 HostAllocateSharedMemoryBuffer(size)); |
1038 } | 1029 } |
1039 | 1030 |
1040 int32 RenderThreadImpl::CreateViewCommandBuffer( | 1031 int32 RenderThreadImpl::CreateViewCommandBuffer( |
1041 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) { | 1032 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) { |
1042 TRACE_EVENT1("gpu", | 1033 TRACE_EVENT1("gpu", |
1043 "RenderThreadImpl::CreateViewCommandBuffer", | 1034 "RenderThreadImpl::CreateViewCommandBuffer", |
1044 "surface_id", | 1035 "surface_id", |
1045 surface_id); | 1036 surface_id); |
1046 | 1037 |
1047 int32 route_id = MSG_ROUTING_NONE; | 1038 int32 route_id = MSG_ROUTING_NONE; |
1048 IPC::Message* message = new GpuHostMsg_CreateViewCommandBuffer( | 1039 IPC::Message* message = new GpuHostMsg_CreateViewCommandBuffer( |
1049 surface_id, | 1040 surface_id, |
1050 init_params, | 1041 init_params, |
1051 &route_id); | 1042 &route_id); |
1052 | 1043 |
1053 // Allow calling this from the compositor thread. | 1044 // Allow calling this from the compositor thread. |
1054 if (base::MessageLoop::current() == message_loop()) | 1045 thread_safe_sender()->Send(message); |
1055 ChildThread::Send(message); | |
1056 else | |
1057 sync_message_filter()->Send(message); | |
1058 | 1046 |
1059 return route_id; | 1047 return route_id; |
1060 } | 1048 } |
1061 | 1049 |
1062 void RenderThreadImpl::CreateImage( | 1050 void RenderThreadImpl::CreateImage( |
1063 gfx::PluginWindowHandle window, | 1051 gfx::PluginWindowHandle window, |
1064 int32 image_id, | 1052 int32 image_id, |
1065 const CreateImageCallback& callback) { | 1053 const CreateImageCallback& callback) { |
1066 NOTREACHED(); | 1054 NOTREACHED(); |
1067 } | 1055 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 &gpu_info)) || | 1149 &gpu_info)) || |
1162 #if defined(OS_POSIX) | 1150 #if defined(OS_POSIX) |
1163 channel_handle.socket.fd == -1 || | 1151 channel_handle.socket.fd == -1 || |
1164 #endif | 1152 #endif |
1165 channel_handle.name.empty()) { | 1153 channel_handle.name.empty()) { |
1166 // Otherwise cancel the connection. | 1154 // Otherwise cancel the connection. |
1167 return NULL; | 1155 return NULL; |
1168 } | 1156 } |
1169 | 1157 |
1170 GetContentClient()->SetGpuInfo(gpu_info); | 1158 GetContentClient()->SetGpuInfo(gpu_info); |
| 1159 |
| 1160 // Cache some variables that are needed on the compositor thread for our |
| 1161 // implementation of GpuChannelHostFactory. |
| 1162 io_message_loop_proxy_ = ChildProcess::current()->io_message_loop_proxy(); |
| 1163 shutdown_event_ = ChildProcess::current()->GetShutDownEvent(); |
| 1164 |
1171 gpu_channel_ = GpuChannelHost::Create( | 1165 gpu_channel_ = GpuChannelHost::Create( |
1172 this, 0, client_id, gpu_info, channel_handle); | 1166 this, 0, client_id, gpu_info, channel_handle); |
1173 return gpu_channel_.get(); | 1167 return gpu_channel_.get(); |
1174 } | 1168 } |
1175 | 1169 |
1176 WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( | 1170 WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( |
1177 WebKit::WebMediaStreamCenterClient* client) { | 1171 WebKit::WebMediaStreamCenterClient* client) { |
1178 #if defined(OS_ANDROID) | 1172 #if defined(OS_ANDROID) |
1179 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1173 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1180 switches::kDisableWebRTC)) | 1174 switches::kDisableWebRTC)) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 | 1258 |
1265 void RenderThreadImpl::SetFlingCurveParameters( | 1259 void RenderThreadImpl::SetFlingCurveParameters( |
1266 const std::vector<float>& new_touchpad, | 1260 const std::vector<float>& new_touchpad, |
1267 const std::vector<float>& new_touchscreen) { | 1261 const std::vector<float>& new_touchscreen) { |
1268 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1262 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
1269 new_touchscreen); | 1263 new_touchscreen); |
1270 | 1264 |
1271 } | 1265 } |
1272 | 1266 |
1273 } // namespace content | 1267 } // namespace content |
OLD | NEW |