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

Unified Diff: content/browser/mojo/mojo_shell_client_host.cc

Issue 1476643002: mustash: Enable connections to mus from the Chrome renderer [take 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't create a RenderWidgetWindowTreeeClientFactory in tests Created 5 years, 1 month 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
Index: content/browser/mojo/mojo_shell_client_host.cc
diff --git a/content/browser/mojo/mojo_shell_client_host.cc b/content/browser/mojo/mojo_shell_client_host.cc
index 1bc85b51f168de0d8bc05c6909e59fe1d5f3771c..eb07f837f7a919133f3b1ea4f8186f63550c5f9c 100644
--- a/content/browser/mojo/mojo_shell_client_host.cc
+++ b/content/browser/mojo/mojo_shell_client_host.cc
@@ -20,6 +20,7 @@ namespace content {
namespace {
const char kMojoShellInstanceURL[] = "mojo_shell_instance_url";
+const char kMojoPlatformFile[] = "mojo_platform_file";
void DidCreateChannel(mojo::embedder::ChannelInfo* info) {}
@@ -45,16 +46,35 @@ class InstanceURL : public base::SupportsUserData::Data {
DISALLOW_COPY_AND_ASSIGN(InstanceURL);
};
+class InstanceShellHandle : public base::SupportsUserData::Data {
+ public:
+ InstanceShellHandle(base::PlatformFile shell_handle)
+ : shell_handle_(shell_handle) {}
+ ~InstanceShellHandle() override {}
+
+ base::PlatformFile get() const { return shell_handle_; }
+
+ private:
+ base::PlatformFile shell_handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstanceShellHandle);
+};
+
void SetMojoApplicationInstanceURL(RenderProcessHost* render_process_host,
const std::string& instance_url) {
render_process_host->SetUserData(kMojoShellInstanceURL,
new InstanceURL(instance_url));
}
+void SetMojoPlatformFile(RenderProcessHost* render_process_host,
+ base::PlatformFile platform_file) {
+ render_process_host->SetUserData(kMojoPlatformFile,
+ new InstanceShellHandle(platform_file));
+}
+
} // namespace
void RegisterChildWithExternalShell(int child_process_id,
- base::ProcessHandle process_handle,
RenderProcessHost* render_process_host) {
// Some process types get created before the main message loop.
if (!MojoShellConnection::Get())
@@ -88,8 +108,7 @@ void RegisterChildWithExternalShell(int child_process_id,
// Send the other end to the child via Chrome IPC.
base::PlatformFile client_file = PlatformFileFromScopedPlatformHandle(
platform_channel_pair.PassClientHandle());
- render_process_host->Send(new MojoMsg_BindExternalMojoShellHandle(
- IPC::GetFileHandleForProcess(client_file, process_handle, true)));
+ SetMojoPlatformFile(render_process_host, client_file);
// Store the URL on the RPH so client code can access it later via
// GetMojoApplicationInstanceURL().
@@ -103,4 +122,15 @@ std::string GetMojoApplicationInstanceURL(
return instance_url ? instance_url->get() : std::string();
}
+void SendExternalMojoShellHandleToChild(
+ base::ProcessHandle process_handle,
+ RenderProcessHost* render_process_host) {
+ InstanceShellHandle* client_file = static_cast<InstanceShellHandle*>(
+ render_process_host->GetUserData(kMojoPlatformFile));
+ if (!client_file)
+ return;
+ render_process_host->Send(new MojoMsg_BindExternalMojoShellHandle(
+ IPC::GetFileHandleForProcess(client_file->get(), process_handle, true)));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698