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

Side by Side Diff: content/common/mojo/mojo_shell_connection_impl.cc

Issue 1461243002: [OLD ATTEMPT, DO NOT REVIEW] mustash: Enable connections to mus from the Chrome renderer Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A bunch of cleanup Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/mojo/mojo_shell_connection_impl.h" 5 #include "content/common/mojo/mojo_shell_connection_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/process/process_handle.h"
Ben Goodger (Google) 2015/11/24 06:42:40 ??
Fady Samuel 2015/11/24 13:32:06 Done.
9 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
10 #include "mojo/application/public/cpp/application_delegate.h" 11 #include "mojo/application/public/cpp/application_delegate.h"
11 #include "mojo/application/public/cpp/application_impl.h" 12 #include "mojo/application/public/cpp/application_impl.h"
12 #include "mojo/converters/network/network_type_converters.h" 13 #include "mojo/converters/network/network_type_converters.h"
13 #include "mojo/runner/child/runner_connection.h" 14 #include "mojo/runner/child/runner_connection.h"
14 15
15 namespace content { 16 namespace content {
16 namespace { 17 namespace {
17 using MojoShellConnectionPtr = 18 using MojoShellConnectionPtr =
18 base::ThreadLocalPointer<MojoShellConnectionImpl>; 19 base::ThreadLocalPointer<MojoShellConnectionImpl>;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 listeners_.end()); 79 listeners_.end());
79 listeners_.push_back(listener); 80 listeners_.push_back(listener);
80 } 81 }
81 82
82 void MojoShellConnectionImpl::RemoveListener(Listener* listener) { 83 void MojoShellConnectionImpl::RemoveListener(Listener* listener) {
83 auto it = std::find(listeners_.begin(), listeners_.end(), listener); 84 auto it = std::find(listeners_.begin(), listeners_.end(), listener);
84 DCHECK(it != listeners_.end()); 85 DCHECK(it != listeners_.end());
85 listeners_.erase(it); 86 listeners_.erase(it);
86 } 87 }
87 88
89 void MojoShellConnectionImpl::OnDestroy() {
90 for (auto listener : listeners_)
91 listener->OnDestroy();
92 }
93
88 // static 94 // static
89 MojoShellConnection* MojoShellConnection::Get() { 95 MojoShellConnection* MojoShellConnection::Get() {
90 return lazy_tls_ptr.Pointer()->Get(); 96 return lazy_tls_ptr.Pointer()->Get();
91 } 97 }
92 98
93 // static 99 // static
94 void MojoShellConnection::Destroy() { 100 void MojoShellConnection::Destroy() {
101 static_cast<MojoShellConnectionImpl*>(Get())->OnDestroy();
Ben Goodger (Google) 2015/11/24 06:42:40 can this be done in ~MojoShellConnectionImpl?
Fady Samuel 2015/11/24 13:32:06 Done.
95 // This joins the shell controller thread. 102 // This joins the shell controller thread.
96 delete Get(); 103 delete Get();
97 lazy_tls_ptr.Pointer()->Set(nullptr); 104 lazy_tls_ptr.Pointer()->Set(nullptr);
98 } 105 }
99 106
100 MojoShellConnection::~MojoShellConnection() {} 107 MojoShellConnection::~MojoShellConnection() {}
101 108
102 } // namespace content 109 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698