| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "content/child/worker_task_runner.h" | 44 #include "content/child/worker_task_runner.h" |
| 45 #include "content/common/child_process_messages.h" | 45 #include "content/common/child_process_messages.h" |
| 46 #include "content/common/content_constants_internal.h" | 46 #include "content/common/content_constants_internal.h" |
| 47 #include "content/common/database_messages.h" | 47 #include "content/common/database_messages.h" |
| 48 #include "content/common/dom_storage/dom_storage_messages.h" | 48 #include "content/common/dom_storage/dom_storage_messages.h" |
| 49 #include "content/common/gpu/client/context_provider_command_buffer.h" | 49 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 50 #include "content/common/gpu/client/gpu_channel_host.h" | 50 #include "content/common/gpu/client/gpu_channel_host.h" |
| 51 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 51 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 52 #include "content/common/gpu/gpu_messages.h" | 52 #include "content/common/gpu/gpu_messages.h" |
| 53 #include "content/common/gpu/gpu_process_launch_causes.h" | 53 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 54 #include "content/common/render_frame_setup.mojom.h" | 54 #include "content/common/mojo/mojo_service_names.h" |
| 55 #include "content/common/resource_messages.h" | 55 #include "content/common/resource_messages.h" |
| 56 #include "content/common/view_messages.h" | 56 #include "content/common/view_messages.h" |
| 57 #include "content/common/worker_messages.h" | 57 #include "content/common/worker_messages.h" |
| 58 #include "content/public/common/content_constants.h" | 58 #include "content/public/common/content_constants.h" |
| 59 #include "content/public/common/content_paths.h" | 59 #include "content/public/common/content_paths.h" |
| 60 #include "content/public/common/content_switches.h" | 60 #include "content/public/common/content_switches.h" |
| 61 #include "content/public/common/renderer_preferences.h" | 61 #include "content/public/common/renderer_preferences.h" |
| 62 #include "content/public/common/url_constants.h" | 62 #include "content/public/common/url_constants.h" |
| 63 #include "content/public/renderer/content_renderer_client.h" | 63 #include "content/public/renderer/content_renderer_client.h" |
| 64 #include "content/public/renderer/render_process_observer.h" | 64 #include "content/public/renderer/render_process_observer.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 88 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 88 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 89 #include "content/renderer/media/webrtc_identity_service.h" | 89 #include "content/renderer/media/webrtc_identity_service.h" |
| 90 #include "content/renderer/net_info_helper.h" | 90 #include "content/renderer/net_info_helper.h" |
| 91 #include "content/renderer/p2p/socket_dispatcher.h" | 91 #include "content/renderer/p2p/socket_dispatcher.h" |
| 92 #include "content/renderer/render_process_impl.h" | 92 #include "content/renderer/render_process_impl.h" |
| 93 #include "content/renderer/render_view_impl.h" | 93 #include "content/renderer/render_view_impl.h" |
| 94 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 94 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
| 95 #include "content/renderer/service_worker/embedded_worker_context_message_filter
.h" | 95 #include "content/renderer/service_worker/embedded_worker_context_message_filter
.h" |
| 96 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 96 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 97 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 97 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 98 #include "content/renderer/web_ui_setup_impl.h" |
| 98 #include "grit/content_resources.h" | 99 #include "grit/content_resources.h" |
| 99 #include "ipc/ipc_channel_handle.h" | 100 #include "ipc/ipc_channel_handle.h" |
| 100 #include "ipc/ipc_forwarding_message_filter.h" | 101 #include "ipc/ipc_forwarding_message_filter.h" |
| 101 #include "ipc/ipc_platform_file.h" | 102 #include "ipc/ipc_platform_file.h" |
| 102 #include "media/base/audio_hardware_config.h" | 103 #include "media/base/audio_hardware_config.h" |
| 103 #include "media/base/media.h" | 104 #include "media/base/media.h" |
| 104 #include "media/filters/gpu_video_accelerator_factories.h" | 105 #include "media/filters/gpu_video_accelerator_factories.h" |
| 105 #include "mojo/common/common_type_converters.h" | 106 #include "mojo/common/common_type_converters.h" |
| 106 #include "net/base/net_errors.h" | 107 #include "net/base/net_errors.h" |
| 107 #include "net/base/net_util.h" | 108 #include "net/base/net_util.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 blink::enableLogChannel(t.token().c_str()); | 259 blink::enableLogChannel(t.token().c_str()); |
| 259 } | 260 } |
| 260 | 261 |
| 261 void NotifyTimezoneChangeOnThisThread() { | 262 void NotifyTimezoneChangeOnThisThread() { |
| 262 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 263 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 263 if (!isolate) | 264 if (!isolate) |
| 264 return; | 265 return; |
| 265 v8::Date::DateTimeConfigurationChangeNotification(isolate); | 266 v8::Date::DateTimeConfigurationChangeNotification(isolate); |
| 266 } | 267 } |
| 267 | 268 |
| 268 class RenderFrameSetupImpl : public mojo::InterfaceImpl<RenderFrameSetup> { | |
| 269 public: | |
| 270 virtual void GetServiceProviderForFrame( | |
| 271 int32_t frame_routing_id, | |
| 272 mojo::InterfaceRequest<mojo::IInterfaceProvider> request) OVERRIDE { | |
| 273 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id); | |
| 274 // We can receive a GetServiceProviderForFrame message for a frame not yet | |
| 275 // created due to a race between the message and a ViewMsg_New IPC that | |
| 276 // triggers creation of the RenderFrame we want. | |
| 277 if (!frame) { | |
| 278 RenderThreadImpl::current()->RegisterPendingRenderFrameConnect( | |
| 279 frame_routing_id, request.PassMessagePipe()); | |
| 280 return; | |
| 281 } | |
| 282 | |
| 283 frame->BindServiceRegistry(request.PassMessagePipe()); | |
| 284 } | |
| 285 | |
| 286 virtual void OnConnectionError() OVERRIDE { delete this; } | |
| 287 }; | |
| 288 | |
| 289 void CreateRenderFrameSetup(mojo::InterfaceRequest<RenderFrameSetup> request) { | |
| 290 mojo::BindToRequest(new RenderFrameSetupImpl(), &request); | |
| 291 } | |
| 292 | |
| 293 } // namespace | 269 } // namespace |
| 294 | 270 |
| 295 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { | 271 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { |
| 296 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); | 272 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); |
| 297 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); | 273 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); |
| 298 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); | 274 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); |
| 299 } | 275 } |
| 300 | 276 |
| 301 RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {} | 277 RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {} |
| 302 | 278 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 if (base::StringToInt(string_value, &num_raster_threads) && | 501 if (base::StringToInt(string_value, &num_raster_threads) && |
| 526 num_raster_threads >= kMinRasterThreads && | 502 num_raster_threads >= kMinRasterThreads && |
| 527 num_raster_threads <= kMaxRasterThreads) { | 503 num_raster_threads <= kMaxRasterThreads) { |
| 528 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); | 504 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); |
| 529 } else { | 505 } else { |
| 530 LOG(WARNING) << "Failed to parse switch " << | 506 LOG(WARNING) << "Failed to parse switch " << |
| 531 switches::kNumRasterThreads << ": " << string_value; | 507 switches::kNumRasterThreads << ": " << string_value; |
| 532 } | 508 } |
| 533 } | 509 } |
| 534 | 510 |
| 535 service_registry()->AddService<RenderFrameSetup>( | |
| 536 base::Bind(CreateRenderFrameSetup)); | |
| 537 | |
| 538 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 511 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
| 539 } | 512 } |
| 540 | 513 |
| 541 RenderThreadImpl::~RenderThreadImpl() { | 514 RenderThreadImpl::~RenderThreadImpl() { |
| 542 for (std::map<int, mojo::MessagePipeHandle>::iterator it = | |
| 543 pending_render_frame_connects_.begin(); | |
| 544 it != pending_render_frame_connects_.end(); | |
| 545 ++it) { | |
| 546 mojo::CloseRaw(it->second); | |
| 547 } | |
| 548 } | 515 } |
| 549 | 516 |
| 550 void RenderThreadImpl::Shutdown() { | 517 void RenderThreadImpl::Shutdown() { |
| 551 FOR_EACH_OBSERVER( | 518 FOR_EACH_OBSERVER( |
| 552 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 519 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
| 553 | 520 |
| 554 ChildThread::Shutdown(); | 521 ChildThread::Shutdown(); |
| 555 | 522 |
| 556 // Wait for all databases to be closed. | 523 // Wait for all databases to be closed. |
| 557 if (webkit_platform_support_) { | 524 if (webkit_platform_support_) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 return sync_message_filter(); | 673 return sync_message_filter(); |
| 707 } | 674 } |
| 708 | 675 |
| 709 scoped_refptr<base::MessageLoopProxy> | 676 scoped_refptr<base::MessageLoopProxy> |
| 710 RenderThreadImpl::GetIOMessageLoopProxy() { | 677 RenderThreadImpl::GetIOMessageLoopProxy() { |
| 711 return ChildProcess::current()->io_message_loop_proxy(); | 678 return ChildProcess::current()->io_message_loop_proxy(); |
| 712 } | 679 } |
| 713 | 680 |
| 714 void RenderThreadImpl::AddRoute(int32 routing_id, IPC::Listener* listener) { | 681 void RenderThreadImpl::AddRoute(int32 routing_id, IPC::Listener* listener) { |
| 715 ChildThread::GetRouter()->AddRoute(routing_id, listener); | 682 ChildThread::GetRouter()->AddRoute(routing_id, listener); |
| 716 std::map<int, mojo::MessagePipeHandle>::iterator it = | |
| 717 pending_render_frame_connects_.find(routing_id); | |
| 718 if (it == pending_render_frame_connects_.end()) | |
| 719 return; | |
| 720 | |
| 721 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id); | |
| 722 if (!frame) | |
| 723 return; | |
| 724 | |
| 725 mojo::ScopedMessagePipeHandle handle(it->second); | |
| 726 pending_render_frame_connects_.erase(it); | |
| 727 frame->BindServiceRegistry(handle.Pass()); | |
| 728 } | 683 } |
| 729 | 684 |
| 730 void RenderThreadImpl::RemoveRoute(int32 routing_id) { | 685 void RenderThreadImpl::RemoveRoute(int32 routing_id) { |
| 731 ChildThread::GetRouter()->RemoveRoute(routing_id); | 686 ChildThread::GetRouter()->RemoveRoute(routing_id); |
| 732 } | 687 } |
| 733 | 688 |
| 734 void RenderThreadImpl::AddEmbeddedWorkerRoute(int32 routing_id, | 689 void RenderThreadImpl::AddEmbeddedWorkerRoute(int32 routing_id, |
| 735 IPC::Listener* listener) { | 690 IPC::Listener* listener) { |
| 736 AddRoute(routing_id, listener); | 691 AddRoute(routing_id, listener); |
| 737 if (devtools_agent_message_filter_.get()) { | 692 if (devtools_agent_message_filter_.get()) { |
| 738 devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread( | 693 devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread( |
| 739 routing_id); | 694 routing_id); |
| 740 } | 695 } |
| 741 } | 696 } |
| 742 | 697 |
| 743 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32 routing_id) { | 698 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32 routing_id) { |
| 744 RemoveRoute(routing_id); | 699 RemoveRoute(routing_id); |
| 745 if (devtools_agent_message_filter_.get()) { | 700 if (devtools_agent_message_filter_.get()) { |
| 746 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread( | 701 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread( |
| 747 routing_id); | 702 routing_id); |
| 748 } | 703 } |
| 749 } | 704 } |
| 750 | 705 |
| 751 void RenderThreadImpl::RegisterPendingRenderFrameConnect( | |
| 752 int routing_id, | |
| 753 mojo::ScopedMessagePipeHandle handle) { | |
| 754 std::pair<std::map<int, mojo::MessagePipeHandle>::iterator, bool> result = | |
| 755 pending_render_frame_connects_.insert( | |
| 756 std::make_pair(routing_id, handle.release())); | |
| 757 CHECK(result.second) << "Inserting a duplicate item."; | |
| 758 } | |
| 759 | |
| 760 int RenderThreadImpl::GenerateRoutingID() { | 706 int RenderThreadImpl::GenerateRoutingID() { |
| 761 int routing_id = MSG_ROUTING_NONE; | 707 int routing_id = MSG_ROUTING_NONE; |
| 762 Send(new ViewHostMsg_GenerateRoutingID(&routing_id)); | 708 Send(new ViewHostMsg_GenerateRoutingID(&routing_id)); |
| 763 return routing_id; | 709 return routing_id; |
| 764 } | 710 } |
| 765 | 711 |
| 766 void RenderThreadImpl::AddFilter(IPC::MessageFilter* filter) { | 712 void RenderThreadImpl::AddFilter(IPC::MessageFilter* filter) { |
| 767 channel()->AddFilter(filter); | 713 channel()->AddFilter(filter); |
| 768 } | 714 } |
| 769 | 715 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { | 1092 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
| 1147 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); | 1093 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |
| 1148 } | 1094 } |
| 1149 | 1095 |
| 1150 void RenderThreadImpl::ReleaseCachedFonts() { | 1096 void RenderThreadImpl::ReleaseCachedFonts() { |
| 1151 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); | 1097 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); |
| 1152 } | 1098 } |
| 1153 | 1099 |
| 1154 #endif // OS_WIN | 1100 #endif // OS_WIN |
| 1155 | 1101 |
| 1156 ServiceRegistry* RenderThreadImpl::GetServiceRegistry() { | |
| 1157 return service_registry(); | |
| 1158 } | |
| 1159 | |
| 1160 bool RenderThreadImpl::IsMainThread() { | 1102 bool RenderThreadImpl::IsMainThread() { |
| 1161 return !!current(); | 1103 return !!current(); |
| 1162 } | 1104 } |
| 1163 | 1105 |
| 1164 base::MessageLoop* RenderThreadImpl::GetMainLoop() { | 1106 base::MessageLoop* RenderThreadImpl::GetMainLoop() { |
| 1165 return message_loop(); | 1107 return message_loop(); |
| 1166 } | 1108 } |
| 1167 | 1109 |
| 1168 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { | 1110 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { |
| 1169 return io_message_loop_proxy_; | 1111 return io_message_loop_proxy_; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 success = sync_message_filter()->Send(message); | 1172 success = sync_message_filter()->Send(message); |
| 1231 | 1173 |
| 1232 if (!success) | 1174 if (!success) |
| 1233 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 1175 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
| 1234 | 1176 |
| 1235 return GpuMemoryBufferImpl::CreateFromHandle( | 1177 return GpuMemoryBufferImpl::CreateFromHandle( |
| 1236 handle, gfx::Size(width, height), internalformat) | 1178 handle, gfx::Size(width, height), internalformat) |
| 1237 .PassAs<gfx::GpuMemoryBuffer>(); | 1179 .PassAs<gfx::GpuMemoryBuffer>(); |
| 1238 } | 1180 } |
| 1239 | 1181 |
| 1182 void RenderThreadImpl::ConnectToService( |
| 1183 const mojo::String& service_url, |
| 1184 const mojo::String& service_name, |
| 1185 mojo::ScopedMessagePipeHandle message_pipe, |
| 1186 const mojo::String& requestor_url) { |
| 1187 // TODO(darin): Invent some kind of registration system to use here. |
| 1188 if (service_url.To<base::StringPiece>() == kRendererService_WebUISetup) { |
| 1189 WebUISetupImpl::Bind(message_pipe.Pass()); |
| 1190 } else { |
| 1191 NOTREACHED() << "Unknown service name"; |
| 1192 } |
| 1193 } |
| 1194 |
| 1240 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { | 1195 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { |
| 1241 suspend_webkit_shared_timer_ = false; | 1196 suspend_webkit_shared_timer_ = false; |
| 1242 } | 1197 } |
| 1243 | 1198 |
| 1244 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 1199 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
| 1245 notify_webkit_of_modal_loop_ = false; | 1200 notify_webkit_of_modal_loop_ = false; |
| 1246 } | 1201 } |
| 1247 | 1202 |
| 1248 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, | 1203 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, |
| 1249 const std::string& host, | 1204 const std::string& host, |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 hidden_widget_count_--; | 1520 hidden_widget_count_--; |
| 1566 | 1521 |
| 1567 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1522 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 1568 return; | 1523 return; |
| 1569 } | 1524 } |
| 1570 | 1525 |
| 1571 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1526 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 1572 } | 1527 } |
| 1573 | 1528 |
| 1574 } // namespace content | 1529 } // namespace content |
| OLD | NEW |