| 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 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 74 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
| 75 #include "content/browser/renderer_host/quota_dispatcher_host.h" | 75 #include "content/browser/renderer_host/quota_dispatcher_host.h" |
| 76 #include "content/browser/renderer_host/render_message_filter.h" | 76 #include "content/browser/renderer_host/render_message_filter.h" |
| 77 #include "content/browser/renderer_host/render_view_host_delegate.h" | 77 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 78 #include "content/browser/renderer_host/render_view_host_impl.h" | 78 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 79 #include "content/browser/renderer_host/render_widget_helper.h" | 79 #include "content/browser/renderer_host/render_widget_helper.h" |
| 80 #include "content/browser/renderer_host/resource_message_filter.h" | 80 #include "content/browser/renderer_host/resource_message_filter.h" |
| 81 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" | 81 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" |
| 82 #include "content/browser/renderer_host/text_input_client_message_filter.h" | 82 #include "content/browser/renderer_host/text_input_client_message_filter.h" |
| 83 #include "content/browser/resolve_proxy_msg_helper.h" | 83 #include "content/browser/resolve_proxy_msg_helper.h" |
| 84 #include "content/browser/storage_partition_impl.h" |
| 84 #include "content/browser/speech/input_tag_speech_dispatcher_host.h" | 85 #include "content/browser/speech/input_tag_speech_dispatcher_host.h" |
| 85 #include "content/browser/speech/speech_recognition_dispatcher_host.h" | 86 #include "content/browser/speech/speech_recognition_dispatcher_host.h" |
| 86 #include "content/browser/trace_message_filter.h" | 87 #include "content/browser/trace_message_filter.h" |
| 87 #include "content/browser/worker_host/worker_message_filter.h" | 88 #include "content/browser/worker_host/worker_message_filter.h" |
| 88 #include "content/common/child_process_host_impl.h" | 89 #include "content/common/child_process_host_impl.h" |
| 89 #include "content/common/child_process_messages.h" | 90 #include "content/common/child_process_messages.h" |
| 90 #include "content/common/gpu/gpu_messages.h" | 91 #include "content/common/gpu/gpu_messages.h" |
| 91 #include "content/common/resource_messages.h" | 92 #include "content/common/resource_messages.h" |
| 92 #include "content/common/view_messages.h" | 93 #include "content/common/view_messages.h" |
| 93 #include "content/public/browser/browser_context.h" | 94 #include "content/public/browser/browser_context.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 315 |
| 315 // static | 316 // static |
| 316 bool g_run_renderer_in_process_ = false; | 317 bool g_run_renderer_in_process_ = false; |
| 317 | 318 |
| 318 // static | 319 // static |
| 319 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { | 320 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { |
| 320 g_max_renderer_count_override = count; | 321 g_max_renderer_count_override = count; |
| 321 } | 322 } |
| 322 | 323 |
| 323 RenderProcessHostImpl::RenderProcessHostImpl( | 324 RenderProcessHostImpl::RenderProcessHostImpl( |
| 324 BrowserContext* browser_context, bool is_guest) | 325 BrowserContext* browser_context, |
| 326 StoragePartitionImpl* storage_partition_impl, |
| 327 bool is_guest) |
| 325 : fast_shutdown_started_(false), | 328 : fast_shutdown_started_(false), |
| 326 deleting_soon_(false), | 329 deleting_soon_(false), |
| 327 pending_views_(0), | 330 pending_views_(0), |
| 328 visible_widgets_(0), | 331 visible_widgets_(0), |
| 329 backgrounded_(true), | 332 backgrounded_(true), |
| 330 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( | 333 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( |
| 331 FROM_HERE, base::TimeDelta::FromSeconds(5), | 334 FROM_HERE, base::TimeDelta::FromSeconds(5), |
| 332 this, &RenderProcessHostImpl::ClearTransportDIBCache)), | 335 this, &RenderProcessHostImpl::ClearTransportDIBCache)), |
| 333 is_initialized_(false), | 336 is_initialized_(false), |
| 334 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 337 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
| 335 browser_context_(browser_context), | 338 browser_context_(browser_context), |
| 339 storage_partition_impl_(storage_partition_impl), |
| 336 sudden_termination_allowed_(true), | 340 sudden_termination_allowed_(true), |
| 337 ignore_input_events_(false), | 341 ignore_input_events_(false), |
| 338 is_guest_(is_guest) { | 342 is_guest_(is_guest) { |
| 339 widget_helper_ = new RenderWidgetHelper(); | 343 widget_helper_ = new RenderWidgetHelper(); |
| 340 | 344 |
| 341 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 345 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
| 342 | 346 |
| 343 // Grant most file permissions to this renderer. | 347 // Grant most file permissions to this renderer. |
| 344 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and | 348 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and |
| 345 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API | 349 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 void RenderProcessHostImpl::CreateMessageFilters() { | 509 void RenderProcessHostImpl::CreateMessageFilters() { |
| 506 MediaObserver* media_observer = | 510 MediaObserver* media_observer = |
| 507 GetContentClient()->browser()->GetMediaObserver(); | 511 GetContentClient()->browser()->GetMediaObserver(); |
| 508 scoped_refptr<RenderMessageFilter> render_message_filter( | 512 scoped_refptr<RenderMessageFilter> render_message_filter( |
| 509 new RenderMessageFilter( | 513 new RenderMessageFilter( |
| 510 GetID(), | 514 GetID(), |
| 511 PluginServiceImpl::GetInstance(), | 515 PluginServiceImpl::GetInstance(), |
| 512 GetBrowserContext(), | 516 GetBrowserContext(), |
| 513 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), | 517 GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), |
| 514 widget_helper_, | 518 widget_helper_, |
| 515 media_observer)); | 519 media_observer, |
| 520 storage_partition_impl_->GetDOMStorageContext())); |
| 516 channel_->AddFilter(render_message_filter); | 521 channel_->AddFilter(render_message_filter); |
| 517 BrowserContext* browser_context = GetBrowserContext(); | 522 BrowserContext* browser_context = GetBrowserContext(); |
| 518 ResourceContext* resource_context = browser_context->GetResourceContext(); | 523 ResourceContext* resource_context = browser_context->GetResourceContext(); |
| 519 | 524 |
| 520 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 525 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
| 521 GetID(), PROCESS_TYPE_RENDERER, resource_context, | 526 GetID(), PROCESS_TYPE_RENDERER, resource_context, |
| 522 new RendererURLRequestContextSelector(browser_context, GetID())); | 527 new RendererURLRequestContextSelector(browser_context, GetID())); |
| 523 | 528 |
| 524 channel_->AddFilter(resource_message_filter); | 529 channel_->AddFilter(resource_message_filter); |
| 525 media::AudioManager* audio_manager = BrowserMainLoop::GetAudioManager(); | 530 media::AudioManager* audio_manager = BrowserMainLoop::GetAudioManager(); |
| 526 media_stream::MediaStreamManager* media_stream_manager = | 531 media_stream::MediaStreamManager* media_stream_manager = |
| 527 BrowserMainLoop::GetMediaStreamManager(); | 532 BrowserMainLoop::GetMediaStreamManager(); |
| 528 channel_->AddFilter(new AudioInputRendererHost(audio_manager, | 533 channel_->AddFilter(new AudioInputRendererHost(audio_manager, |
| 529 media_stream_manager)); | 534 media_stream_manager)); |
| 530 channel_->AddFilter(new AudioRendererHost(audio_manager, media_observer)); | 535 channel_->AddFilter(new AudioRendererHost(audio_manager, media_observer)); |
| 531 channel_->AddFilter(new VideoCaptureHost()); | 536 channel_->AddFilter(new VideoCaptureHost()); |
| 532 channel_->AddFilter(new AppCacheDispatcherHost( | 537 channel_->AddFilter( |
| 533 static_cast<ChromeAppCacheService*>( | 538 new AppCacheDispatcherHost(storage_partition_impl_->GetAppCacheService(), |
| 534 BrowserContext::GetAppCacheService(browser_context)), | 539 GetID())); |
| 535 GetID())); | |
| 536 channel_->AddFilter(new ClipboardMessageFilter()); | 540 channel_->AddFilter(new ClipboardMessageFilter()); |
| 537 channel_->AddFilter(new DOMStorageMessageFilter(GetID(), | 541 channel_->AddFilter( |
| 538 static_cast<DOMStorageContextImpl*>( | 542 new DOMStorageMessageFilter( |
| 539 BrowserContext::GetDOMStorageContext(browser_context, GetID())))); | 543 GetID(), |
| 540 channel_->AddFilter(new IndexedDBDispatcherHost(GetID(), | 544 storage_partition_impl_->GetDOMStorageContext())); |
| 541 static_cast<IndexedDBContextImpl*>( | 545 channel_->AddFilter( |
| 542 BrowserContext::GetIndexedDBContext(browser_context)))); | 546 new IndexedDBDispatcherHost( |
| 547 GetID(), |
| 548 storage_partition_impl_->GetIndexedDBContext())); |
| 543 channel_->AddFilter(GeolocationDispatcherHost::New( | 549 channel_->AddFilter(GeolocationDispatcherHost::New( |
| 544 GetID(), browser_context->GetGeolocationPermissionContext())); | 550 GetID(), browser_context->GetGeolocationPermissionContext())); |
| 545 gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); | 551 gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); |
| 546 channel_->AddFilter(gpu_message_filter_); | 552 channel_->AddFilter(gpu_message_filter_); |
| 547 #if defined(ENABLE_WEBRTC) | 553 #if defined(ENABLE_WEBRTC) |
| 548 channel_->AddFilter(new media_stream::MediaStreamDispatcherHost(GetID())); | 554 channel_->AddFilter(new media_stream::MediaStreamDispatcherHost(GetID())); |
| 549 #endif | 555 #endif |
| 550 channel_->AddFilter( | 556 channel_->AddFilter( |
| 551 GetContentClient()->browser()->AllowPepperPrivateFileAPI() ? | 557 GetContentClient()->browser()->AllowPepperPrivateFileAPI() ? |
| 552 new PepperUnsafeFileMessageFilter(GetID(), browser_context->GetPath()) : | 558 new PepperUnsafeFileMessageFilter(GetID(), browser_context->GetPath()) : |
| 553 new PepperFileMessageFilter(GetID())); | 559 new PepperFileMessageFilter(GetID())); |
| 554 channel_->AddFilter(new PepperMessageFilter(PepperMessageFilter::RENDERER, | 560 channel_->AddFilter(new PepperMessageFilter(PepperMessageFilter::RENDERER, |
| 555 GetID(), browser_context)); | 561 GetID(), browser_context)); |
| 556 #if defined(ENABLE_INPUT_SPEECH) | 562 #if defined(ENABLE_INPUT_SPEECH) |
| 557 channel_->AddFilter(new speech::InputTagSpeechDispatcherHost( | 563 channel_->AddFilter(new speech::InputTagSpeechDispatcherHost( |
| 558 GetID(), browser_context->GetRequestContext(), | 564 GetID(), browser_context->GetRequestContext(), |
| 559 browser_context->GetSpeechRecognitionPreferences())); | 565 browser_context->GetSpeechRecognitionPreferences())); |
| 560 channel_->AddFilter(new speech::SpeechRecognitionDispatcherHost( | 566 channel_->AddFilter(new speech::SpeechRecognitionDispatcherHost( |
| 561 GetID(), browser_context->GetRequestContext(), | 567 GetID(), browser_context->GetRequestContext(), |
| 562 browser_context->GetSpeechRecognitionPreferences())); | 568 browser_context->GetSpeechRecognitionPreferences())); |
| 563 #endif | 569 #endif |
| 564 channel_->AddFilter(new FileAPIMessageFilter( | 570 channel_->AddFilter(new FileAPIMessageFilter( |
| 565 GetID(), | 571 GetID(), |
| 566 browser_context->GetRequestContext(), | 572 browser_context->GetRequestContext(), |
| 567 BrowserContext::GetFileSystemContext(browser_context), | 573 storage_partition_impl_->GetFileSystemContext(), |
| 568 ChromeBlobStorageContext::GetFor(browser_context))); | 574 ChromeBlobStorageContext::GetFor(browser_context))); |
| 569 channel_->AddFilter(new device_orientation::OrientationMessageFilter()); | 575 channel_->AddFilter(new device_orientation::OrientationMessageFilter()); |
| 570 channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); | 576 channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); |
| 571 channel_->AddFilter(new MimeRegistryMessageFilter()); | 577 channel_->AddFilter(new MimeRegistryMessageFilter()); |
| 572 channel_->AddFilter(new DatabaseMessageFilter( | 578 channel_->AddFilter(new DatabaseMessageFilter( |
| 573 BrowserContext::GetDatabaseTracker(browser_context))); | 579 storage_partition_impl_->GetDatabaseTracker())); |
| 574 #if defined(OS_MACOSX) | 580 #if defined(OS_MACOSX) |
| 575 channel_->AddFilter(new TextInputClientMessageFilter(GetID())); | 581 channel_->AddFilter(new TextInputClientMessageFilter(GetID())); |
| 576 #elif defined(OS_WIN) | 582 #elif defined(OS_WIN) |
| 577 channel_->AddFilter(new FontCacheDispatcher()); | 583 channel_->AddFilter(new FontCacheDispatcher()); |
| 578 #endif | 584 #endif |
| 579 | 585 |
| 580 SocketStreamDispatcherHost* socket_stream_dispatcher_host = | 586 SocketStreamDispatcherHost* socket_stream_dispatcher_host = |
| 581 new SocketStreamDispatcherHost(GetID(), | 587 new SocketStreamDispatcherHost(GetID(), |
| 582 new RendererURLRequestContextSelector(browser_context, GetID()), | 588 new RendererURLRequestContextSelector(browser_context, GetID()), |
| 583 resource_context); | 589 resource_context); |
| 584 channel_->AddFilter(socket_stream_dispatcher_host); | 590 channel_->AddFilter(socket_stream_dispatcher_host); |
| 585 | 591 |
| 586 channel_->AddFilter(new WorkerMessageFilter(GetID(), resource_context, | 592 channel_->AddFilter(new WorkerMessageFilter(GetID(), resource_context, |
| 587 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | 593 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
| 588 base::Unretained(widget_helper_.get())))); | 594 base::Unretained(widget_helper_.get())))); |
| 589 | 595 |
| 590 #if defined(ENABLE_WEBRTC) | 596 #if defined(ENABLE_WEBRTC) |
| 591 channel_->AddFilter(new P2PSocketDispatcherHost(resource_context)); | 597 channel_->AddFilter(new P2PSocketDispatcherHost(resource_context)); |
| 592 #endif | 598 #endif |
| 593 | 599 |
| 594 channel_->AddFilter(new TraceMessageFilter()); | 600 channel_->AddFilter(new TraceMessageFilter()); |
| 595 channel_->AddFilter(new ResolveProxyMsgHelper( | 601 channel_->AddFilter(new ResolveProxyMsgHelper( |
| 596 browser_context->GetRequestContextForRenderProcess(GetID()))); | 602 browser_context->GetRequestContextForRenderProcess(GetID()))); |
| 597 channel_->AddFilter(new QuotaDispatcherHost( | 603 channel_->AddFilter(new QuotaDispatcherHost( |
| 598 GetID(), | 604 GetID(), |
| 599 BrowserContext::GetQuotaManager(browser_context), | 605 storage_partition_impl_->GetQuotaManager(), |
| 600 GetContentClient()->browser()->CreateQuotaPermissionContext())); | 606 GetContentClient()->browser()->CreateQuotaPermissionContext())); |
| 601 channel_->AddFilter(new GamepadBrowserMessageFilter(this)); | 607 channel_->AddFilter(new GamepadBrowserMessageFilter(this)); |
| 602 channel_->AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 608 channel_->AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
| 603 channel_->AddFilter(new content::HistogramMessageFilter()); | 609 channel_->AddFilter(new content::HistogramMessageFilter()); |
| 604 } | 610 } |
| 605 | 611 |
| 606 int RenderProcessHostImpl::GetNextRoutingID() { | 612 int RenderProcessHostImpl::GetNextRoutingID() { |
| 607 return widget_helper_->GetNextRoutingID(); | 613 return widget_helper_->GetNextRoutingID(); |
| 608 } | 614 } |
| 609 | 615 |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 int32 route_id, | 1513 int32 route_id, |
| 1508 int32 gpu_process_host_id) { | 1514 int32 gpu_process_host_id) { |
| 1509 TRACE_EVENT0("renderer_host", | 1515 TRACE_EVENT0("renderer_host", |
| 1510 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1516 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
| 1511 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 1517 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
| 1512 gpu_process_host_id, | 1518 gpu_process_host_id, |
| 1513 0); | 1519 0); |
| 1514 } | 1520 } |
| 1515 | 1521 |
| 1516 } // namespace content | 1522 } // namespace content |
| OLD | NEW |