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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 #include "content/browser/renderer_host/media/video_capture_host.h" | 77 #include "content/browser/renderer_host/media/video_capture_host.h" |
78 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h" | 78 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h" |
79 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 79 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
80 #include "content/browser/renderer_host/quota_dispatcher_host.h" | 80 #include "content/browser/renderer_host/quota_dispatcher_host.h" |
81 #include "content/browser/renderer_host/render_message_filter.h" | 81 #include "content/browser/renderer_host/render_message_filter.h" |
82 #include "content/browser/renderer_host/render_view_host_delegate.h" | 82 #include "content/browser/renderer_host/render_view_host_delegate.h" |
83 #include "content/browser/renderer_host/render_view_host_impl.h" | 83 #include "content/browser/renderer_host/render_view_host_impl.h" |
84 #include "content/browser/renderer_host/render_widget_helper.h" | 84 #include "content/browser/renderer_host/render_widget_helper.h" |
85 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" | 85 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" |
86 #include "content/browser/renderer_host/text_input_client_message_filter.h" | 86 #include "content/browser/renderer_host/text_input_client_message_filter.h" |
| 87 #include "content/browser/renderer_host/url_handling_message_filter.h" |
87 #include "content/browser/renderer_host/webrtc_logging_handler_host.h" | 88 #include "content/browser/renderer_host/webrtc_logging_handler_host.h" |
88 #include "content/browser/resolve_proxy_msg_helper.h" | 89 #include "content/browser/resolve_proxy_msg_helper.h" |
89 #include "content/browser/speech/input_tag_speech_dispatcher_host.h" | 90 #include "content/browser/speech/input_tag_speech_dispatcher_host.h" |
90 #include "content/browser/speech/speech_recognition_dispatcher_host.h" | 91 #include "content/browser/speech/speech_recognition_dispatcher_host.h" |
91 #include "content/browser/storage_partition_impl.h" | 92 #include "content/browser/storage_partition_impl.h" |
92 #include "content/browser/tracing/trace_message_filter.h" | 93 #include "content/browser/tracing/trace_message_filter.h" |
93 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 94 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
94 #include "content/browser/worker_host/worker_message_filter.h" | 95 #include "content/browser/worker_host/worker_message_filter.h" |
95 #include "content/browser/worker_host/worker_storage_partition.h" | 96 #include "content/browser/worker_host/worker_storage_partition.h" |
96 #include "content/common/child_process_host_impl.h" | 97 #include "content/common/child_process_host_impl.h" |
97 #include "content/common/child_process_messages.h" | 98 #include "content/common/child_process_messages.h" |
98 #include "content/common/gpu/gpu_messages.h" | 99 #include "content/common/gpu/gpu_messages.h" |
99 #include "content/common/resource_messages.h" | 100 #include "content/common/resource_messages.h" |
100 #include "content/common/view_messages.h" | 101 #include "content/common/view_messages.h" |
101 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" | 102 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
102 #include "content/public/browser/browser_context.h" | 103 #include "content/public/browser/browser_context.h" |
103 #include "content/public/browser/content_browser_client.h" | 104 #include "content/public/browser/content_browser_client.h" |
104 #include "content/public/browser/notification_service.h" | 105 #include "content/public/browser/notification_service.h" |
105 #include "content/public/browser/notification_types.h" | 106 #include "content/public/browser/notification_types.h" |
106 #include "content/public/browser/render_process_host_factory.h" | 107 #include "content/public/browser/render_process_host_factory.h" |
107 #include "content/public/browser/resource_context.h" | 108 #include "content/public/browser/resource_context.h" |
108 #include "content/public/browser/user_metrics.h" | 109 #include "content/public/browser/user_metrics.h" |
109 #include "content/public/common/content_constants.h" | 110 #include "content/public/common/content_constants.h" |
110 #include "content/public/common/content_switches.h" | 111 #include "content/public/common/content_switches.h" |
111 #include "content/public/common/process_type.h" | 112 #include "content/public/common/process_type.h" |
112 #include "content/public/common/result_codes.h" | 113 #include "content/public/common/result_codes.h" |
113 #include "content/public/common/url_constants.h" | 114 #include "content/public/common/url_constants.h" |
| 115 #include "content/public/common/url_handling_messages.h" |
114 #include "content/renderer/render_process_impl.h" | 116 #include "content/renderer/render_process_impl.h" |
115 #include "content/renderer/render_thread_impl.h" | 117 #include "content/renderer/render_thread_impl.h" |
116 #include "ipc/ipc_channel.h" | 118 #include "ipc/ipc_channel.h" |
117 #include "ipc/ipc_logging.h" | 119 #include "ipc/ipc_logging.h" |
118 #include "ipc/ipc_platform_file.h" | 120 #include "ipc/ipc_platform_file.h" |
119 #include "ipc/ipc_switches.h" | 121 #include "ipc/ipc_switches.h" |
120 #include "ipc/ipc_sync_channel.h" | 122 #include "ipc/ipc_sync_channel.h" |
121 #include "media/base/media_switches.h" | 123 #include "media/base/media_switches.h" |
122 #include "net/url_request/url_request_context_getter.h" | 124 #include "net/url_request/url_request_context_getter.h" |
123 #include "ppapi/shared_impl/ppapi_switches.h" | 125 #include "ppapi/shared_impl/ppapi_switches.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 536 |
535 fast_shutdown_started_ = false; | 537 fast_shutdown_started_ = false; |
536 } | 538 } |
537 | 539 |
538 is_initialized_ = true; | 540 is_initialized_ = true; |
539 return true; | 541 return true; |
540 } | 542 } |
541 | 543 |
542 void RenderProcessHostImpl::CreateMessageFilters() { | 544 void RenderProcessHostImpl::CreateMessageFilters() { |
543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 546 |
544 channel_->AddFilter(new ResourceSchedulerFilter(GetID())); | 547 channel_->AddFilter(new ResourceSchedulerFilter(GetID())); |
545 MediaInternals* media_internals = MediaInternals::GetInstance();; | 548 |
| 549 MediaInternals* media_internals = MediaInternals::GetInstance(); |
| 550 |
546 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages | 551 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages |
547 // from guests. | 552 // from guests. |
548 if (supports_browser_plugin_) { | 553 if (supports_browser_plugin_) { |
549 scoped_refptr<BrowserPluginMessageFilter> bp_message_filter( | 554 scoped_refptr<BrowserPluginMessageFilter> bp_message_filter( |
550 new BrowserPluginMessageFilter(GetID(), IsGuest())); | 555 new BrowserPluginMessageFilter(GetID(), IsGuest())); |
551 channel_->AddFilter(bp_message_filter); | 556 channel_->AddFilter(bp_message_filter); |
552 } | 557 } |
553 | 558 |
554 scoped_refptr<RenderMessageFilter> render_message_filter( | 559 scoped_refptr<RenderMessageFilter> render_message_filter( |
555 new RenderMessageFilter( | 560 new RenderMessageFilter( |
556 GetID(), | 561 GetID(), |
557 #if defined(ENABLE_PLUGINS) | 562 #if defined(ENABLE_PLUGINS) |
558 PluginServiceImpl::GetInstance(), | 563 PluginServiceImpl::GetInstance(), |
559 #else | 564 #else |
560 NULL, | 565 NULL, |
561 #endif | 566 #endif |
562 GetBrowserContext(), | 567 GetBrowserContext(), |
563 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), | 568 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), |
564 widget_helper_, | 569 widget_helper_, |
565 media_internals, | 570 media_internals, |
566 storage_partition_impl_->GetDOMStorageContext())); | 571 storage_partition_impl_->GetDOMStorageContext())); |
567 channel_->AddFilter(render_message_filter); | 572 channel_->AddFilter(render_message_filter); |
| 573 |
568 BrowserContext* browser_context = GetBrowserContext(); | 574 BrowserContext* browser_context = GetBrowserContext(); |
| 575 |
569 ResourceContext* resource_context = browser_context->GetResourceContext(); | 576 ResourceContext* resource_context = browser_context->GetResourceContext(); |
570 | |
571 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 577 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
572 GetID(), PROCESS_TYPE_RENDERER, resource_context, | 578 GetID(), PROCESS_TYPE_RENDERER, resource_context, |
573 storage_partition_impl_->GetAppCacheService(), | 579 storage_partition_impl_->GetAppCacheService(), |
574 ChromeBlobStorageContext::GetFor(browser_context), | 580 ChromeBlobStorageContext::GetFor(browser_context), |
575 storage_partition_impl_->GetFileSystemContext(), | 581 storage_partition_impl_->GetFileSystemContext(), |
576 new RendererURLRequestContextSelector(browser_context, GetID())); | 582 new RendererURLRequestContextSelector(browser_context, GetID())); |
| 583 channel_->AddFilter(resource_message_filter); |
577 | 584 |
578 channel_->AddFilter(resource_message_filter); | |
579 media::AudioManager* audio_manager = BrowserMainLoop::GetAudioManager(); | 585 media::AudioManager* audio_manager = BrowserMainLoop::GetAudioManager(); |
580 MediaStreamManager* media_stream_manager = | 586 MediaStreamManager* media_stream_manager = |
581 BrowserMainLoop::GetMediaStreamManager(); | 587 BrowserMainLoop::GetMediaStreamManager(); |
582 channel_->AddFilter(new AudioInputRendererHost(audio_manager, | 588 channel_->AddFilter(new AudioInputRendererHost(audio_manager, |
583 media_stream_manager)); | 589 media_stream_manager)); |
584 channel_->AddFilter(new AudioRendererHost( | 590 channel_->AddFilter(new AudioRendererHost( |
585 GetID(), audio_manager, BrowserMainLoop::GetAudioMirroringManager(), | 591 GetID(), audio_manager, BrowserMainLoop::GetAudioMirroringManager(), |
586 media_internals)); | 592 media_internals)); |
| 593 |
587 channel_->AddFilter(new VideoCaptureHost()); | 594 channel_->AddFilter(new VideoCaptureHost()); |
| 595 |
588 channel_->AddFilter(new AppCacheDispatcherHost( | 596 channel_->AddFilter(new AppCacheDispatcherHost( |
589 storage_partition_impl_->GetAppCacheService(), | 597 storage_partition_impl_->GetAppCacheService(), |
590 GetID())); | 598 GetID())); |
| 599 |
591 channel_->AddFilter(new ClipboardMessageFilter(browser_context)); | 600 channel_->AddFilter(new ClipboardMessageFilter(browser_context)); |
| 601 |
592 channel_->AddFilter( | 602 channel_->AddFilter( |
593 new DOMStorageMessageFilter( | 603 new DOMStorageMessageFilter( |
594 GetID(), | 604 GetID(), |
595 storage_partition_impl_->GetDOMStorageContext())); | 605 storage_partition_impl_->GetDOMStorageContext())); |
| 606 |
596 channel_->AddFilter( | 607 channel_->AddFilter( |
597 new IndexedDBDispatcherHost( | 608 new IndexedDBDispatcherHost( |
598 GetID(), | 609 GetID(), |
599 storage_partition_impl_->GetIndexedDBContext())); | 610 storage_partition_impl_->GetIndexedDBContext())); |
| 611 |
600 if (IsGuest()) { | 612 if (IsGuest()) { |
601 if (!g_browser_plugin_geolocation_context.Get()) { | 613 if (!g_browser_plugin_geolocation_context.Get()) { |
602 g_browser_plugin_geolocation_context.Get() = | 614 g_browser_plugin_geolocation_context.Get() = |
603 new BrowserPluginGeolocationPermissionContext(); | 615 new BrowserPluginGeolocationPermissionContext(); |
604 } | 616 } |
605 channel_->AddFilter(GeolocationDispatcherHost::New( | 617 channel_->AddFilter(GeolocationDispatcherHost::New( |
606 GetID(), g_browser_plugin_geolocation_context.Get())); | 618 GetID(), g_browser_plugin_geolocation_context.Get())); |
607 } else { | 619 } else { |
608 channel_->AddFilter(GeolocationDispatcherHost::New( | 620 channel_->AddFilter(GeolocationDispatcherHost::New( |
609 GetID(), browser_context->GetGeolocationPermissionContext())); | 621 GetID(), browser_context->GetGeolocationPermissionContext())); |
610 } | 622 } |
| 623 |
611 gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); | 624 gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); |
612 channel_->AddFilter(gpu_message_filter_); | 625 channel_->AddFilter(gpu_message_filter_); |
| 626 |
613 #if defined(ENABLE_WEBRTC) | 627 #if defined(ENABLE_WEBRTC) |
614 peer_connection_tracker_host_ = new PeerConnectionTrackerHost(GetID()); | 628 peer_connection_tracker_host_ = new PeerConnectionTrackerHost(GetID()); |
615 channel_->AddFilter(peer_connection_tracker_host_); | 629 channel_->AddFilter(peer_connection_tracker_host_); |
| 630 |
616 channel_->AddFilter(new MediaStreamDispatcherHost(GetID())); | 631 channel_->AddFilter(new MediaStreamDispatcherHost(GetID())); |
617 #endif | 632 #endif |
618 #if defined(ENABLE_PLUGINS) | 633 #if defined(ENABLE_PLUGINS) |
619 channel_->AddFilter(new PepperMessageFilter(GetID(), browser_context)); | 634 channel_->AddFilter(new PepperMessageFilter(GetID(), browser_context)); |
620 #endif | 635 #endif |
621 #if defined(ENABLE_INPUT_SPEECH) | 636 #if defined(ENABLE_INPUT_SPEECH) |
622 channel_->AddFilter(new InputTagSpeechDispatcherHost( | 637 channel_->AddFilter(new InputTagSpeechDispatcherHost( |
623 IsGuest(), GetID(), storage_partition_impl_->GetURLRequestContext(), | 638 IsGuest(), GetID(), storage_partition_impl_->GetURLRequestContext(), |
624 browser_context->GetSpeechRecognitionPreferences())); | 639 browser_context->GetSpeechRecognitionPreferences())); |
625 channel_->AddFilter(new SpeechRecognitionDispatcherHost( | 640 channel_->AddFilter(new SpeechRecognitionDispatcherHost( |
626 GetID(), storage_partition_impl_->GetURLRequestContext(), | 641 GetID(), storage_partition_impl_->GetURLRequestContext(), |
627 browser_context->GetSpeechRecognitionPreferences())); | 642 browser_context->GetSpeechRecognitionPreferences())); |
628 #endif | 643 #endif |
| 644 |
629 channel_->AddFilter(new FileAPIMessageFilter( | 645 channel_->AddFilter(new FileAPIMessageFilter( |
630 GetID(), | 646 GetID(), |
631 storage_partition_impl_->GetURLRequestContext(), | 647 storage_partition_impl_->GetURLRequestContext(), |
632 storage_partition_impl_->GetFileSystemContext(), | 648 storage_partition_impl_->GetFileSystemContext(), |
633 ChromeBlobStorageContext::GetFor(browser_context))); | 649 ChromeBlobStorageContext::GetFor(browser_context))); |
| 650 |
634 channel_->AddFilter(new OrientationMessageFilter()); | 651 channel_->AddFilter(new OrientationMessageFilter()); |
| 652 |
635 channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); | 653 channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); |
| 654 |
636 channel_->AddFilter(new MimeRegistryMessageFilter()); | 655 channel_->AddFilter(new MimeRegistryMessageFilter()); |
| 656 |
637 channel_->AddFilter(new DatabaseMessageFilter( | 657 channel_->AddFilter(new DatabaseMessageFilter( |
638 storage_partition_impl_->GetDatabaseTracker())); | 658 storage_partition_impl_->GetDatabaseTracker())); |
| 659 |
639 #if defined(OS_MACOSX) | 660 #if defined(OS_MACOSX) |
640 channel_->AddFilter(new TextInputClientMessageFilter(GetID())); | 661 channel_->AddFilter(new TextInputClientMessageFilter(GetID())); |
641 #elif defined(OS_WIN) | 662 #elif defined(OS_WIN) |
642 channel_->AddFilter(new FontCacheDispatcher()); | 663 channel_->AddFilter(new FontCacheDispatcher()); |
643 #endif | 664 #endif |
644 | 665 |
645 SocketStreamDispatcherHost* socket_stream_dispatcher_host = | 666 SocketStreamDispatcherHost* socket_stream_dispatcher_host = |
646 new SocketStreamDispatcherHost(GetID(), | 667 new SocketStreamDispatcherHost(GetID(), |
647 new RendererURLRequestContextSelector(browser_context, GetID()), | 668 new RendererURLRequestContextSelector(browser_context, GetID()), |
648 resource_context); | 669 resource_context); |
(...skipping 12 matching lines...) Expand all Loading... |
661 storage_partition_impl_->GetDatabaseTracker(), | 682 storage_partition_impl_->GetDatabaseTracker(), |
662 storage_partition_impl_->GetIndexedDBContext()), | 683 storage_partition_impl_->GetIndexedDBContext()), |
663 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | 684 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
664 base::Unretained(widget_helper_.get())))); | 685 base::Unretained(widget_helper_.get())))); |
665 | 686 |
666 #if defined(ENABLE_WEBRTC) | 687 #if defined(ENABLE_WEBRTC) |
667 channel_->AddFilter(new P2PSocketDispatcherHost(resource_context)); | 688 channel_->AddFilter(new P2PSocketDispatcherHost(resource_context)); |
668 #endif | 689 #endif |
669 | 690 |
670 channel_->AddFilter(new TraceMessageFilter()); | 691 channel_->AddFilter(new TraceMessageFilter()); |
| 692 |
| 693 // ResolveProxyMsgHelper |
671 channel_->AddFilter(new ResolveProxyMsgHelper( | 694 channel_->AddFilter(new ResolveProxyMsgHelper( |
672 browser_context->GetRequestContextForRenderProcess(GetID()))); | 695 browser_context->GetRequestContextForRenderProcess(GetID()))); |
| 696 |
673 channel_->AddFilter(new QuotaDispatcherHost( | 697 channel_->AddFilter(new QuotaDispatcherHost( |
674 GetID(), | 698 GetID(), |
675 storage_partition_impl_->GetQuotaManager(), | 699 storage_partition_impl_->GetQuotaManager(), |
676 GetContentClient()->browser()->CreateQuotaPermissionContext())); | 700 GetContentClient()->browser()->CreateQuotaPermissionContext())); |
| 701 |
677 channel_->AddFilter(new GamepadBrowserMessageFilter()); | 702 channel_->AddFilter(new GamepadBrowserMessageFilter()); |
| 703 |
678 channel_->AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 704 channel_->AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
| 705 |
679 channel_->AddFilter(new HistogramMessageFilter()); | 706 channel_->AddFilter(new HistogramMessageFilter()); |
| 707 |
680 channel_->AddFilter(new HyphenatorMessageFilter(this)); | 708 channel_->AddFilter(new HyphenatorMessageFilter(this)); |
| 709 |
681 #if defined(ENABLE_WEBRTC) | 710 #if defined(ENABLE_WEBRTC) |
682 channel_->AddFilter(new WebRtcLoggingHandlerHost()); | 711 channel_->AddFilter(new WebRtcLoggingHandlerHost()); |
683 #endif | 712 #endif |
| 713 |
| 714 channel_->AddFilter(new UrlHandlingMessageFilter(this)); |
684 } | 715 } |
685 | 716 |
686 int RenderProcessHostImpl::GetNextRoutingID() { | 717 int RenderProcessHostImpl::GetNextRoutingID() { |
687 return widget_helper_->GetNextRoutingID(); | 718 return widget_helper_->GetNextRoutingID(); |
688 } | 719 } |
689 | 720 |
690 void RenderProcessHostImpl::SimulateSwapOutACK( | 721 void RenderProcessHostImpl::SimulateSwapOutACK( |
691 const ViewMsg_SwapOut_Params& params) { | 722 const ViewMsg_SwapOut_Params& params) { |
692 widget_helper_->SimulateSwapOutACK(params); | 723 widget_helper_->SimulateSwapOutACK(params); |
693 } | 724 } |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 TRACE_EVENT0("renderer_host", | 1758 TRACE_EVENT0("renderer_host", |
1728 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1759 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
1729 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 1760 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
1730 ack_params.sync_point = 0; | 1761 ack_params.sync_point = 0; |
1731 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 1762 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
1732 gpu_process_host_id, | 1763 gpu_process_host_id, |
1733 ack_params); | 1764 ack_params); |
1734 } | 1765 } |
1735 | 1766 |
1736 } // namespace content | 1767 } // namespace content |
OLD | NEW |