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

Unified Diff: content/common/mojo/mojo_shell_connection_impl.cc

Issue 1738663002: Hook embedded shell up to MojoShellConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/common/mojo/mojo_shell_connection_impl.h ('k') | content/common/url_schemes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mojo/mojo_shell_connection_impl.cc
diff --git a/content/common/mojo/mojo_shell_connection_impl.cc b/content/common/mojo/mojo_shell_connection_impl.cc
index 282b4b1413aef05186f6d3c8d3721394f3882c40..853120506f7223dd739a62c8b0602e054a7741c8 100644
--- a/content/common/mojo/mojo_shell_connection_impl.cc
+++ b/content/common/mojo/mojo_shell_connection_impl.cc
@@ -17,6 +17,7 @@
namespace content {
namespace {
+
using MojoShellConnectionPtr =
base::ThreadLocalPointer<MojoShellConnectionImpl>;
@@ -34,11 +35,25 @@ bool IsRunningInMojoShell() {
// static
void MojoShellConnectionImpl::Create() {
DCHECK(!lazy_tls_ptr.Pointer()->Get());
- MojoShellConnectionImpl* connection = new MojoShellConnectionImpl;
+ MojoShellConnectionImpl* connection =
+ new MojoShellConnectionImpl(true /* external */);
lazy_tls_ptr.Pointer()->Set(connection);
}
// static
+void MojoShellConnectionImpl::Create(
+ mojo::shell::mojom::ShellClientRequest request) {
+ DCHECK(!lazy_tls_ptr.Pointer()->Get());
+ MojoShellConnectionImpl* connection =
+ new MojoShellConnectionImpl(false /* external */);
+ lazy_tls_ptr.Pointer()->Set(connection);
+
+ connection->shell_connection_.reset(
+ new mojo::ShellConnection(connection, std::move(request)));
+ connection->shell_connection_->WaitForInitialize();
+}
+
+// static
MojoShellConnectionImpl* MojoShellConnectionImpl::Get() {
return static_cast<MojoShellConnectionImpl*>(MojoShellConnection::Get());
}
@@ -57,7 +72,9 @@ void MojoShellConnectionImpl::BindToMessagePipe(
WaitForShell(std::move(handle));
}
-MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {}
+MojoShellConnectionImpl::MojoShellConnectionImpl(bool external) :
+ external_(external), initialized_(false) {}
+
MojoShellConnectionImpl::~MojoShellConnectionImpl() {
STLDeleteElements(&listeners_);
}
@@ -66,7 +83,12 @@ void MojoShellConnectionImpl::WaitForShell(
mojo::ScopedMessagePipeHandle handle) {
mojo::shell::mojom::ShellClientRequest request;
runner_connection_.reset(mojo::shell::RunnerConnection::ConnectToRunner(
- &request, std::move(handle)));
+ &request, std::move(handle), false /* exit_on_error */));
+ if (!runner_connection_) {
+ delete this;
+ lazy_tls_ptr.Pointer()->Set(nullptr);
+ return;
+ }
shell_connection_.reset(new mojo::ShellConnection(this, std::move(request)));
shell_connection_->WaitForInitialize();
}
@@ -91,7 +113,7 @@ mojo::Shell* MojoShellConnectionImpl::GetShell() {
}
bool MojoShellConnectionImpl::UsingExternalShell() const {
- return true;
+ return external_;
}
void MojoShellConnectionImpl::AddListener(Listener* listener) {
« no previous file with comments | « content/common/mojo/mojo_shell_connection_impl.h ('k') | content/common/url_schemes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698