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/resource_messages.h" | 55 #include "content/common/resource_messages.h" |
| 55 #include "content/common/view_messages.h" | 56 #include "content/common/view_messages.h" |
| 56 #include "content/common/worker_messages.h" | 57 #include "content/common/worker_messages.h" |
| 57 #include "content/public/common/content_constants.h" | 58 #include "content/public/common/content_constants.h" |
| 58 #include "content/public/common/content_paths.h" | 59 #include "content/public/common/content_paths.h" |
| 59 #include "content/public/common/content_switches.h" | 60 #include "content/public/common/content_switches.h" |
| 60 #include "content/public/common/renderer_preferences.h" | 61 #include "content/public/common/renderer_preferences.h" |
| 61 #include "content/public/common/url_constants.h" | 62 #include "content/public/common/url_constants.h" |
| 62 #include "content/public/renderer/content_renderer_client.h" | 63 #include "content/public/renderer/content_renderer_client.h" |
| 63 #include "content/public/renderer/render_process_observer.h" | 64 #include "content/public/renderer/render_process_observer.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 75 #include "content/renderer/media/audio_message_filter.h" | 76 #include "content/renderer/media/audio_message_filter.h" |
| 76 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 77 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
| 77 #include "content/renderer/media/media_stream_center.h" | 78 #include "content/renderer/media/media_stream_center.h" |
| 78 #include "content/renderer/media/media_stream_dependency_factory.h" | 79 #include "content/renderer/media/media_stream_dependency_factory.h" |
| 79 #include "content/renderer/media/midi_message_filter.h" | 80 #include "content/renderer/media/midi_message_filter.h" |
| 80 #include "content/renderer/media/peer_connection_tracker.h" | 81 #include "content/renderer/media/peer_connection_tracker.h" |
| 81 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" | 82 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" |
| 82 #include "content/renderer/media/video_capture_impl_manager.h" | 83 #include "content/renderer/media/video_capture_impl_manager.h" |
| 83 #include "content/renderer/media/video_capture_message_filter.h" | 84 #include "content/renderer/media/video_capture_message_filter.h" |
| 84 #include "content/renderer/media/webrtc_identity_service.h" | 85 #include "content/renderer/media/webrtc_identity_service.h" |
| 85 #include "content/renderer/mojo/mojo_render_process_observer.h" | |
| 86 #include "content/renderer/p2p/socket_dispatcher.h" | 86 #include "content/renderer/p2p/socket_dispatcher.h" |
| 87 #include "content/renderer/render_process_impl.h" | 87 #include "content/renderer/render_process_impl.h" |
| 88 #include "content/renderer/render_view_impl.h" | 88 #include "content/renderer/render_view_impl.h" |
| 89 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 89 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
| 90 #include "content/renderer/service_worker/embedded_worker_context_message_filter .h" | 90 #include "content/renderer/service_worker/embedded_worker_context_message_filter .h" |
| 91 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 91 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 92 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 92 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 93 #include "content/renderer/web_ui_setup_impl.h" | |
| 93 #include "grit/content_resources.h" | 94 #include "grit/content_resources.h" |
| 94 #include "ipc/ipc_channel_handle.h" | 95 #include "ipc/ipc_channel_handle.h" |
| 95 #include "ipc/ipc_forwarding_message_filter.h" | 96 #include "ipc/ipc_forwarding_message_filter.h" |
| 96 #include "ipc/ipc_platform_file.h" | 97 #include "ipc/ipc_platform_file.h" |
| 97 #include "media/base/audio_hardware_config.h" | 98 #include "media/base/audio_hardware_config.h" |
| 98 #include "media/base/media.h" | 99 #include "media/base/media.h" |
| 99 #include "media/filters/gpu_video_accelerator_factories.h" | 100 #include "media/filters/gpu_video_accelerator_factories.h" |
| 101 #include "mojo/common/common_type_converters.h" | |
| 100 #include "net/base/net_errors.h" | 102 #include "net/base/net_errors.h" |
| 101 #include "net/base/net_util.h" | 103 #include "net/base/net_util.h" |
| 102 #include "skia/ext/event_tracer_impl.h" | 104 #include "skia/ext/event_tracer_impl.h" |
| 103 #include "third_party/WebKit/public/platform/WebString.h" | 105 #include "third_party/WebKit/public/platform/WebString.h" |
| 104 #include "third_party/WebKit/public/web/WebColorName.h" | 106 #include "third_party/WebKit/public/web/WebColorName.h" |
| 105 #include "third_party/WebKit/public/web/WebDatabase.h" | 107 #include "third_party/WebKit/public/web/WebDatabase.h" |
| 106 #include "third_party/WebKit/public/web/WebDocument.h" | 108 #include "third_party/WebKit/public/web/WebDocument.h" |
| 107 #include "third_party/WebKit/public/web/WebFrame.h" | 109 #include "third_party/WebKit/public/web/WebFrame.h" |
| 108 #include "third_party/WebKit/public/web/WebImageCache.h" | 110 #include "third_party/WebKit/public/web/WebImageCache.h" |
| 109 #include "third_party/WebKit/public/web/WebKit.h" | 111 #include "third_party/WebKit/public/web/WebKit.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 v8::V8::SetCreateHistogramFunction(CreateHistogram); | 305 v8::V8::SetCreateHistogramFunction(CreateHistogram); |
| 304 } | 306 } |
| 305 } | 307 } |
| 306 | 308 |
| 307 RenderThreadImpl* RenderThreadImpl::current() { | 309 RenderThreadImpl* RenderThreadImpl::current() { |
| 308 return lazy_tls.Pointer()->Get(); | 310 return lazy_tls.Pointer()->Get(); |
| 309 } | 311 } |
| 310 | 312 |
| 311 // When we run plugins in process, we actually run them on the render thread, | 313 // When we run plugins in process, we actually run them on the render thread, |
| 312 // which means that we need to make the render thread pump UI events. | 314 // which means that we need to make the render thread pump UI events. |
| 313 RenderThreadImpl::RenderThreadImpl() { | 315 RenderThreadImpl::RenderThreadImpl() |
| 316 : mojo_application_(this) { | |
| 314 Init(); | 317 Init(); |
| 315 } | 318 } |
| 316 | 319 |
| 317 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) | 320 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) |
| 318 : ChildThread(channel_name) { | 321 : ChildThread(channel_name), |
| 322 mojo_application_(this) { | |
| 319 Init(); | 323 Init(); |
| 320 } | 324 } |
| 321 | 325 |
| 322 void RenderThreadImpl::Init() { | 326 void RenderThreadImpl::Init() { |
| 323 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); | 327 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); |
| 324 | 328 |
| 325 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( | 329 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( |
| 326 base::PlatformThread::CurrentId(), | 330 base::PlatformThread::CurrentId(), |
| 327 kTraceEventRendererMainThreadSortIndex); | 331 kTraceEventRendererMainThreadSortIndex); |
| 328 | 332 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 audio_message_filter_ = new AudioMessageFilter(GetIOMessageLoopProxy()); | 391 audio_message_filter_ = new AudioMessageFilter(GetIOMessageLoopProxy()); |
| 388 AddFilter(audio_message_filter_.get()); | 392 AddFilter(audio_message_filter_.get()); |
| 389 | 393 |
| 390 midi_message_filter_ = new MidiMessageFilter(GetIOMessageLoopProxy()); | 394 midi_message_filter_ = new MidiMessageFilter(GetIOMessageLoopProxy()); |
| 391 AddFilter(midi_message_filter_.get()); | 395 AddFilter(midi_message_filter_.get()); |
| 392 | 396 |
| 393 AddFilter((new IndexedDBMessageFilter(thread_safe_sender()))->GetFilter()); | 397 AddFilter((new IndexedDBMessageFilter(thread_safe_sender()))->GetFilter()); |
| 394 | 398 |
| 395 AddFilter((new EmbeddedWorkerContextMessageFilter())->GetFilter()); | 399 AddFilter((new EmbeddedWorkerContextMessageFilter())->GetFilter()); |
| 396 | 400 |
| 397 // MojoRenderProcessObserver deletes itself as necessary. | |
| 398 new MojoRenderProcessObserver(this); | |
| 399 | |
| 400 GetContentClient()->renderer()->RenderThreadStarted(); | 401 GetContentClient()->renderer()->RenderThreadStarted(); |
| 401 | 402 |
| 402 InitSkiaEventTracer(); | 403 InitSkiaEventTracer(); |
| 403 | 404 |
| 404 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 405 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 405 if (command_line.HasSwitch(cc::switches::kEnableGpuBenchmarking)) | 406 if (command_line.HasSwitch(cc::switches::kEnableGpuBenchmarking)) |
| 406 RegisterExtension(GpuBenchmarkingExtension::Get()); | 407 RegisterExtension(GpuBenchmarkingExtension::Get()); |
| 407 | 408 |
| 408 is_impl_side_painting_enabled_ = | 409 is_impl_side_painting_enabled_ = |
| 409 command_line.HasSwitch(switches::kEnableImplSidePainting); | 410 command_line.HasSwitch(switches::kEnableImplSidePainting); |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1195 | 1196 |
| 1196 if (!success) | 1197 if (!success) |
| 1197 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 1198 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
| 1198 | 1199 |
| 1199 return GpuMemoryBufferImpl::Create( | 1200 return GpuMemoryBufferImpl::Create( |
| 1200 handle, | 1201 handle, |
| 1201 gfx::Size(width, height), | 1202 gfx::Size(width, height), |
| 1202 internalformat).PassAs<gfx::GpuMemoryBuffer>(); | 1203 internalformat).PassAs<gfx::GpuMemoryBuffer>(); |
| 1203 } | 1204 } |
| 1204 | 1205 |
| 1206 void RenderThreadImpl::AcceptConnection( | |
| 1207 const mojo::String& service_name, | |
| 1208 mojo::ScopedMessagePipeHandle message_pipe) { | |
| 1209 // TODO(darin): Invent some kind of registration system to use here. | |
| 1210 if (service_name.To<base::StringPiece>() == kRendererService_WebUISetup) | |
| 1211 WebUISetupImpl::Bind(message_pipe.Pass()); | |
| 1212 } | |
|
sky
2014/04/22 15:52:20
DCHECK or something if we hit the else?
| |
| 1213 | |
| 1205 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { | 1214 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { |
| 1206 suspend_webkit_shared_timer_ = false; | 1215 suspend_webkit_shared_timer_ = false; |
| 1207 } | 1216 } |
| 1208 | 1217 |
| 1209 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 1218 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
| 1210 notify_webkit_of_modal_loop_ = false; | 1219 notify_webkit_of_modal_loop_ = false; |
| 1211 } | 1220 } |
| 1212 | 1221 |
| 1213 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, | 1222 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, |
| 1214 const std::string& host, | 1223 const std::string& host, |
| 1215 double zoom_level) { | 1224 double zoom_level) { |
| 1216 RenderViewZoomer zoomer(scheme, host, zoom_level); | 1225 RenderViewZoomer zoomer(scheme, host, zoom_level); |
| 1217 RenderView::ForEach(&zoomer); | 1226 RenderView::ForEach(&zoomer); |
| 1218 } | 1227 } |
| 1219 | 1228 |
| 1220 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 1229 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
| 1221 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); | 1230 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); |
| 1222 RenderProcessObserver* observer; | 1231 RenderProcessObserver* observer; |
| 1223 while ((observer = it.GetNext()) != NULL) { | 1232 while ((observer = it.GetNext()) != NULL) { |
| 1224 if (observer->OnControlMessageReceived(msg)) | 1233 if (observer->OnControlMessageReceived(msg)) |
| 1225 return true; | 1234 return true; |
| 1226 } | 1235 } |
| 1227 | 1236 |
| 1228 // Some messages are handled by delegates. | 1237 // Some messages are handled by delegates. |
| 1229 if (appcache_dispatcher_->OnMessageReceived(msg) || | 1238 if (mojo_application_.OnMessageReceived(msg) || |
| 1239 appcache_dispatcher_->OnMessageReceived(msg) || | |
| 1230 dom_storage_dispatcher_->OnMessageReceived(msg) || | 1240 dom_storage_dispatcher_->OnMessageReceived(msg) || |
| 1231 embedded_worker_dispatcher_->OnMessageReceived(msg)) { | 1241 embedded_worker_dispatcher_->OnMessageReceived(msg)) { |
| 1232 return true; | 1242 return true; |
| 1233 } | 1243 } |
| 1234 | 1244 |
| 1235 bool handled = true; | 1245 bool handled = true; |
| 1236 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) | 1246 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) |
| 1237 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, | 1247 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, |
| 1238 OnSetZoomLevelForCurrentURL) | 1248 OnSetZoomLevelForCurrentURL) |
| 1239 // TODO(port): removed from render_messages_internal.h; | 1249 // TODO(port): removed from render_messages_internal.h; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1519 hidden_widget_count_--; | 1529 hidden_widget_count_--; |
| 1520 | 1530 |
| 1521 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1531 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 1522 return; | 1532 return; |
| 1523 } | 1533 } |
| 1524 | 1534 |
| 1525 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1535 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 1526 } | 1536 } |
| 1527 | 1537 |
| 1528 } // namespace content | 1538 } // namespace content |
| OLD | NEW |