Chromium Code Reviews| 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 BrowserContext* browser_context, | 426 BrowserContext* browser_context, |
| 427 StoragePartitionImpl* storage_partition_impl, | 427 StoragePartitionImpl* storage_partition_impl, |
| 428 bool is_isolated_guest) | 428 bool is_isolated_guest) |
| 429 : fast_shutdown_started_(false), | 429 : fast_shutdown_started_(false), |
| 430 deleting_soon_(false), | 430 deleting_soon_(false), |
| 431 #ifndef NDEBUG | 431 #ifndef NDEBUG |
| 432 is_self_deleted_(false), | 432 is_self_deleted_(false), |
| 433 #endif | 433 #endif |
| 434 pending_views_(0), | 434 pending_views_(0), |
| 435 mojo_application_host_(new MojoApplicationHost), | 435 mojo_application_host_(new MojoApplicationHost), |
| 436 mojo_activation_required_(false), | |
| 437 visible_widgets_(0), | 436 visible_widgets_(0), |
| 438 backgrounded_(true), | 437 backgrounded_(true), |
| 439 is_initialized_(false), | 438 is_initialized_(false), |
| 440 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 439 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
| 441 browser_context_(browser_context), | 440 browser_context_(browser_context), |
| 442 storage_partition_impl_(storage_partition_impl), | 441 storage_partition_impl_(storage_partition_impl), |
| 443 sudden_termination_allowed_(true), | 442 sudden_termination_allowed_(true), |
| 444 ignore_input_events_(false), | 443 ignore_input_events_(false), |
| 445 is_isolated_guest_(is_isolated_guest), | 444 is_isolated_guest_(is_isolated_guest), |
| 446 gpu_observer_registered_(false), | 445 gpu_observer_registered_(false), |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 gpu_observer_registered_ = true; | 630 gpu_observer_registered_ = true; |
| 632 GpuDataManagerImpl::GetInstance()->AddObserver(this); | 631 GpuDataManagerImpl::GetInstance()->AddObserver(this); |
| 633 } | 632 } |
| 634 | 633 |
| 635 power_monitor_broadcaster_.Init(); | 634 power_monitor_broadcaster_.Init(); |
| 636 | 635 |
| 637 is_initialized_ = true; | 636 is_initialized_ = true; |
| 638 return true; | 637 return true; |
| 639 } | 638 } |
| 640 | 639 |
| 641 void RenderProcessHostImpl::MaybeActivateMojo() { | |
| 642 // TODO(darin): Following security review, we can unconditionally initialize | |
| 643 // Mojo in all renderers. We will then be able to directly call Activate() | |
| 644 // from OnProcessLaunched. | |
| 645 if (!mojo_activation_required_) | |
| 646 return; // Waiting on someone to require Mojo. | |
| 647 | |
| 648 if (!GetHandle()) | |
| 649 return; // Waiting on renderer startup. | |
| 650 | |
| 651 if (!mojo_application_host_->did_activate()) | |
|
darin (slow to review)
2014/09/15 04:49:32
it turns out this was the only caller of did_activ
| |
| 652 mojo_application_host_->Activate(this, GetHandle()); | |
| 653 } | |
| 654 | |
| 655 bool RenderProcessHostImpl::ShouldUseMojoChannel() const { | 640 bool RenderProcessHostImpl::ShouldUseMojoChannel() const { |
| 656 const base::CommandLine& command_line = | 641 const base::CommandLine& command_line = |
| 657 *base::CommandLine::ForCurrentProcess(); | 642 *base::CommandLine::ForCurrentProcess(); |
| 658 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); | 643 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); |
| 659 } | 644 } |
| 660 | 645 |
| 661 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 646 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
| 662 const std::string& channel_id) { | 647 const std::string& channel_id) { |
| 663 scoped_refptr<base::SingleThreadTaskRunner> runner = | 648 scoped_refptr<base::SingleThreadTaskRunner> runner = |
| 664 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 649 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| (...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1910 IDMap<IPC::Listener>::iterator iter(&listeners_); | 1895 IDMap<IPC::Listener>::iterator iter(&listeners_); |
| 1911 while (!iter.IsAtEnd()) { | 1896 while (!iter.IsAtEnd()) { |
| 1912 iter.GetCurrentValue()->OnMessageReceived( | 1897 iter.GetCurrentValue()->OnMessageReceived( |
| 1913 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), | 1898 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), |
| 1914 static_cast<int>(status), | 1899 static_cast<int>(status), |
| 1915 exit_code)); | 1900 exit_code)); |
| 1916 iter.Advance(); | 1901 iter.Advance(); |
| 1917 } | 1902 } |
| 1918 | 1903 |
| 1919 mojo_application_host_.reset(new MojoApplicationHost); | 1904 mojo_application_host_.reset(new MojoApplicationHost); |
| 1920 mojo_activation_required_ = false; | |
| 1921 | 1905 |
| 1922 // It's possible that one of the calls out to the observers might have caused | 1906 // It's possible that one of the calls out to the observers might have caused |
| 1923 // this object to be no longer needed. | 1907 // this object to be no longer needed. |
| 1924 if (delayed_cleanup_needed_) | 1908 if (delayed_cleanup_needed_) |
| 1925 Cleanup(); | 1909 Cleanup(); |
| 1926 | 1910 |
| 1927 // This object is not deleted at this point and might be reused later. | 1911 // This object is not deleted at this point and might be reused later. |
| 1928 // TODO(darin): clean this up | 1912 // TODO(darin): clean this up |
| 1929 } | 1913 } |
| 1930 | 1914 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2077 // was after, we can end up executing JavaScript before the initialization | 2061 // was after, we can end up executing JavaScript before the initialization |
| 2078 // happens. | 2062 // happens. |
| 2079 NotificationService::current()->Notify( | 2063 NotificationService::current()->Notify( |
| 2080 NOTIFICATION_RENDERER_PROCESS_CREATED, | 2064 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 2081 Source<RenderProcessHost>(this), | 2065 Source<RenderProcessHost>(this), |
| 2082 NotificationService::NoDetails()); | 2066 NotificationService::NoDetails()); |
| 2083 | 2067 |
| 2084 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2068 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
| 2085 // This way, Mojo can be safely used from the renderer in response to any | 2069 // This way, Mojo can be safely used from the renderer in response to any |
| 2086 // Chrome IPC message. | 2070 // Chrome IPC message. |
| 2087 MaybeActivateMojo(); | 2071 mojo_application_host_->Activate(this, GetHandle()); |
| 2088 | 2072 |
| 2089 while (!queued_messages_.empty()) { | 2073 while (!queued_messages_.empty()) { |
| 2090 Send(queued_messages_.front()); | 2074 Send(queued_messages_.front()); |
| 2091 queued_messages_.pop(); | 2075 queued_messages_.pop(); |
| 2092 } | 2076 } |
| 2093 | 2077 |
| 2094 #if defined(ENABLE_WEBRTC) | 2078 #if defined(ENABLE_WEBRTC) |
| 2095 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) | 2079 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) |
| 2096 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); | 2080 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); |
| 2097 #endif | 2081 #endif |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2218 } | 2202 } |
| 2219 | 2203 |
| 2220 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2204 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
| 2221 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2205 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2222 DCHECK_GT(worker_ref_count_, 0); | 2206 DCHECK_GT(worker_ref_count_, 0); |
| 2223 --worker_ref_count_; | 2207 --worker_ref_count_; |
| 2224 if (worker_ref_count_ == 0) | 2208 if (worker_ref_count_ == 0) |
| 2225 Cleanup(); | 2209 Cleanup(); |
| 2226 } | 2210 } |
| 2227 | 2211 |
| 2228 void RenderProcessHostImpl::EnsureMojoActivated() { | |
| 2229 mojo_activation_required_ = true; | |
| 2230 MaybeActivateMojo(); | |
| 2231 } | |
| 2232 | |
| 2233 } // namespace content | 2212 } // namespace content |
| OLD | NEW |