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

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

Issue 2104553002: Migrate GpuProcess to use MojoChild/ShellConnection for the Shell handshake (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/mojo/mojo_shell_context.h ('k') | content/content.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cf4a0a3a6b7cc230742510d279d6924626a51225..707308d651fdb46c43c4869f23676bb791d78e6c 100644
--- a/content/browser/mojo/mojo_shell_context.cc
+++ b/content/browser/mojo/mojo_shell_context.cc
@@ -35,6 +35,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"
@@ -48,6 +49,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,
@@ -232,6 +248,8 @@ MojoShellContext::MojoShellContext() {
manifest_provider_->AddManifests(std::move(manifests));
manifest_provider_->AddManifestResource(kBrowserMojoApplicationName,
IDR_MOJO_CONTENT_BROWSER_MANIFEST);
+ manifest_provider_->AddManifestResource(kGpuMojoApplicationName,
+ IDR_MOJO_CONTENT_GPU_MANIFEST);
manifest_provider_->AddManifestResource(kRendererMojoApplicationName,
IDR_MOJO_CONTENT_RENDERER_MANIFEST);
manifest_provider_->AddManifestResource("mojo:catalog",
@@ -254,6 +272,12 @@ 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);
for (const auto& entry : apps) {
@@ -292,6 +316,8 @@ MojoShellContext::MojoShellContext() {
MojoShellContext::~MojoShellContext() {
if (MojoShellConnection::GetForProcess())
MojoShellConnection::DestroyForProcess();
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&DestroyConnectorOnIOThread));
catalog_.reset();
}
@@ -308,6 +334,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,
« no previous file with comments | « content/browser/mojo/mojo_shell_context.h ('k') | content/content.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698