Chromium Code Reviews| 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/mojo/mojo_service_names.h" | 54 #include "content/common/render_frame_setup.mojom.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 20 matching lines...) Expand all Loading... | |
| 85 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 85 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 86 #include "content/renderer/media/webrtc_identity_service.h" | 86 #include "content/renderer/media/webrtc_identity_service.h" |
| 87 #include "content/renderer/net_info_helper.h" | 87 #include "content/renderer/net_info_helper.h" |
| 88 #include "content/renderer/p2p/socket_dispatcher.h" | 88 #include "content/renderer/p2p/socket_dispatcher.h" |
| 89 #include "content/renderer/render_process_impl.h" | 89 #include "content/renderer/render_process_impl.h" |
| 90 #include "content/renderer/render_view_impl.h" | 90 #include "content/renderer/render_view_impl.h" |
| 91 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 91 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
| 92 #include "content/renderer/service_worker/embedded_worker_context_message_filter .h" | 92 #include "content/renderer/service_worker/embedded_worker_context_message_filter .h" |
| 93 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 93 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 94 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 94 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 95 #include "content/renderer/web_ui_setup_impl.h" | |
| 96 #include "grit/content_resources.h" | 95 #include "grit/content_resources.h" |
| 97 #include "ipc/ipc_channel_handle.h" | 96 #include "ipc/ipc_channel_handle.h" |
| 98 #include "ipc/ipc_forwarding_message_filter.h" | 97 #include "ipc/ipc_forwarding_message_filter.h" |
| 99 #include "ipc/ipc_platform_file.h" | 98 #include "ipc/ipc_platform_file.h" |
| 100 #include "media/base/audio_hardware_config.h" | 99 #include "media/base/audio_hardware_config.h" |
| 101 #include "media/base/media.h" | 100 #include "media/base/media.h" |
| 102 #include "media/filters/gpu_video_accelerator_factories.h" | 101 #include "media/filters/gpu_video_accelerator_factories.h" |
| 103 #include "mojo/common/common_type_converters.h" | 102 #include "mojo/common/common_type_converters.h" |
| 104 #include "net/base/net_errors.h" | 103 #include "net/base/net_errors.h" |
| 105 #include "net/base/net_util.h" | 104 #include "net/base/net_util.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 blink::enableLogChannel(t.token().c_str()); | 257 blink::enableLogChannel(t.token().c_str()); |
| 259 } | 258 } |
| 260 | 259 |
| 261 void NotifyTimezoneChangeOnThisThread() { | 260 void NotifyTimezoneChangeOnThisThread() { |
| 262 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 261 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 263 if (!isolate) | 262 if (!isolate) |
| 264 return; | 263 return; |
| 265 v8::Date::DateTimeConfigurationChangeNotification(isolate); | 264 v8::Date::DateTimeConfigurationChangeNotification(isolate); |
| 266 } | 265 } |
| 267 | 266 |
| 267 class RenderFrameSetupImpl : public mojo::InterfaceImpl<RenderFrameSetup> { | |
| 268 public: | |
| 269 virtual void GetServiceProvider( | |
| 270 int32_t frame_routing_id, | |
| 271 mojo::InterfaceRequest<mojo::IInterfaceProvider> request) OVERRIDE { | |
| 272 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id); | |
| 273 if (!frame) { | |
|
darin (slow to review)
2014/06/21 04:33:35
Under what conditions is there no frame yet for th
Sam McNally
2014/06/24 04:00:29
There's a race between the IPC that causes the Ren
| |
| 274 RenderThreadImpl::current()->RegisterPendingRenderFrameConnect( | |
| 275 frame_routing_id, request.PassMessagePipe()); | |
| 276 return; | |
| 277 } | |
| 278 | |
| 279 frame->BindServiceRegistry(request.PassMessagePipe()); | |
| 280 } | |
| 281 | |
| 282 virtual void OnConnectionError() OVERRIDE { delete this; } | |
| 283 }; | |
| 284 | |
| 285 void CreateRenderFrameSetup(mojo::InterfaceRequest<RenderFrameSetup> request) { | |
| 286 mojo::BindToRequest(new RenderFrameSetupImpl(), &request); | |
| 287 } | |
| 288 | |
| 268 } // namespace | 289 } // namespace |
| 269 | 290 |
| 270 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { | 291 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { |
| 271 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); | 292 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); |
| 272 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); | 293 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); |
| 273 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); | 294 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); |
| 274 } | 295 } |
| 275 | 296 |
| 276 RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {} | 297 RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {} |
| 277 | 298 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 if (base::StringToInt(string_value, &num_raster_threads) && | 521 if (base::StringToInt(string_value, &num_raster_threads) && |
| 501 num_raster_threads >= kMinRasterThreads && | 522 num_raster_threads >= kMinRasterThreads && |
| 502 num_raster_threads <= kMaxRasterThreads) { | 523 num_raster_threads <= kMaxRasterThreads) { |
| 503 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); | 524 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); |
| 504 } else { | 525 } else { |
| 505 LOG(WARNING) << "Failed to parse switch " << | 526 LOG(WARNING) << "Failed to parse switch " << |
| 506 switches::kNumRasterThreads << ": " << string_value; | 527 switches::kNumRasterThreads << ": " << string_value; |
| 507 } | 528 } |
| 508 } | 529 } |
| 509 | 530 |
| 531 service_registry()->AddService<RenderFrameSetup>( | |
| 532 base::Bind(CreateRenderFrameSetup)); | |
| 533 | |
| 510 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 534 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
| 511 } | 535 } |
| 512 | 536 |
| 513 RenderThreadImpl::~RenderThreadImpl() { | 537 RenderThreadImpl::~RenderThreadImpl() { |
| 538 for (std::map<int, mojo::MessagePipeHandle>::iterator it = | |
| 539 pending_render_frame_connects_.begin(); | |
| 540 it != pending_render_frame_connects_.end(); | |
| 541 ++it) { | |
| 542 mojo::ScopedMessagePipeHandle handle(it->second); | |
|
darin (slow to review)
2014/06/21 04:33:35
nit: again, CloseRaw() might be clearer.
Sam McNally
2014/06/24 04:00:29
Done.
| |
| 543 } | |
| 514 } | 544 } |
| 515 | 545 |
| 516 void RenderThreadImpl::Shutdown() { | 546 void RenderThreadImpl::Shutdown() { |
| 517 FOR_EACH_OBSERVER( | 547 FOR_EACH_OBSERVER( |
| 518 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 548 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
| 519 | 549 |
| 520 ChildThread::Shutdown(); | 550 ChildThread::Shutdown(); |
| 521 | 551 |
| 522 // Wait for all databases to be closed. | 552 // Wait for all databases to be closed. |
| 523 if (webkit_platform_support_) { | 553 if (webkit_platform_support_) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 return sync_message_filter(); | 702 return sync_message_filter(); |
| 673 } | 703 } |
| 674 | 704 |
| 675 scoped_refptr<base::MessageLoopProxy> | 705 scoped_refptr<base::MessageLoopProxy> |
| 676 RenderThreadImpl::GetIOMessageLoopProxy() { | 706 RenderThreadImpl::GetIOMessageLoopProxy() { |
| 677 return ChildProcess::current()->io_message_loop_proxy(); | 707 return ChildProcess::current()->io_message_loop_proxy(); |
| 678 } | 708 } |
| 679 | 709 |
| 680 void RenderThreadImpl::AddRoute(int32 routing_id, IPC::Listener* listener) { | 710 void RenderThreadImpl::AddRoute(int32 routing_id, IPC::Listener* listener) { |
| 681 ChildThread::GetRouter()->AddRoute(routing_id, listener); | 711 ChildThread::GetRouter()->AddRoute(routing_id, listener); |
| 712 std::map<int, mojo::MessagePipeHandle>::iterator it = | |
| 713 pending_render_frame_connects_.find(routing_id); | |
| 714 if (it == pending_render_frame_connects_.end()) | |
| 715 return; | |
| 716 | |
| 717 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id); | |
| 718 if (!frame) | |
| 719 return; | |
| 720 | |
| 721 mojo::ScopedMessagePipeHandle handle(it->second); | |
| 722 pending_render_frame_connects_.erase(it); | |
| 723 frame->BindServiceRegistry(handle.Pass()); | |
| 682 } | 724 } |
| 683 | 725 |
| 684 void RenderThreadImpl::RemoveRoute(int32 routing_id) { | 726 void RenderThreadImpl::RemoveRoute(int32 routing_id) { |
| 685 ChildThread::GetRouter()->RemoveRoute(routing_id); | 727 ChildThread::GetRouter()->RemoveRoute(routing_id); |
| 686 } | 728 } |
| 687 | 729 |
| 688 void RenderThreadImpl::AddEmbeddedWorkerRoute(int32 routing_id, | 730 void RenderThreadImpl::AddEmbeddedWorkerRoute(int32 routing_id, |
| 689 IPC::Listener* listener) { | 731 IPC::Listener* listener) { |
| 690 AddRoute(routing_id, listener); | 732 AddRoute(routing_id, listener); |
| 691 if (devtools_agent_message_filter_.get()) { | 733 if (devtools_agent_message_filter_.get()) { |
| 692 devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread( | 734 devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread( |
| 693 routing_id); | 735 routing_id); |
| 694 } | 736 } |
| 695 } | 737 } |
| 696 | 738 |
| 697 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32 routing_id) { | 739 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32 routing_id) { |
| 698 RemoveRoute(routing_id); | 740 RemoveRoute(routing_id); |
| 699 if (devtools_agent_message_filter_.get()) { | 741 if (devtools_agent_message_filter_.get()) { |
| 700 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread( | 742 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread( |
| 701 routing_id); | 743 routing_id); |
| 702 } | 744 } |
| 703 } | 745 } |
| 704 | 746 |
| 747 void RenderThreadImpl::RegisterPendingRenderFrameConnect( | |
| 748 int routing_id, | |
| 749 mojo::ScopedMessagePipeHandle handle) { | |
| 750 std::pair<std::map<int, mojo::MessagePipeHandle>::iterator, bool> result = | |
| 751 pending_render_frame_connects_.insert( | |
| 752 std::make_pair(routing_id, handle.release())); | |
| 753 CHECK(result.second) << "Inserting a duplicate item."; | |
| 754 } | |
| 755 | |
| 705 int RenderThreadImpl::GenerateRoutingID() { | 756 int RenderThreadImpl::GenerateRoutingID() { |
| 706 int routing_id = MSG_ROUTING_NONE; | 757 int routing_id = MSG_ROUTING_NONE; |
| 707 Send(new ViewHostMsg_GenerateRoutingID(&routing_id)); | 758 Send(new ViewHostMsg_GenerateRoutingID(&routing_id)); |
| 708 return routing_id; | 759 return routing_id; |
| 709 } | 760 } |
| 710 | 761 |
| 711 void RenderThreadImpl::AddFilter(IPC::MessageFilter* filter) { | 762 void RenderThreadImpl::AddFilter(IPC::MessageFilter* filter) { |
| 712 channel()->AddFilter(filter); | 763 channel()->AddFilter(filter); |
| 713 } | 764 } |
| 714 | 765 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1087 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { | 1138 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
| 1088 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); | 1139 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |
| 1089 } | 1140 } |
| 1090 | 1141 |
| 1091 void RenderThreadImpl::ReleaseCachedFonts() { | 1142 void RenderThreadImpl::ReleaseCachedFonts() { |
| 1092 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); | 1143 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); |
| 1093 } | 1144 } |
| 1094 | 1145 |
| 1095 #endif // OS_WIN | 1146 #endif // OS_WIN |
| 1096 | 1147 |
| 1148 ServiceRegistry* RenderThreadImpl::GetServiceRegistry() { | |
| 1149 return service_registry(); | |
| 1150 } | |
| 1151 | |
| 1097 bool RenderThreadImpl::IsMainThread() { | 1152 bool RenderThreadImpl::IsMainThread() { |
| 1098 return !!current(); | 1153 return !!current(); |
| 1099 } | 1154 } |
| 1100 | 1155 |
| 1101 base::MessageLoop* RenderThreadImpl::GetMainLoop() { | 1156 base::MessageLoop* RenderThreadImpl::GetMainLoop() { |
| 1102 return message_loop(); | 1157 return message_loop(); |
| 1103 } | 1158 } |
| 1104 | 1159 |
| 1105 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { | 1160 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { |
| 1106 return io_message_loop_proxy_; | 1161 return io_message_loop_proxy_; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1167 success = sync_message_filter()->Send(message); | 1222 success = sync_message_filter()->Send(message); |
| 1168 | 1223 |
| 1169 if (!success) | 1224 if (!success) |
| 1170 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 1225 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
| 1171 | 1226 |
| 1172 return GpuMemoryBufferImpl::CreateFromHandle( | 1227 return GpuMemoryBufferImpl::CreateFromHandle( |
| 1173 handle, gfx::Size(width, height), internalformat) | 1228 handle, gfx::Size(width, height), internalformat) |
| 1174 .PassAs<gfx::GpuMemoryBuffer>(); | 1229 .PassAs<gfx::GpuMemoryBuffer>(); |
| 1175 } | 1230 } |
| 1176 | 1231 |
| 1177 void RenderThreadImpl::ConnectToService( | |
| 1178 const mojo::String& service_url, | |
| 1179 const mojo::String& service_name, | |
| 1180 mojo::ScopedMessagePipeHandle message_pipe, | |
| 1181 const mojo::String& requestor_url) { | |
| 1182 // TODO(darin): Invent some kind of registration system to use here. | |
| 1183 if (service_url.To<base::StringPiece>() == kRendererService_WebUISetup) { | |
| 1184 WebUISetupImpl::Bind(message_pipe.Pass()); | |
| 1185 } else { | |
| 1186 NOTREACHED() << "Unknown service name"; | |
| 1187 } | |
| 1188 } | |
| 1189 | |
| 1190 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { | 1232 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { |
| 1191 suspend_webkit_shared_timer_ = false; | 1233 suspend_webkit_shared_timer_ = false; |
| 1192 } | 1234 } |
| 1193 | 1235 |
| 1194 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 1236 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
| 1195 notify_webkit_of_modal_loop_ = false; | 1237 notify_webkit_of_modal_loop_ = false; |
| 1196 } | 1238 } |
| 1197 | 1239 |
| 1198 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, | 1240 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, |
| 1199 const std::string& host, | 1241 const std::string& host, |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1515 hidden_widget_count_--; | 1557 hidden_widget_count_--; |
| 1516 | 1558 |
| 1517 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1559 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 1518 return; | 1560 return; |
| 1519 } | 1561 } |
| 1520 | 1562 |
| 1521 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1563 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 1522 } | 1564 } |
| 1523 | 1565 |
| 1524 } // namespace content | 1566 } // namespace content |
| OLD | NEW |