Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 584173002: Revert "Always activate MojoApplicationHost" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 BrowserContext* browser_context, 430 BrowserContext* browser_context,
431 StoragePartitionImpl* storage_partition_impl, 431 StoragePartitionImpl* storage_partition_impl,
432 bool is_isolated_guest) 432 bool is_isolated_guest)
433 : fast_shutdown_started_(false), 433 : fast_shutdown_started_(false),
434 deleting_soon_(false), 434 deleting_soon_(false),
435 #ifndef NDEBUG 435 #ifndef NDEBUG
436 is_self_deleted_(false), 436 is_self_deleted_(false),
437 #endif 437 #endif
438 pending_views_(0), 438 pending_views_(0),
439 mojo_application_host_(new MojoApplicationHost), 439 mojo_application_host_(new MojoApplicationHost),
440 mojo_activation_required_(false),
440 visible_widgets_(0), 441 visible_widgets_(0),
441 backgrounded_(true), 442 backgrounded_(true),
442 is_initialized_(false), 443 is_initialized_(false),
443 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), 444 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
444 browser_context_(browser_context), 445 browser_context_(browser_context),
445 storage_partition_impl_(storage_partition_impl), 446 storage_partition_impl_(storage_partition_impl),
446 sudden_termination_allowed_(true), 447 sudden_termination_allowed_(true),
447 ignore_input_events_(false), 448 ignore_input_events_(false),
448 is_isolated_guest_(is_isolated_guest), 449 is_isolated_guest_(is_isolated_guest),
449 gpu_observer_registered_(false), 450 gpu_observer_registered_(false),
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 gpu_observer_registered_ = true; 635 gpu_observer_registered_ = true;
635 GpuDataManagerImpl::GetInstance()->AddObserver(this); 636 GpuDataManagerImpl::GetInstance()->AddObserver(this);
636 } 637 }
637 638
638 power_monitor_broadcaster_.Init(); 639 power_monitor_broadcaster_.Init();
639 640
640 is_initialized_ = true; 641 is_initialized_ = true;
641 return true; 642 return true;
642 } 643 }
643 644
645 void RenderProcessHostImpl::MaybeActivateMojo() {
646 // TODO(darin): Following security review, we can unconditionally initialize
647 // Mojo in all renderers. We will then be able to directly call Activate()
648 // from OnProcessLaunched.
649 if (!mojo_activation_required_)
650 return; // Waiting on someone to require Mojo.
651
652 if (!GetHandle())
653 return; // Waiting on renderer startup.
654
655 if (!mojo_application_host_->did_activate())
656 mojo_application_host_->Activate(this, GetHandle());
657 }
658
644 bool RenderProcessHostImpl::ShouldUseMojoChannel() const { 659 bool RenderProcessHostImpl::ShouldUseMojoChannel() const {
645 const base::CommandLine& command_line = 660 const base::CommandLine& command_line =
646 *base::CommandLine::ForCurrentProcess(); 661 *base::CommandLine::ForCurrentProcess();
647 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); 662 return command_line.HasSwitch(switches::kEnableRendererMojoChannel);
648 } 663 }
649 664
650 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( 665 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy(
651 const std::string& channel_id) { 666 const std::string& channel_id) {
652 scoped_refptr<base::SingleThreadTaskRunner> runner = 667 scoped_refptr<base::SingleThreadTaskRunner> runner =
653 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 668 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 IDMap<IPC::Listener>::iterator iter(&listeners_); 1919 IDMap<IPC::Listener>::iterator iter(&listeners_);
1905 while (!iter.IsAtEnd()) { 1920 while (!iter.IsAtEnd()) {
1906 iter.GetCurrentValue()->OnMessageReceived( 1921 iter.GetCurrentValue()->OnMessageReceived(
1907 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), 1922 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(),
1908 static_cast<int>(status), 1923 static_cast<int>(status),
1909 exit_code)); 1924 exit_code));
1910 iter.Advance(); 1925 iter.Advance();
1911 } 1926 }
1912 1927
1913 mojo_application_host_.reset(new MojoApplicationHost); 1928 mojo_application_host_.reset(new MojoApplicationHost);
1929 mojo_activation_required_ = false;
1914 1930
1915 // It's possible that one of the calls out to the observers might have caused 1931 // It's possible that one of the calls out to the observers might have caused
1916 // this object to be no longer needed. 1932 // this object to be no longer needed.
1917 if (delayed_cleanup_needed_) 1933 if (delayed_cleanup_needed_)
1918 Cleanup(); 1934 Cleanup();
1919 1935
1920 // This object is not deleted at this point and might be reused later. 1936 // This object is not deleted at this point and might be reused later.
1921 // TODO(darin): clean this up 1937 // TODO(darin): clean this up
1922 } 1938 }
1923 1939
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 // was after, we can end up executing JavaScript before the initialization 2086 // was after, we can end up executing JavaScript before the initialization
2071 // happens. 2087 // happens.
2072 NotificationService::current()->Notify( 2088 NotificationService::current()->Notify(
2073 NOTIFICATION_RENDERER_PROCESS_CREATED, 2089 NOTIFICATION_RENDERER_PROCESS_CREATED,
2074 Source<RenderProcessHost>(this), 2090 Source<RenderProcessHost>(this),
2075 NotificationService::NoDetails()); 2091 NotificationService::NoDetails());
2076 2092
2077 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. 2093 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages.
2078 // This way, Mojo can be safely used from the renderer in response to any 2094 // This way, Mojo can be safely used from the renderer in response to any
2079 // Chrome IPC message. 2095 // Chrome IPC message.
2080 mojo_application_host_->Activate(this, GetHandle()); 2096 MaybeActivateMojo();
2081 2097
2082 while (!queued_messages_.empty()) { 2098 while (!queued_messages_.empty()) {
2083 Send(queued_messages_.front()); 2099 Send(queued_messages_.front());
2084 queued_messages_.pop(); 2100 queued_messages_.pop();
2085 } 2101 }
2086 2102
2087 #if defined(ENABLE_WEBRTC) 2103 #if defined(ENABLE_WEBRTC)
2088 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) 2104 if (WebRTCInternals::GetInstance()->aec_dump_enabled())
2089 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); 2105 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path());
2090 #endif 2106 #endif
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 } 2227 }
2212 2228
2213 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2229 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2214 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2230 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2215 DCHECK_GT(worker_ref_count_, 0); 2231 DCHECK_GT(worker_ref_count_, 0);
2216 --worker_ref_count_; 2232 --worker_ref_count_;
2217 if (worker_ref_count_ == 0) 2233 if (worker_ref_count_ == 0)
2218 Cleanup(); 2234 Cleanup();
2219 } 2235 }
2220 2236
2237 void RenderProcessHostImpl::EnsureMojoActivated() {
2238 mojo_activation_required_ = true;
2239 MaybeActivateMojo();
2240 }
2241
2221 } // namespace content 2242 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698