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