Commit bd0aa4dc authored by morrita's avatar morrita Committed by Commit bot

Always activate MojoApplicationHost

Before this change, MojoApplicatioHost was activated only if some
browser-side modules requested it. There was no way for renderer
to activate it.

This CL let MojoApplicationHost always get activated. Now
renderer can request services it needs without its own activation flow.

R=darin@chromium.org,tsepez@chromium.org
TEST=none
BUG=none

Review URL: https://codereview.chromium.org/563373002

Cr-Commit-Position: refs/heads/master@{#294969}
parent b90decf7
...@@ -287,7 +287,6 @@ RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { ...@@ -287,7 +287,6 @@ RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() {
} }
ServiceRegistry* RenderFrameHostImpl::GetServiceRegistry() { ServiceRegistry* RenderFrameHostImpl::GetServiceRegistry() {
static_cast<RenderProcessHostImpl*>(GetProcess())->EnsureMojoActivated();
return &service_registry_; return &service_registry_;
} }
......
...@@ -47,7 +47,7 @@ bool MojoApplicationHost::Init() { ...@@ -47,7 +47,7 @@ bool MojoApplicationHost::Init() {
return true; return true;
} }
bool MojoApplicationHost::Activate(IPC::Sender* sender, void MojoApplicationHost::Activate(IPC::Sender* sender,
base::ProcessHandle process_handle) { base::ProcessHandle process_handle) {
DCHECK(!did_activate_); DCHECK(!did_activate_);
DCHECK(client_handle_.is_valid()); DCHECK(client_handle_.is_valid());
...@@ -56,7 +56,6 @@ bool MojoApplicationHost::Activate(IPC::Sender* sender, ...@@ -56,7 +56,6 @@ bool MojoApplicationHost::Activate(IPC::Sender* sender,
PlatformFileFromScopedPlatformHandle(client_handle_.Pass()); PlatformFileFromScopedPlatformHandle(client_handle_.Pass());
did_activate_ = sender->Send(new MojoMsg_Activate( did_activate_ = sender->Send(new MojoMsg_Activate(
IPC::GetFileHandleForProcess(client_file, process_handle, true))); IPC::GetFileHandleForProcess(client_file, process_handle, true)));
return did_activate_;
} }
void MojoApplicationHost::WillDestroySoon() { void MojoApplicationHost::WillDestroySoon() {
......
...@@ -30,12 +30,10 @@ class MojoApplicationHost { ...@@ -30,12 +30,10 @@ class MojoApplicationHost {
// 1- Init makes service_registry() available synchronously. // 1- Init makes service_registry() available synchronously.
// 2- Activate establishes the actual connection to the peer process. // 2- Activate establishes the actual connection to the peer process.
bool Init(); bool Init();
bool Activate(IPC::Sender* sender, base::ProcessHandle process_handle); void Activate(IPC::Sender* sender, base::ProcessHandle process_handle);
void WillDestroySoon(); void WillDestroySoon();
bool did_activate() const { return did_activate_; }
ServiceRegistry* service_registry() { return &service_registry_; } ServiceRegistry* service_registry() { return &service_registry_; }
private: private:
......
...@@ -433,7 +433,6 @@ RenderProcessHostImpl::RenderProcessHostImpl( ...@@ -433,7 +433,6 @@ RenderProcessHostImpl::RenderProcessHostImpl(
#endif #endif
pending_views_(0), pending_views_(0),
mojo_application_host_(new MojoApplicationHost), mojo_application_host_(new MojoApplicationHost),
mojo_activation_required_(false),
visible_widgets_(0), visible_widgets_(0),
backgrounded_(true), backgrounded_(true),
is_initialized_(false), is_initialized_(false),
...@@ -638,20 +637,6 @@ bool RenderProcessHostImpl::Init() { ...@@ -638,20 +637,6 @@ bool RenderProcessHostImpl::Init() {
return true; return true;
} }
void RenderProcessHostImpl::MaybeActivateMojo() {
// TODO(darin): Following security review, we can unconditionally initialize
// Mojo in all renderers. We will then be able to directly call Activate()
// from OnProcessLaunched.
if (!mojo_activation_required_)
return; // Waiting on someone to require Mojo.
if (!GetHandle())
return; // Waiting on renderer startup.
if (!mojo_application_host_->did_activate())
mojo_application_host_->Activate(this, GetHandle());
}
bool RenderProcessHostImpl::ShouldUseMojoChannel() const { bool RenderProcessHostImpl::ShouldUseMojoChannel() const {
const base::CommandLine& command_line = const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
...@@ -1917,7 +1902,6 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) { ...@@ -1917,7 +1902,6 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) {
} }
mojo_application_host_.reset(new MojoApplicationHost); mojo_application_host_.reset(new MojoApplicationHost);
mojo_activation_required_ = false;
// It's possible that one of the calls out to the observers might have caused // It's possible that one of the calls out to the observers might have caused
// this object to be no longer needed. // this object to be no longer needed.
...@@ -2084,7 +2068,7 @@ void RenderProcessHostImpl::OnProcessLaunched() { ...@@ -2084,7 +2068,7 @@ void RenderProcessHostImpl::OnProcessLaunched() {
// Allow Mojo to be setup before the renderer sees any Chrome IPC messages. // Allow Mojo to be setup before the renderer sees any Chrome IPC messages.
// This way, Mojo can be safely used from the renderer in response to any // This way, Mojo can be safely used from the renderer in response to any
// Chrome IPC message. // Chrome IPC message.
MaybeActivateMojo(); mojo_application_host_->Activate(this, GetHandle());
while (!queued_messages_.empty()) { while (!queued_messages_.empty()) {
Send(queued_messages_.front()); Send(queued_messages_.front());
...@@ -2225,9 +2209,4 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() { ...@@ -2225,9 +2209,4 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
Cleanup(); Cleanup();
} }
void RenderProcessHostImpl::EnsureMojoActivated() {
mojo_activation_required_ = true;
MaybeActivateMojo();
}
} // namespace content } // namespace content
...@@ -245,9 +245,6 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -245,9 +245,6 @@ class CONTENT_EXPORT RenderProcessHostImpl
// immediately after receiving response headers. // immediately after receiving response headers.
void ResumeResponseDeferredAtStart(const GlobalRequestID& request_id); void ResumeResponseDeferredAtStart(const GlobalRequestID& request_id);
// Activates Mojo for this process. Does nothing if Mojo is already activated.
void EnsureMojoActivated();
protected: protected:
// A proxy for our IPC::Channel that lives on the IO thread (see // A proxy for our IPC::Channel that lives on the IO thread (see
// browser_process.h) // browser_process.h)
...@@ -272,7 +269,6 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -272,7 +269,6 @@ class CONTENT_EXPORT RenderProcessHostImpl
private: private:
friend class VisitRelayingRenderProcessHost; friend class VisitRelayingRenderProcessHost;
void MaybeActivateMojo();
bool ShouldUseMojoChannel() const; bool ShouldUseMojoChannel() const;
scoped_ptr<IPC::ChannelProxy> CreateChannelProxy( scoped_ptr<IPC::ChannelProxy> CreateChannelProxy(
const std::string& channel_id); const std::string& channel_id);
...@@ -320,7 +316,6 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -320,7 +316,6 @@ class CONTENT_EXPORT RenderProcessHostImpl
#endif #endif
scoped_ptr<MojoApplicationHost> mojo_application_host_; scoped_ptr<MojoApplicationHost> mojo_application_host_;
bool mojo_activation_required_;
// The registered IPC listener objects. When this list is empty, we should // The registered IPC listener objects. When this list is empty, we should
// delete ourselves. // delete ourselves.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment