| Index: content/browser/mojo/mojo_shell_context.cc
|
| diff --git a/content/browser/mojo/mojo_shell_context.cc b/content/browser/mojo/mojo_shell_context.cc
|
| index 4f4200e4ea88c98903cfb22cd44669c0690afaa5..d651d1986afad2b1583a1e36efe15e2472949e91 100644
|
| --- a/content/browser/mojo/mojo_shell_context.cc
|
| +++ b/content/browser/mojo/mojo_shell_context.cc
|
| @@ -36,6 +36,7 @@
|
| #include "services/catalog/store.h"
|
| #include "services/shell/connect_params.h"
|
| #include "services/shell/native_runner.h"
|
| +#include "services/shell/public/cpp/connector.h"
|
| #include "services/shell/public/cpp/identity.h"
|
| #include "services/shell/public/cpp/shell_client.h"
|
| #include "services/shell/public/interfaces/connector.mojom.h"
|
| @@ -49,6 +50,21 @@ namespace content {
|
|
|
| namespace {
|
|
|
| +using ConnectorPtr = base::ThreadLocalPointer<shell::Connector>;
|
| +
|
| +base::LazyInstance<ConnectorPtr>::Leaky io_connector_tls_ptr =
|
| + LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +void SetConnectorOnIOThread(std::unique_ptr<shell::Connector> connector) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + io_connector_tls_ptr.Pointer()->Set(connector.release());
|
| +}
|
| +
|
| +void DestroyConnectorOnIOThread() {
|
| + delete MojoShellContext::GetConnectorForIOThread();
|
| + io_connector_tls_ptr.Pointer()->Set(nullptr);
|
| +}
|
| +
|
| void StartUtilityProcessOnIOThread(
|
| mojo::InterfaceRequest<mojom::ProcessControl> request,
|
| const base::string16& process_name,
|
| @@ -59,9 +75,7 @@ void StartUtilityProcessOnIOThread(
|
| if (!use_sandbox)
|
| process_host->DisableSandbox();
|
| process_host->Start();
|
| -
|
| - ServiceRegistry* services = process_host->GetServiceRegistry();
|
| - services->ConnectToRemoteService(std::move(request));
|
| + process_host->GetRemoteInterfaces()->GetInterface(std::move(request));
|
| }
|
|
|
| void OnApplicationLoaded(const std::string& name, bool success) {
|
| @@ -103,8 +117,7 @@ void RequestGpuProcessControl(
|
| // load requests through mojom::ProcessControl will also fail. Make sure we
|
| // handle
|
| // these cases correctly.
|
| - process_host->GetServiceRegistry()->ConnectToRemoteService(
|
| - std::move(request));
|
| + process_host->GetRemoteInterfaces()->GetInterface(std::move(request));
|
| }
|
|
|
| void LaunchAppInGpuProcess(const std::string& app_name,
|
| @@ -256,6 +269,11 @@ MojoShellContext::MojoShellContext() {
|
| }
|
| MojoShellConnection::SetForProcess(
|
| MojoShellConnection::Create(std::move(request)));
|
| + std::unique_ptr<shell::Connector> io_connector =
|
| + MojoShellConnection::GetForProcess()->GetConnector()->Clone();
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&SetConnectorOnIOThread, base::Passed(&io_connector)));
|
|
|
| ContentBrowserClient::StaticMojoApplicationMap apps;
|
| GetContentClient()->browser()->RegisterInProcessMojoApplications(&apps);
|
| @@ -293,6 +311,8 @@ MojoShellContext::MojoShellContext() {
|
| }
|
|
|
| MojoShellContext::~MojoShellContext() {
|
| + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&DestroyConnectorOnIOThread));
|
| if (MojoShellConnection::GetForProcess())
|
| MojoShellConnection::DestroyForProcess();
|
| catalog_.reset();
|
| @@ -311,6 +331,12 @@ void MojoShellContext::ConnectToApplication(
|
| std::move(exposed_services), callback);
|
| }
|
|
|
| +// static
|
| +shell::Connector* MojoShellContext::GetConnectorForIOThread() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + return io_connector_tls_ptr.Pointer()->Get();
|
| +}
|
| +
|
| void MojoShellContext::ConnectToApplicationOnOwnThread(
|
| const std::string& user_id,
|
| const std::string& name,
|
|
|