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

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: Don't create a RenderWidgetWindowTreeeClientFactory in tests 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..3c0714d2027f918224e4fbc4c19da46658632249 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,34 @@ bool IsRunningInMojoShell() {
// static
void MojoShellConnectionImpl::Create() {
- DCHECK(IsRunningInMojoShell());
- CreateWithMessagePipe(mojo::ScopedMessagePipeHandle());
+ DCHECK(!lazy_tls_ptr.Pointer()->Get());
+ MojoShellConnectionImpl* connection = new MojoShellConnectionImpl;
+ lazy_tls_ptr.Pointer()->Set(connection);
}
// static
-void MojoShellConnectionImpl::CreateWithMessagePipe(
+MojoShellConnectionImpl* MojoShellConnectionImpl::Get() {
+ return static_cast<MojoShellConnectionImpl*>(MojoShellConnection::Get());
+}
+
+void MojoShellConnectionImpl::BindToCommandLinePlatformChannel() {
+ DCHECK(IsRunningInMojoShell());
+ if (initialized_)
+ return;
+ WaitForShell(mojo::ScopedMessagePipeHandle());
+}
+
+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