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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 BrowserContext* browser_context, | 433 BrowserContext* browser_context, |
434 StoragePartitionImpl* storage_partition_impl, | 434 StoragePartitionImpl* storage_partition_impl, |
435 bool is_isolated_guest) | 435 bool is_isolated_guest) |
436 : fast_shutdown_started_(false), | 436 : fast_shutdown_started_(false), |
437 deleting_soon_(false), | 437 deleting_soon_(false), |
438 #ifndef NDEBUG | 438 #ifndef NDEBUG |
439 is_self_deleted_(false), | 439 is_self_deleted_(false), |
440 #endif | 440 #endif |
441 pending_views_(0), | 441 pending_views_(0), |
442 mojo_application_host_(new MojoApplicationHost), | 442 mojo_application_host_(new MojoApplicationHost), |
443 mojo_activation_required_(false), | |
444 visible_widgets_(0), | 443 visible_widgets_(0), |
445 backgrounded_(true), | 444 backgrounded_(true), |
446 is_initialized_(false), | 445 is_initialized_(false), |
447 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 446 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
448 browser_context_(browser_context), | 447 browser_context_(browser_context), |
449 storage_partition_impl_(storage_partition_impl), | 448 storage_partition_impl_(storage_partition_impl), |
450 sudden_termination_allowed_(true), | 449 sudden_termination_allowed_(true), |
451 ignore_input_events_(false), | 450 ignore_input_events_(false), |
452 is_isolated_guest_(is_isolated_guest), | 451 is_isolated_guest_(is_isolated_guest), |
453 gpu_observer_registered_(false), | 452 gpu_observer_registered_(false), |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 GpuDataManagerImpl::GetInstance()->AddObserver(this); | 638 GpuDataManagerImpl::GetInstance()->AddObserver(this); |
640 } | 639 } |
641 | 640 |
642 power_monitor_broadcaster_.Init(); | 641 power_monitor_broadcaster_.Init(); |
643 | 642 |
644 is_initialized_ = true; | 643 is_initialized_ = true; |
645 init_time_ = base::TimeTicks::Now(); | 644 init_time_ = base::TimeTicks::Now(); |
646 return true; | 645 return true; |
647 } | 646 } |
648 | 647 |
649 void RenderProcessHostImpl::MaybeActivateMojo() { | |
650 // TODO(darin): Following security review, we can unconditionally initialize | |
651 // Mojo in all renderers. We will then be able to directly call Activate() | |
652 // from OnProcessLaunched. | |
653 if (!mojo_activation_required_) | |
654 return; // Waiting on someone to require Mojo. | |
655 | |
656 if (!GetHandle()) | |
657 return; // Waiting on renderer startup. | |
658 | |
659 if (!mojo_application_host_->did_activate()) | |
660 mojo_application_host_->Activate(this, GetHandle()); | |
661 } | |
662 | |
663 bool RenderProcessHostImpl::ShouldUseMojoChannel() const { | 648 bool RenderProcessHostImpl::ShouldUseMojoChannel() const { |
664 const base::CommandLine& command_line = | 649 const base::CommandLine& command_line = |
665 *base::CommandLine::ForCurrentProcess(); | 650 *base::CommandLine::ForCurrentProcess(); |
666 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); | 651 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); |
667 } | 652 } |
668 | 653 |
669 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 654 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
670 const std::string& channel_id) { | 655 const std::string& channel_id) { |
671 scoped_refptr<base::SingleThreadTaskRunner> runner = | 656 scoped_refptr<base::SingleThreadTaskRunner> runner = |
672 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 657 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1936 IDMap<IPC::Listener>::iterator iter(&listeners_); | 1921 IDMap<IPC::Listener>::iterator iter(&listeners_); |
1937 while (!iter.IsAtEnd()) { | 1922 while (!iter.IsAtEnd()) { |
1938 iter.GetCurrentValue()->OnMessageReceived( | 1923 iter.GetCurrentValue()->OnMessageReceived( |
1939 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), | 1924 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), |
1940 static_cast<int>(status), | 1925 static_cast<int>(status), |
1941 exit_code)); | 1926 exit_code)); |
1942 iter.Advance(); | 1927 iter.Advance(); |
1943 } | 1928 } |
1944 | 1929 |
1945 mojo_application_host_.reset(new MojoApplicationHost); | 1930 mojo_application_host_.reset(new MojoApplicationHost); |
1946 mojo_activation_required_ = false; | |
1947 | 1931 |
1948 // It's possible that one of the calls out to the observers might have caused | 1932 // It's possible that one of the calls out to the observers might have caused |
1949 // this object to be no longer needed. | 1933 // this object to be no longer needed. |
1950 if (delayed_cleanup_needed_) | 1934 if (delayed_cleanup_needed_) |
1951 Cleanup(); | 1935 Cleanup(); |
1952 | 1936 |
1953 // This object is not deleted at this point and might be reused later. | 1937 // This object is not deleted at this point and might be reused later. |
1954 // TODO(darin): clean this up | 1938 // TODO(darin): clean this up |
1955 } | 1939 } |
1956 | 1940 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 // was after, we can end up executing JavaScript before the initialization | 2087 // was after, we can end up executing JavaScript before the initialization |
2104 // happens. | 2088 // happens. |
2105 NotificationService::current()->Notify( | 2089 NotificationService::current()->Notify( |
2106 NOTIFICATION_RENDERER_PROCESS_CREATED, | 2090 NOTIFICATION_RENDERER_PROCESS_CREATED, |
2107 Source<RenderProcessHost>(this), | 2091 Source<RenderProcessHost>(this), |
2108 NotificationService::NoDetails()); | 2092 NotificationService::NoDetails()); |
2109 | 2093 |
2110 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2094 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
2111 // This way, Mojo can be safely used from the renderer in response to any | 2095 // This way, Mojo can be safely used from the renderer in response to any |
2112 // Chrome IPC message. | 2096 // Chrome IPC message. |
2113 MaybeActivateMojo(); | 2097 mojo_application_host_->Activate(this, GetHandle()); |
2114 | 2098 |
2115 if (channel_mojo_host_) | 2099 if (channel_mojo_host_) |
2116 channel_mojo_host_->OnClientLaunched(GetHandle()); | 2100 channel_mojo_host_->OnClientLaunched(GetHandle()); |
2117 | 2101 |
2118 while (!queued_messages_.empty()) { | 2102 while (!queued_messages_.empty()) { |
2119 Send(queued_messages_.front()); | 2103 Send(queued_messages_.front()); |
2120 queued_messages_.pop(); | 2104 queued_messages_.pop(); |
2121 } | 2105 } |
2122 | 2106 |
2123 #if defined(ENABLE_WEBRTC) | 2107 #if defined(ENABLE_WEBRTC) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2247 } | 2231 } |
2248 | 2232 |
2249 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2233 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2250 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2234 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2251 DCHECK_GT(worker_ref_count_, 0); | 2235 DCHECK_GT(worker_ref_count_, 0); |
2252 --worker_ref_count_; | 2236 --worker_ref_count_; |
2253 if (worker_ref_count_ == 0) | 2237 if (worker_ref_count_ == 0) |
2254 Cleanup(); | 2238 Cleanup(); |
2255 } | 2239 } |
2256 | 2240 |
2257 void RenderProcessHostImpl::EnsureMojoActivated() { | |
2258 mojo_activation_required_ = true; | |
2259 MaybeActivateMojo(); | |
2260 } | |
2261 | |
2262 } // namespace content | 2241 } // namespace content |
OLD | NEW |