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

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2107143003: Revert of Make RenderProcessHost/RenderThread use MojoChildConnection/MojoShellConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rph2
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/child/child_thread_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 5f4306a1ca1adcd51ed743a5f51579957c17dfe8..f859866b27795aadc62590287556e4b35e4f7702 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -85,6 +85,7 @@
#include "content/browser/message_port_message_filter.h"
#include "content/browser/mime_registry_impl.h"
#include "content/browser/mojo/constants.h"
+#include "content/browser/mojo/mojo_application_host.h"
#include "content/browser/mojo/mojo_child_connection.h"
#include "content/browser/notifications/notification_message_filter.h"
#include "content/browser/notifications/platform_notification_context_impl.h"
@@ -542,6 +543,7 @@
#endif
pending_views_(0),
child_token_(mojo::edk::GenerateRandomToken()),
+ mojo_application_host_(new MojoApplicationHost(child_token_)),
visible_widgets_(0),
is_process_backgrounded_(false),
is_initialized_(false),
@@ -600,29 +602,6 @@
IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded();
#endif // defined(OS_MACOSX)
#endif // USE_ATTACHMENT_BROKER
-
- shell::Connector* connector =
- BrowserContext::GetShellConnectorFor(browser_context_);
- // Some embedders may not initialize Mojo or the shell connector for a browser
- // context (e.g. Android WebView)... so just fall back to the per-process
- // connector.
- if (!connector) {
- // Additionally, some test code may not initialize the process-wide
- // MojoShellConnection prior to this point. This class of test code doesn't
- // care about render processes so we can initialize a dummy one.
- if (!MojoShellConnection::GetForProcess()) {
- shell::mojom::ShellClientRequest request =
- mojo::GetProxy(&test_shell_client_);
- MojoShellConnection::SetForProcess(MojoShellConnection::Create(
- std::move(request)));
- }
- connector = MojoShellConnection::GetForProcess()->GetConnector();
- }
- mojo_child_connection_.reset(new MojoChildConnection(
- kRendererMojoApplicationName,
- base::StringPrintf("%d_%d", id_, instance_id_++),
- child_token_,
- connector));
}
// static
@@ -700,6 +679,19 @@
// for the view host which may not be sure in some cases
if (channel_)
return true;
+
+ shell::Connector* connector =
+ BrowserContext::GetShellConnectorFor(browser_context_);
+ // Some embedders may not initialize Mojo or the shell connector for a browser
+ // context (e.g. Android WebView)... so just fall back to the per-process
+ // connector.
+ if (!connector)
+ connector = MojoShellConnection::GetForProcess()->GetConnector();
+ mojo_child_connection_.reset(new MojoChildConnection(
+ kRendererMojoApplicationName,
+ base::StringPrintf("%d_%d", id_, instance_id_++),
+ child_token_,
+ connector));
base::CommandLine::StringType renderer_prefix;
// A command prefix is something prepended to the command line of the spawned
@@ -749,8 +741,7 @@
channel_id,
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO)
->task_runner(),
- mojo_channel_token_,
- mojo_child_connection_->shell_client_token())));
+ mojo_channel_token_, mojo_application_host_->GetToken())));
base::Thread::Options options;
#if defined(OS_WIN) && !defined(OS_MACOSX)
@@ -1068,11 +1059,11 @@
#if defined(OS_ANDROID)
ServiceRegistrarAndroid::RegisterProcessHostServices(
- mojo_child_connection_->service_registry_android());
+ mojo_application_host_->service_registry_android());
#endif
GetContentClient()->browser()->ExposeInterfacesToRenderer(
- GetInterfaceRegistry(), this);
+ mojo_application_host_->interface_registry(), this);
}
void RenderProcessHostImpl::CreateStoragePartitionService(
@@ -1098,11 +1089,13 @@
}
shell::InterfaceRegistry* RenderProcessHostImpl::GetInterfaceRegistry() {
- return GetChildConnection()->GetInterfaceRegistry();
+ DCHECK(mojo_application_host_);
+ return mojo_application_host_->interface_registry();
}
shell::InterfaceProvider* RenderProcessHostImpl::GetRemoteInterfaces() {
- return GetChildConnection()->GetRemoteInterfaces();
+ DCHECK(mojo_application_host_);
+ return mojo_application_host_->remote_interfaces();
}
shell::Connection* RenderProcessHostImpl::GetChildConnection() {
@@ -1343,7 +1336,7 @@
mojo_channel_token_);
}
command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
- mojo_child_connection_->shell_client_token());
+ mojo_application_host_->GetToken());
}
void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
@@ -1925,6 +1918,14 @@
RemoveUserData(kSessionStorageHolderKey);
+ // On shutdown, |this| may not be deleted because the deleter is posted to
+ // the current MessageLoop, but MessageLoop deletes all its pending
+ // callbacks on shutdown. Since the deleter takes |this| as a raw pointer,
+ // deleting the callback doesn't delete |this| resulting in a memory leak.
+ // Valgrind complains, so delete |mojo_application_host_| explicitly here to
+ // stop valgrind from complaining.
+ mojo_application_host_.reset();
+
// Remove ourself from the list of renderer processes so that we can't be
// reused in between now and when the Delete task runs.
UnregisterHost(GetID());
@@ -2421,15 +2422,7 @@
// navigate or perform other actions that require a connection. Ensure that
// there is one before calling them.
child_token_ = mojo::edk::GenerateRandomToken();
- shell::Connector* connector =
- BrowserContext::GetShellConnectorFor(browser_context_);
- if (!connector)
- connector = MojoShellConnection::GetForProcess()->GetConnector();
- mojo_child_connection_.reset(new MojoChildConnection(
- kRendererMojoApplicationName,
- base::StringPrintf("%d_%d", id_, instance_id_++),
- child_token_,
- connector));
+ mojo_application_host_.reset(new MojoApplicationHost(child_token_));
within_process_died_observer_ = true;
NotificationService::current()->Notify(
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/child/child_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698