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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 RenderProcessHostImpl::RenderProcessHostImpl( | 388 RenderProcessHostImpl::RenderProcessHostImpl( |
389 BrowserContext* browser_context, | 389 BrowserContext* browser_context, |
390 StoragePartitionImpl* storage_partition_impl, | 390 StoragePartitionImpl* storage_partition_impl, |
391 bool is_guest) | 391 bool is_guest) |
392 : fast_shutdown_started_(false), | 392 : fast_shutdown_started_(false), |
393 deleting_soon_(false), | 393 deleting_soon_(false), |
394 #ifndef NDEBUG | 394 #ifndef NDEBUG |
395 is_self_deleted_(false), | 395 is_self_deleted_(false), |
396 #endif | 396 #endif |
397 pending_views_(0), | 397 pending_views_(0), |
| 398 mojo_activation_required_(false), |
398 visible_widgets_(0), | 399 visible_widgets_(0), |
399 backgrounded_(true), | 400 backgrounded_(true), |
400 is_initialized_(false), | 401 is_initialized_(false), |
401 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 402 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
402 browser_context_(browser_context), | 403 browser_context_(browser_context), |
403 storage_partition_impl_(storage_partition_impl), | 404 storage_partition_impl_(storage_partition_impl), |
404 sudden_termination_allowed_(true), | 405 sudden_termination_allowed_(true), |
405 ignore_input_events_(false), | 406 ignore_input_events_(false), |
406 is_guest_(is_guest), | 407 is_guest_(is_guest), |
407 gpu_observer_registered_(false), | 408 gpu_observer_registered_(false), |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 598 |
598 if (!gpu_observer_registered_) { | 599 if (!gpu_observer_registered_) { |
599 gpu_observer_registered_ = true; | 600 gpu_observer_registered_ = true; |
600 GpuDataManagerImpl::GetInstance()->AddObserver(this); | 601 GpuDataManagerImpl::GetInstance()->AddObserver(this); |
601 } | 602 } |
602 | 603 |
603 is_initialized_ = true; | 604 is_initialized_ = true; |
604 return true; | 605 return true; |
605 } | 606 } |
606 | 607 |
| 608 void RenderProcessHostImpl::MaybeActivateMojo() { |
| 609 // TODO(darin): Following security review, we can unconditionally initialize |
| 610 // Mojo in all renderers. We will then be able to directly call Activate() |
| 611 // from OnProcessLaunched. |
| 612 if (!mojo_activation_required_) |
| 613 return; // Waiting on someone to require Mojo. |
| 614 |
| 615 if (!GetHandle()) |
| 616 return; // Waiting on renderer startup. |
| 617 |
| 618 if (!mojo_application_host_->did_activate()) |
| 619 mojo_application_host_->Activate(this, GetHandle()); |
| 620 } |
| 621 |
607 void RenderProcessHostImpl::CreateMessageFilters() { | 622 void RenderProcessHostImpl::CreateMessageFilters() { |
608 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 623 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
609 AddFilter(new ResourceSchedulerFilter(GetID())); | 624 AddFilter(new ResourceSchedulerFilter(GetID())); |
610 MediaInternals* media_internals = MediaInternals::GetInstance(); | 625 MediaInternals* media_internals = MediaInternals::GetInstance(); |
611 media::AudioManager* audio_manager = | 626 media::AudioManager* audio_manager = |
612 BrowserMainLoop::GetInstance()->audio_manager(); | 627 BrowserMainLoop::GetInstance()->audio_manager(); |
613 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages | 628 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages |
614 // from guests. | 629 // from guests. |
615 scoped_refptr<BrowserPluginMessageFilter> bp_message_filter( | 630 scoped_refptr<BrowserPluginMessageFilter> bp_message_filter( |
616 new BrowserPluginMessageFilter(GetID(), IsGuest())); | 631 new BrowserPluginMessageFilter(GetID(), IsGuest())); |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 // with state that must be there before any JavaScript executes. | 1980 // with state that must be there before any JavaScript executes. |
1966 // | 1981 // |
1967 // The queued messages contain such things as "navigate". If this notification | 1982 // The queued messages contain such things as "navigate". If this notification |
1968 // was after, we can end up executing JavaScript before the initialization | 1983 // was after, we can end up executing JavaScript before the initialization |
1969 // happens. | 1984 // happens. |
1970 NotificationService::current()->Notify( | 1985 NotificationService::current()->Notify( |
1971 NOTIFICATION_RENDERER_PROCESS_CREATED, | 1986 NOTIFICATION_RENDERER_PROCESS_CREATED, |
1972 Source<RenderProcessHost>(this), | 1987 Source<RenderProcessHost>(this), |
1973 NotificationService::NoDetails()); | 1988 NotificationService::NoDetails()); |
1974 | 1989 |
1975 // TODO(darin): This is blocked on security review. Un-commenting this will | 1990 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
1976 // allow Mojo calls from all renderers. | 1991 // This way, Mojo can be safely used from the renderer in response to any |
1977 #if 0 | 1992 // Chrome IPC message. |
1978 // Let the Mojo system get setup on the child process side before any other | 1993 MaybeActivateMojo(); |
1979 // IPCs arrive. This way those may safely generate Mojo-related RPCs. | |
1980 mojo_application_host_->Activate(this, GetHandle()); | |
1981 #endif | |
1982 | 1994 |
1983 while (!queued_messages_.empty()) { | 1995 while (!queued_messages_.empty()) { |
1984 Send(queued_messages_.front()); | 1996 Send(queued_messages_.front()); |
1985 queued_messages_.pop(); | 1997 queued_messages_.pop(); |
1986 } | 1998 } |
1987 | 1999 |
1988 #if defined(ENABLE_WEBRTC) | 2000 #if defined(ENABLE_WEBRTC) |
1989 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) | 2001 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) |
1990 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); | 2002 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); |
1991 #endif | 2003 #endif |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2070 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2059 DCHECK_GT(worker_ref_count_, 0); | 2071 DCHECK_GT(worker_ref_count_, 0); |
2060 --worker_ref_count_; | 2072 --worker_ref_count_; |
2061 if (worker_ref_count_ == 0) | 2073 if (worker_ref_count_ == 0) |
2062 Cleanup(); | 2074 Cleanup(); |
2063 } | 2075 } |
2064 | 2076 |
2065 void RenderProcessHostImpl::ConnectTo( | 2077 void RenderProcessHostImpl::ConnectTo( |
2066 const base::StringPiece& service_name, | 2078 const base::StringPiece& service_name, |
2067 mojo::ScopedMessagePipeHandle handle) { | 2079 mojo::ScopedMessagePipeHandle handle) { |
2068 if (!mojo_application_host_->did_activate()) | 2080 mojo_activation_required_ = true; |
2069 mojo_application_host_->Activate(this, GetHandle()); | 2081 MaybeActivateMojo(); |
2070 | 2082 |
2071 mojo::AllocationScope scope; | 2083 mojo::AllocationScope scope; |
2072 mojo_application_host_->shell_client()->AcceptConnection(service_name, | 2084 mojo_application_host_->shell_client()->AcceptConnection(service_name, |
2073 handle.Pass()); | 2085 handle.Pass()); |
2074 } | 2086 } |
2075 | 2087 |
2076 } // namespace content | 2088 } // namespace content |
OLD | NEW |