| 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 f58065b8520714c0b9095e78f8f3bb7272c685af..e3f962f262c859a067c9bce529bda4f9b90223b6 100644
|
| --- a/content/browser/mojo/mojo_shell_client_host.cc
|
| +++ b/content/browser/mojo/mojo_shell_client_host.cc
|
| @@ -2,9 +2,11 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/strings/stringprintf.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "content/browser/mojo/mojo_shell_client_host.h"
|
| #include "content/common/mojo/mojo_messages.h"
|
| +#include "content/public/browser/render_process_host.h"
|
| #include "content/public/common/mojo_shell_connection.h"
|
| #include "ipc/ipc_sender.h"
|
| #include "mojo/application/public/cpp/application_impl.h"
|
| @@ -16,6 +18,9 @@
|
|
|
| namespace content {
|
| namespace {
|
| +
|
| +const char kMojoShellInstanceURL[] = "mojo_shell_instance_url";
|
| +
|
| void DidCreateChannel(mojo::embedder::ChannelInfo* info) {}
|
|
|
| base::PlatformFile PlatformFileFromScopedPlatformHandle(
|
| @@ -27,11 +32,30 @@ base::PlatformFile PlatformFileFromScopedPlatformHandle(
|
| #endif
|
| }
|
|
|
| +class InstanceURL : public base::SupportsUserData::Data {
|
| + public:
|
| + InstanceURL(const std::string& instance_url) : instance_url_(instance_url) {}
|
| + ~InstanceURL() override {}
|
| +
|
| + std::string get() const { return instance_url_; }
|
| +
|
| + private:
|
| + std::string instance_url_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(InstanceURL);
|
| +};
|
| +
|
| +void SetMojoApplicationInstanceURL(RenderProcessHost* render_process_host,
|
| + const std::string& instance_url) {
|
| + render_process_host->SetUserData(kMojoShellInstanceURL,
|
| + new InstanceURL(instance_url));
|
| +}
|
| +
|
| } // namespace
|
|
|
| void RegisterChildWithExternalShell(int child_process_id,
|
| base::ProcessHandle process_handle,
|
| - IPC::Sender* sender) {
|
| + RenderProcessHost* render_process_host) {
|
| // Some process types get created before the main message loop.
|
| if (!MojoShellConnection::Get())
|
| return;
|
| @@ -57,16 +81,27 @@ void RegisterChildWithExternalShell(int child_process_id,
|
| // specification is best determined (not here, this is a common
|
| // chokepoint for all process types) and how to wire it through.
|
| // http://crbug.com/555393
|
| + std::string url =
|
| + base::StringPrintf("exe:chrome_renderer%d", child_process_id);
|
| application_manager->CreateInstanceForHandle(
|
| - mojo::ScopedHandle(mojo::Handle(handle.release().value())),
|
| - "exe:chrome_renderer", // See above about how this string is meaningless.
|
| - base::IntToString(child_process_id));
|
| + mojo::ScopedHandle(mojo::Handle(handle.release().value())), url);
|
|
|
| // Send the other end to the child via Chrome IPC.
|
| base::PlatformFile client_file = PlatformFileFromScopedPlatformHandle(
|
| platform_channel_pair.PassClientHandle());
|
| - sender->Send(new MojoMsg_BindExternalMojoShellHandle(
|
| + render_process_host->Send(new MojoMsg_BindExternalMojoShellHandle(
|
| IPC::GetFileHandleForProcess(client_file, process_handle, true)));
|
| +
|
| + // Store the URL on the RPH so client code can access it later via
|
| + // GetMojoApplicationInstanceURL().
|
| + SetMojoApplicationInstanceURL(render_process_host, url);
|
| +}
|
| +
|
| +std::string GetMojoApplicationInstanceURL(
|
| + RenderProcessHost* render_process_host) {
|
| + InstanceURL* instance_url = static_cast<InstanceURL*>(
|
| + render_process_host->GetUserData(kMojoShellInstanceURL));
|
| + return instance_url ? instance_url->get() : std::string();
|
| }
|
|
|
| } // namespace content
|
|
|