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

Unified Diff: content/common/mojo/mojo_shell_connection_impl.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: Added comment on RenderWidgetWindowTreeClientFactory lifetime 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/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 25c8be1c0e7eae4a06dcdab0f5bbb078502246f2..d1fd3abfb53c375291bcbab5166f3997f37884bc 100644
--- a/content/common/mojo/mojo_shell_connection_impl.cc
+++ b/content/common/mojo/mojo_shell_connection_impl.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
+#include "base/stl_util.h"
#include "base/threading/thread_local.h"
#include "mojo/application/public/cpp/application_delegate.h"
#include "mojo/application/public/cpp/application_impl.h"
@@ -30,21 +31,29 @@ bool IsRunningInMojoShell() {
// static
void MojoShellConnectionImpl::Create() {
+ DCHECK(!lazy_tls_ptr.Pointer()->Get());
+ MojoShellConnectionImpl* connection = new MojoShellConnectionImpl;
+ lazy_tls_ptr.Pointer()->Set(connection);
+}
+
+void MojoShellConnectionImpl::BindToCommandLinePlatformChannel() {
DCHECK(IsRunningInMojoShell());
- CreateWithMessagePipe(mojo::ScopedMessagePipeHandle());
+ if (initialized_)
+ return;
+ WaitForShell(mojo::ScopedMessagePipeHandle());
}
-// static
-void MojoShellConnectionImpl::CreateWithMessagePipe(
+void MojoShellConnectionImpl::BindToMessagePipe(
mojo::ScopedMessagePipeHandle handle) {
- DCHECK(!lazy_tls_ptr.Pointer()->Get());
- MojoShellConnectionImpl* connection = new MojoShellConnectionImpl;
- lazy_tls_ptr.Pointer()->Set(connection);
- connection->WaitForShell(handle.Pass());
+ if (initialized_)
+ return;
+ WaitForShell(handle.Pass());
}
MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {}
-MojoShellConnectionImpl::~MojoShellConnectionImpl() {}
+MojoShellConnectionImpl::~MojoShellConnectionImpl() {
+ STLDeleteElements(&listeners_);
+}
void MojoShellConnectionImpl::WaitForShell(
mojo::ScopedMessagePipeHandle handle) {

Powered by Google App Engine
This is Rietveld 408576698