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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 gpu_observer_registered_ = true; | 524 gpu_observer_registered_ = true; |
525 GpuDataManagerImpl::GetInstance()->AddObserver(this); | 525 GpuDataManagerImpl::GetInstance()->AddObserver(this); |
526 } | 526 } |
527 | 527 |
528 is_initialized_ = true; | 528 is_initialized_ = true; |
529 return true; | 529 return true; |
530 } | 530 } |
531 | 531 |
532 void RenderProcessHostImpl::CreateMessageFilters() { | 532 void RenderProcessHostImpl::CreateMessageFilters() { |
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
534 channel_->AddFilter(new ResourceSchedulerFilter(GetID())); | 534 AddFilter(new ResourceSchedulerFilter(GetID())); |
535 MediaInternals* media_internals = MediaInternals::GetInstance();; | 535 MediaInternals* media_internals = MediaInternals::GetInstance();; |
536 media::AudioManager* audio_manager = | 536 media::AudioManager* audio_manager = |
537 BrowserMainLoop::GetInstance()->audio_manager(); | 537 BrowserMainLoop::GetInstance()->audio_manager(); |
538 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages | 538 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages |
539 // from guests. | 539 // from guests. |
540 if (supports_browser_plugin_) { | 540 if (supports_browser_plugin_) { |
541 scoped_refptr<BrowserPluginMessageFilter> bp_message_filter( | 541 scoped_refptr<BrowserPluginMessageFilter> bp_message_filter( |
542 new BrowserPluginMessageFilter(GetID(), IsGuest())); | 542 new BrowserPluginMessageFilter(GetID(), IsGuest())); |
543 channel_->AddFilter(bp_message_filter.get()); | 543 AddFilter(bp_message_filter.get()); |
544 } | 544 } |
545 | 545 |
546 scoped_refptr<RenderMessageFilter> render_message_filter( | 546 scoped_refptr<RenderMessageFilter> render_message_filter( |
547 new RenderMessageFilter( | 547 new RenderMessageFilter( |
548 GetID(), | 548 GetID(), |
549 IsGuest(), | 549 IsGuest(), |
550 #if defined(ENABLE_PLUGINS) | 550 #if defined(ENABLE_PLUGINS) |
551 PluginServiceImpl::GetInstance(), | 551 PluginServiceImpl::GetInstance(), |
552 #else | 552 #else |
553 NULL, | 553 NULL, |
554 #endif | 554 #endif |
555 GetBrowserContext(), | 555 GetBrowserContext(), |
556 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), | 556 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), |
557 widget_helper_.get(), | 557 widget_helper_.get(), |
558 audio_manager, | 558 audio_manager, |
559 media_internals, | 559 media_internals, |
560 storage_partition_impl_->GetDOMStorageContext())); | 560 storage_partition_impl_->GetDOMStorageContext())); |
561 channel_->AddFilter(render_message_filter.get()); | 561 AddFilter(render_message_filter.get()); |
562 BrowserContext* browser_context = GetBrowserContext(); | 562 BrowserContext* browser_context = GetBrowserContext(); |
563 ResourceContext* resource_context = browser_context->GetResourceContext(); | 563 ResourceContext* resource_context = browser_context->GetResourceContext(); |
564 | 564 |
565 scoped_refptr<net::URLRequestContextGetter> request_context( | 565 scoped_refptr<net::URLRequestContextGetter> request_context( |
566 browser_context->GetRequestContextForRenderProcess(GetID())); | 566 browser_context->GetRequestContextForRenderProcess(GetID())); |
567 scoped_refptr<net::URLRequestContextGetter> media_request_context( | 567 scoped_refptr<net::URLRequestContextGetter> media_request_context( |
568 browser_context->GetMediaRequestContextForRenderProcess(GetID())); | 568 browser_context->GetMediaRequestContextForRenderProcess(GetID())); |
569 | 569 |
570 ResourceMessageFilter::GetContextsCallback get_contexts_callback( | 570 ResourceMessageFilter::GetContextsCallback get_contexts_callback( |
571 base::Bind(&GetContexts, browser_context->GetResourceContext(), | 571 base::Bind(&GetContexts, browser_context->GetResourceContext(), |
572 request_context, media_request_context)); | 572 request_context, media_request_context)); |
573 | 573 |
574 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 574 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
575 GetID(), PROCESS_TYPE_RENDERER, | 575 GetID(), PROCESS_TYPE_RENDERER, |
576 storage_partition_impl_->GetAppCacheService(), | 576 storage_partition_impl_->GetAppCacheService(), |
577 ChromeBlobStorageContext::GetFor(browser_context), | 577 ChromeBlobStorageContext::GetFor(browser_context), |
578 storage_partition_impl_->GetFileSystemContext(), | 578 storage_partition_impl_->GetFileSystemContext(), |
579 get_contexts_callback); | 579 get_contexts_callback); |
580 | 580 |
581 channel_->AddFilter(resource_message_filter); | 581 AddFilter(resource_message_filter); |
582 MediaStreamManager* media_stream_manager = | 582 MediaStreamManager* media_stream_manager = |
583 BrowserMainLoop::GetInstance()->media_stream_manager(); | 583 BrowserMainLoop::GetInstance()->media_stream_manager(); |
584 channel_->AddFilter(new AudioInputRendererHost( | 584 AddFilter(new AudioInputRendererHost( |
585 audio_manager, | 585 audio_manager, |
586 media_stream_manager, | 586 media_stream_manager, |
587 BrowserMainLoop::GetInstance()->audio_mirroring_manager(), | 587 BrowserMainLoop::GetInstance()->audio_mirroring_manager(), |
588 BrowserMainLoop::GetInstance()->user_input_monitor())); | 588 BrowserMainLoop::GetInstance()->user_input_monitor())); |
589 channel_->AddFilter(new AudioRendererHost( | 589 AddFilter(new AudioRendererHost( |
590 GetID(), | 590 GetID(), |
591 audio_manager, | 591 audio_manager, |
592 BrowserMainLoop::GetInstance()->audio_mirroring_manager(), | 592 BrowserMainLoop::GetInstance()->audio_mirroring_manager(), |
593 media_internals, | 593 media_internals, |
594 media_stream_manager)); | 594 media_stream_manager)); |
595 channel_->AddFilter( | 595 AddFilter( |
596 new MIDIHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); | 596 new MIDIHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager())); |
597 channel_->AddFilter(new MIDIDispatcherHost(GetID(), browser_context)); | 597 AddFilter(new MIDIDispatcherHost(GetID(), browser_context)); |
598 channel_->AddFilter(new VideoCaptureHost(media_stream_manager)); | 598 AddFilter(new VideoCaptureHost(media_stream_manager)); |
599 channel_->AddFilter(new AppCacheDispatcherHost( | 599 AddFilter(new AppCacheDispatcherHost( |
600 storage_partition_impl_->GetAppCacheService(), | 600 storage_partition_impl_->GetAppCacheService(), |
601 GetID())); | 601 GetID())); |
602 channel_->AddFilter(new ClipboardMessageFilter); | 602 AddFilter(new ClipboardMessageFilter); |
603 channel_->AddFilter(new DOMStorageMessageFilter( | 603 AddFilter(new DOMStorageMessageFilter( |
604 GetID(), | 604 GetID(), |
605 storage_partition_impl_->GetDOMStorageContext())); | 605 storage_partition_impl_->GetDOMStorageContext())); |
606 channel_->AddFilter(new IndexedDBDispatcherHost( | 606 AddFilter(new IndexedDBDispatcherHost( |
607 GetID(), | 607 GetID(), |
608 storage_partition_impl_->GetIndexedDBContext())); | 608 storage_partition_impl_->GetIndexedDBContext())); |
609 channel_->AddFilter(new ServiceWorkerDispatcherHost( | 609 AddFilter(new ServiceWorkerDispatcherHost( |
610 storage_partition_impl_->GetServiceWorkerContext())); | 610 storage_partition_impl_->GetServiceWorkerContext())); |
611 if (IsGuest()) { | 611 if (IsGuest()) { |
612 if (!g_browser_plugin_geolocation_context.Get().get()) { | 612 if (!g_browser_plugin_geolocation_context.Get().get()) { |
613 g_browser_plugin_geolocation_context.Get() = | 613 g_browser_plugin_geolocation_context.Get() = |
614 new BrowserPluginGeolocationPermissionContext(); | 614 new BrowserPluginGeolocationPermissionContext(); |
615 } | 615 } |
616 channel_->AddFilter(GeolocationDispatcherHost::New( | 616 AddFilter(GeolocationDispatcherHost::New( |
617 GetID(), g_browser_plugin_geolocation_context.Get().get())); | 617 GetID(), g_browser_plugin_geolocation_context.Get().get())); |
618 } else { | 618 } else { |
619 channel_->AddFilter(GeolocationDispatcherHost::New( | 619 AddFilter(GeolocationDispatcherHost::New( |
620 GetID(), browser_context->GetGeolocationPermissionContext())); | 620 GetID(), browser_context->GetGeolocationPermissionContext())); |
621 } | 621 } |
622 gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); | 622 gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); |
623 channel_->AddFilter(gpu_message_filter_); | 623 AddFilter(gpu_message_filter_); |
624 #if defined(ENABLE_WEBRTC) | 624 #if defined(ENABLE_WEBRTC) |
625 channel_->AddFilter(new WebRTCIdentityServiceHost( | 625 AddFilter(new WebRTCIdentityServiceHost( |
626 GetID(), storage_partition_impl_->GetWebRTCIdentityStore())); | 626 GetID(), storage_partition_impl_->GetWebRTCIdentityStore())); |
627 peer_connection_tracker_host_ = new PeerConnectionTrackerHost(GetID()); | 627 peer_connection_tracker_host_ = new PeerConnectionTrackerHost(GetID()); |
628 channel_->AddFilter(peer_connection_tracker_host_.get()); | 628 AddFilter(peer_connection_tracker_host_.get()); |
629 channel_->AddFilter(new MediaStreamDispatcherHost( | 629 AddFilter(new MediaStreamDispatcherHost( |
630 GetID(), media_stream_manager)); | 630 GetID(), media_stream_manager)); |
631 channel_->AddFilter( | 631 AddFilter( |
632 new DeviceRequestMessageFilter(resource_context, media_stream_manager)); | 632 new DeviceRequestMessageFilter(resource_context, media_stream_manager)); |
633 #endif | 633 #endif |
634 #if defined(ENABLE_PLUGINS) | 634 #if defined(ENABLE_PLUGINS) |
635 channel_->AddFilter(new PepperRendererConnection(GetID())); | 635 AddFilter(new PepperRendererConnection(GetID())); |
636 #endif | 636 #endif |
637 #if defined(ENABLE_INPUT_SPEECH) | 637 #if defined(ENABLE_INPUT_SPEECH) |
638 channel_->AddFilter(new InputTagSpeechDispatcherHost( | 638 AddFilter(new InputTagSpeechDispatcherHost( |
639 IsGuest(), GetID(), storage_partition_impl_->GetURLRequestContext())); | 639 IsGuest(), GetID(), storage_partition_impl_->GetURLRequestContext())); |
640 #endif | 640 #endif |
641 channel_->AddFilter(new SpeechRecognitionDispatcherHost( | 641 AddFilter(new SpeechRecognitionDispatcherHost( |
642 GetID(), storage_partition_impl_->GetURLRequestContext())); | 642 GetID(), storage_partition_impl_->GetURLRequestContext())); |
643 channel_->AddFilter(new FileAPIMessageFilter( | 643 AddFilter(new FileAPIMessageFilter( |
644 GetID(), | 644 GetID(), |
645 storage_partition_impl_->GetURLRequestContext(), | 645 storage_partition_impl_->GetURLRequestContext(), |
646 storage_partition_impl_->GetFileSystemContext(), | 646 storage_partition_impl_->GetFileSystemContext(), |
647 ChromeBlobStorageContext::GetFor(browser_context), | 647 ChromeBlobStorageContext::GetFor(browser_context), |
648 StreamContext::GetFor(browser_context))); | 648 StreamContext::GetFor(browser_context))); |
649 channel_->AddFilter(new OrientationMessageFilter()); | 649 AddFilter(new OrientationMessageFilter()); |
650 channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); | 650 AddFilter(new FileUtilitiesMessageFilter(GetID())); |
651 channel_->AddFilter(new MimeRegistryMessageFilter()); | 651 AddFilter(new MimeRegistryMessageFilter()); |
652 channel_->AddFilter(new DatabaseMessageFilter( | 652 AddFilter(new DatabaseMessageFilter( |
653 storage_partition_impl_->GetDatabaseTracker())); | 653 storage_partition_impl_->GetDatabaseTracker())); |
654 #if defined(OS_MACOSX) | 654 #if defined(OS_MACOSX) |
655 channel_->AddFilter(new TextInputClientMessageFilter(GetID())); | 655 AddFilter(new TextInputClientMessageFilter(GetID())); |
656 #elif defined(OS_WIN) | 656 #elif defined(OS_WIN) |
657 channel_->AddFilter(new FontCacheDispatcher()); | 657 channel_->AddFilter(new FontCacheDispatcher()); |
658 #elif defined(OS_ANDROID) | 658 #elif defined(OS_ANDROID) |
659 browser_demuxer_android_ = new BrowserDemuxerAndroid(); | 659 browser_demuxer_android_ = new BrowserDemuxerAndroid(); |
660 channel_->AddFilter(browser_demuxer_android_); | 660 AddFilter(browser_demuxer_android_); |
661 #endif | 661 #endif |
662 | 662 |
663 SocketStreamDispatcherHost::GetRequestContextCallback | 663 SocketStreamDispatcherHost::GetRequestContextCallback |
664 request_context_callback( | 664 request_context_callback( |
665 base::Bind(&GetRequestContext, request_context, | 665 base::Bind(&GetRequestContext, request_context, |
666 media_request_context)); | 666 media_request_context)); |
667 | 667 |
668 SocketStreamDispatcherHost* socket_stream_dispatcher_host = | 668 SocketStreamDispatcherHost* socket_stream_dispatcher_host = |
669 new SocketStreamDispatcherHost( | 669 new SocketStreamDispatcherHost( |
670 GetID(), request_context_callback, resource_context); | 670 GetID(), request_context_callback, resource_context); |
671 channel_->AddFilter(socket_stream_dispatcher_host); | 671 AddFilter(socket_stream_dispatcher_host); |
672 | 672 |
673 channel_->AddFilter(new WorkerMessageFilter( | 673 AddFilter(new WorkerMessageFilter( |
674 GetID(), | 674 GetID(), |
675 resource_context, | 675 resource_context, |
676 WorkerStoragePartition( | 676 WorkerStoragePartition( |
677 storage_partition_impl_->GetURLRequestContext(), | 677 storage_partition_impl_->GetURLRequestContext(), |
678 storage_partition_impl_->GetMediaURLRequestContext(), | 678 storage_partition_impl_->GetMediaURLRequestContext(), |
679 storage_partition_impl_->GetAppCacheService(), | 679 storage_partition_impl_->GetAppCacheService(), |
680 storage_partition_impl_->GetQuotaManager(), | 680 storage_partition_impl_->GetQuotaManager(), |
681 storage_partition_impl_->GetFileSystemContext(), | 681 storage_partition_impl_->GetFileSystemContext(), |
682 storage_partition_impl_->GetDatabaseTracker(), | 682 storage_partition_impl_->GetDatabaseTracker(), |
683 storage_partition_impl_->GetIndexedDBContext()), | 683 storage_partition_impl_->GetIndexedDBContext()), |
684 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | 684 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
685 base::Unretained(widget_helper_.get())))); | 685 base::Unretained(widget_helper_.get())))); |
686 | 686 |
687 #if defined(ENABLE_WEBRTC) | 687 #if defined(ENABLE_WEBRTC) |
688 channel_->AddFilter(new P2PSocketDispatcherHost( | 688 AddFilter(new P2PSocketDispatcherHost( |
689 resource_context, | 689 resource_context, |
690 browser_context->GetRequestContextForRenderProcess(GetID()))); | 690 browser_context->GetRequestContextForRenderProcess(GetID()))); |
691 #endif | 691 #endif |
692 | 692 |
693 channel_->AddFilter(new TraceMessageFilter()); | 693 AddFilter(new TraceMessageFilter()); |
694 channel_->AddFilter(new ResolveProxyMsgHelper( | 694 AddFilter(new ResolveProxyMsgHelper( |
695 browser_context->GetRequestContextForRenderProcess(GetID()))); | 695 browser_context->GetRequestContextForRenderProcess(GetID()))); |
696 channel_->AddFilter(new QuotaDispatcherHost( | 696 AddFilter(new QuotaDispatcherHost( |
697 GetID(), | 697 GetID(), |
698 storage_partition_impl_->GetQuotaManager(), | 698 storage_partition_impl_->GetQuotaManager(), |
699 GetContentClient()->browser()->CreateQuotaPermissionContext())); | 699 GetContentClient()->browser()->CreateQuotaPermissionContext())); |
700 channel_->AddFilter(new GamepadBrowserMessageFilter()); | 700 AddFilter(new GamepadBrowserMessageFilter()); |
701 channel_->AddFilter(new DeviceMotionMessageFilter()); | 701 AddFilter(new DeviceMotionMessageFilter()); |
702 channel_->AddFilter(new DeviceOrientationMessageFilter()); | 702 AddFilter(new DeviceOrientationMessageFilter()); |
703 channel_->AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 703 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
704 channel_->AddFilter(new HistogramMessageFilter()); | 704 AddFilter(new HistogramMessageFilter()); |
705 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 705 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
706 if (CommandLine::ForCurrentProcess()->HasSwitch( | 706 if (CommandLine::ForCurrentProcess()->HasSwitch( |
707 switches::kEnableMemoryBenchmarking)) | 707 switches::kEnableMemoryBenchmarking)) |
708 channel_->AddFilter(new MemoryBenchmarkMessageFilter()); | 708 AddFilter(new MemoryBenchmarkMessageFilter()); |
709 #endif | 709 #endif |
710 #if defined(OS_ANDROID) | 710 #if defined(OS_ANDROID) |
711 channel_->AddFilter(new VibrationMessageFilter()); | 711 AddFilter(new VibrationMessageFilter()); |
712 #endif | 712 #endif |
713 } | 713 } |
714 | 714 |
715 int RenderProcessHostImpl::GetNextRoutingID() { | 715 int RenderProcessHostImpl::GetNextRoutingID() { |
716 return widget_helper_->GetNextRoutingID(); | 716 return widget_helper_->GetNextRoutingID(); |
717 } | 717 } |
718 | 718 |
719 | 719 |
720 void RenderProcessHostImpl::ResumeDeferredNavigation( | 720 void RenderProcessHostImpl::ResumeDeferredNavigation( |
721 const GlobalRequestID& request_id) { | 721 const GlobalRequestID& request_id) { |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 } | 1379 } |
1380 | 1380 |
1381 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) { | 1381 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) { |
1382 widget_helper_->ResumeRequestsForView(route_id); | 1382 widget_helper_->ResumeRequestsForView(route_id); |
1383 } | 1383 } |
1384 | 1384 |
1385 IPC::ChannelProxy* RenderProcessHostImpl::GetChannel() { | 1385 IPC::ChannelProxy* RenderProcessHostImpl::GetChannel() { |
1386 return channel_.get(); | 1386 return channel_.get(); |
1387 } | 1387 } |
1388 | 1388 |
| 1389 void RenderProcessHostImpl::AddFilter(BrowserMessageFilter* filter) { |
| 1390 channel_->AddFilter(filter->GetFilter()); |
| 1391 } |
| 1392 |
1389 bool RenderProcessHostImpl::FastShutdownForPageCount(size_t count) { | 1393 bool RenderProcessHostImpl::FastShutdownForPageCount(size_t count) { |
1390 if (static_cast<size_t>(GetActiveViewCount()) == count) | 1394 if (static_cast<size_t>(GetActiveViewCount()) == count) |
1391 return FastShutdownIfPossible(); | 1395 return FastShutdownIfPossible(); |
1392 return false; | 1396 return false; |
1393 } | 1397 } |
1394 | 1398 |
1395 bool RenderProcessHostImpl::FastShutdownStarted() const { | 1399 bool RenderProcessHostImpl::FastShutdownStarted() const { |
1396 return fast_shutdown_started_; | 1400 return fast_shutdown_started_; |
1397 } | 1401 } |
1398 | 1402 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 // Skip widgets in other processes. | 1803 // Skip widgets in other processes. |
1800 if (widget->GetProcess()->GetID() != GetID()) | 1804 if (widget->GetProcess()->GetID() != GetID()) |
1801 continue; | 1805 continue; |
1802 | 1806 |
1803 RenderViewHost* rvh = RenderViewHost::From(widget); | 1807 RenderViewHost* rvh = RenderViewHost::From(widget); |
1804 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); | 1808 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); |
1805 } | 1809 } |
1806 } | 1810 } |
1807 | 1811 |
1808 } // namespace content | 1812 } // namespace content |
OLD | NEW |