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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 bool is_guest) | 380 bool is_guest) |
381 : fast_shutdown_started_(false), | 381 : fast_shutdown_started_(false), |
382 deleting_soon_(false), | 382 deleting_soon_(false), |
383 pending_views_(0), | 383 pending_views_(0), |
384 visible_widgets_(0), | 384 visible_widgets_(0), |
385 backgrounded_(true), | 385 backgrounded_(true), |
386 cached_dibs_cleaner_( | 386 cached_dibs_cleaner_( |
387 FROM_HERE, base::TimeDelta::FromSeconds(5), | 387 FROM_HERE, base::TimeDelta::FromSeconds(5), |
388 this, &RenderProcessHostImpl::ClearTransportDIBCache), | 388 this, &RenderProcessHostImpl::ClearTransportDIBCache), |
389 is_initialized_(false), | 389 is_initialized_(false), |
390 child_process_launcher_factory_(base::Bind(&NewChildProcessLauncher)), | |
390 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 391 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
391 browser_context_(browser_context), | 392 browser_context_(browser_context), |
392 storage_partition_impl_(storage_partition_impl), | 393 storage_partition_impl_(storage_partition_impl), |
393 sudden_termination_allowed_(true), | 394 sudden_termination_allowed_(true), |
394 ignore_input_events_(false), | 395 ignore_input_events_(false), |
395 #if defined(OS_ANDROID) | 396 #if defined(OS_ANDROID) |
396 dummy_shutdown_event_(false, false), | 397 dummy_shutdown_event_(false, false), |
397 #endif | 398 #endif |
398 supports_browser_plugin_(supports_browser_plugin), | 399 supports_browser_plugin_(supports_browser_plugin), |
399 is_guest_(is_guest), | 400 is_guest_(is_guest), |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 // first so the process type argument will appear first. | 533 // first so the process type argument will appear first. |
533 CommandLine* cmd_line = new CommandLine(renderer_path); | 534 CommandLine* cmd_line = new CommandLine(renderer_path); |
534 if (!renderer_prefix.empty()) | 535 if (!renderer_prefix.empty()) |
535 cmd_line->PrependWrapper(renderer_prefix); | 536 cmd_line->PrependWrapper(renderer_prefix); |
536 AppendRendererCommandLine(cmd_line); | 537 AppendRendererCommandLine(cmd_line); |
537 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 538 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
538 | 539 |
539 // Spawn the child process asynchronously to avoid blocking the UI thread. | 540 // Spawn the child process asynchronously to avoid blocking the UI thread. |
540 // As long as there's no renderer prefix, we can use the zygote process | 541 // As long as there's no renderer prefix, we can use the zygote process |
541 // at this stage. | 542 // at this stage. |
542 child_process_launcher_.reset(new ChildProcessLauncher( | 543 child_process_launcher_ = child_process_launcher_factory_.Run( |
543 #if defined(OS_WIN) | 544 #if defined(OS_WIN) |
544 new RendererSandboxedProcessLauncherDelegate, | 545 new RendererSandboxedProcessLauncherDelegate, |
545 #elif defined(OS_POSIX) | 546 #elif defined(OS_POSIX) |
546 renderer_prefix.empty(), | 547 renderer_prefix.empty(), |
547 base::EnvironmentVector(), | 548 base::EnvironmentVector(), |
548 channel_->TakeClientFileDescriptor(), | 549 channel_->TakeClientFileDescriptor(), |
549 #endif | 550 #endif |
550 cmd_line, | 551 cmd_line, |
551 GetID(), | 552 GetID(), |
552 this)); | 553 this); |
553 | 554 |
554 fast_shutdown_started_ = false; | 555 fast_shutdown_started_ = false; |
555 } | 556 } |
556 | 557 |
557 if (!gpu_observer_registered_) { | 558 if (!gpu_observer_registered_) { |
558 gpu_observer_registered_ = true; | 559 gpu_observer_registered_ = true; |
559 GpuDataManagerImpl::GetInstance()->AddObserver(this); | 560 GpuDataManagerImpl::GetInstance()->AddObserver(this); |
560 } | 561 } |
561 | 562 |
562 is_initialized_ = true; | 563 is_initialized_ = true; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 GetID(), PROCESS_TYPE_RENDERER, resource_context, | 597 GetID(), PROCESS_TYPE_RENDERER, resource_context, |
597 storage_partition_impl_->GetAppCacheService(), | 598 storage_partition_impl_->GetAppCacheService(), |
598 ChromeBlobStorageContext::GetFor(browser_context), | 599 ChromeBlobStorageContext::GetFor(browser_context), |
599 storage_partition_impl_->GetFileSystemContext(), | 600 storage_partition_impl_->GetFileSystemContext(), |
600 new RendererURLRequestContextSelector(browser_context, GetID())); | 601 new RendererURLRequestContextSelector(browser_context, GetID())); |
601 | 602 |
602 channel_->AddFilter(resource_message_filter); | 603 channel_->AddFilter(resource_message_filter); |
603 media::AudioManager* audio_manager = BrowserMainLoop::GetAudioManager(); | 604 media::AudioManager* audio_manager = BrowserMainLoop::GetAudioManager(); |
604 MediaStreamManager* media_stream_manager = | 605 MediaStreamManager* media_stream_manager = |
605 BrowserMainLoop::GetMediaStreamManager(); | 606 BrowserMainLoop::GetMediaStreamManager(); |
606 channel_->AddFilter(new AudioInputRendererHost(audio_manager, | 607 channel_->AddFilter(new AudioInputRendererHost(audio_manager, |
Charlie Reis
2013/06/05 19:07:10
Does this also need to be behind the if?
Jeffrey Yasskin
2013/06/05 21:23:27
The test passes with it outside the if, likely bec
| |
607 media_stream_manager)); | 608 media_stream_manager)); |
608 channel_->AddFilter(new AudioRendererHost( | 609 if (audio_manager) { |
609 GetID(), audio_manager, BrowserMainLoop::GetAudioMirroringManager(), | 610 channel_->AddFilter(new AudioRendererHost( |
610 media_internals, media_stream_manager)); | 611 GetID(), audio_manager, BrowserMainLoop::GetAudioMirroringManager(), |
612 media_internals, media_stream_manager)); | |
613 } | |
611 channel_->AddFilter(new VideoCaptureHost()); | 614 channel_->AddFilter(new VideoCaptureHost()); |
612 channel_->AddFilter(new AppCacheDispatcherHost( | 615 channel_->AddFilter(new AppCacheDispatcherHost( |
613 storage_partition_impl_->GetAppCacheService(), | 616 storage_partition_impl_->GetAppCacheService(), |
614 GetID())); | 617 GetID())); |
615 channel_->AddFilter(new ClipboardMessageFilter); | 618 channel_->AddFilter(new ClipboardMessageFilter); |
616 channel_->AddFilter( | 619 channel_->AddFilter( |
617 new DOMStorageMessageFilter( | 620 new DOMStorageMessageFilter( |
618 GetID(), | 621 GetID(), |
619 storage_partition_impl_->GetDOMStorageContext())); | 622 storage_partition_impl_->GetDOMStorageContext())); |
620 channel_->AddFilter( | 623 channel_->AddFilter( |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1676 void RenderProcessHostImpl::EndFrameSubscription(int route_id) { | 1679 void RenderProcessHostImpl::EndFrameSubscription(int route_id) { |
1677 if (!gpu_message_filter_) | 1680 if (!gpu_message_filter_) |
1678 return; | 1681 return; |
1679 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 1682 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
1680 &GpuMessageFilter::EndFrameSubscription, | 1683 &GpuMessageFilter::EndFrameSubscription, |
1681 gpu_message_filter_, | 1684 gpu_message_filter_, |
1682 route_id)); | 1685 route_id)); |
1683 } | 1686 } |
1684 | 1687 |
1685 void RenderProcessHostImpl::OnShutdownRequest() { | 1688 void RenderProcessHostImpl::OnShutdownRequest() { |
1686 // Don't shut down if there are more active RenderViews than the one asking | 1689 // Don't shut down if there are more active RenderViews than the one asking |
Charlie Reis
2013/06/05 19:07:10
Please update this comment:
s/more active RenderVi
Jeffrey Yasskin
2013/06/05 21:23:27
Thanks, done.
| |
1687 // to close, or if there are pending RenderViews being swapped back in. | 1690 // to close, or if there are pending RenderViews being swapped back in. |
1688 // In single process mode, we never shutdown the renderer. | 1691 // In single process mode, we never shutdown the renderer. |
1689 int num_active_views = GetActiveViewCount(); | 1692 int num_active_views = GetActiveViewCount(); |
1690 if (pending_views_ || num_active_views > 1 || run_renderer_in_process()) | 1693 if (pending_views_ || num_active_views > 0 || run_renderer_in_process()) |
1691 return; | 1694 return; |
1692 | 1695 |
1693 // Notify any contents that might have swapped out renderers from this | 1696 // Notify any contents that might have swapped out renderers from this |
1694 // process. They should not attempt to swap them back in. | 1697 // process. They should not attempt to swap them back in. |
1695 NotificationService::current()->Notify( | 1698 NotificationService::current()->Notify( |
1696 NOTIFICATION_RENDERER_PROCESS_CLOSING, | 1699 NOTIFICATION_RENDERER_PROCESS_CLOSING, |
1697 Source<RenderProcessHost>(this), | 1700 Source<RenderProcessHost>(this), |
1698 NotificationService::NoDetails()); | 1701 NotificationService::NoDetails()); |
1699 | 1702 |
1700 Send(new ChildProcessMsg_Shutdown()); | 1703 Send(new ChildProcessMsg_Shutdown()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1795 continue; | 1798 continue; |
1796 | 1799 |
1797 RenderViewHost* rvh = | 1800 RenderViewHost* rvh = |
1798 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); | 1801 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
1799 | 1802 |
1800 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); | 1803 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); |
1801 } | 1804 } |
1802 } | 1805 } |
1803 | 1806 |
1804 } // namespace content | 1807 } // namespace content |
OLD | NEW |