| OLD | NEW |
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 mojo::Connector* MojoShellConnectionImpl::GetConnector() { | 129 mojo::Connector* MojoShellConnectionImpl::GetConnector() { |
| 130 DCHECK(shell_connection_); | 130 DCHECK(shell_connection_); |
| 131 return shell_connection_->connector(); | 131 return shell_connection_->connector(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool MojoShellConnectionImpl::UsingExternalShell() const { | 134 bool MojoShellConnectionImpl::UsingExternalShell() const { |
| 135 return external_; | 135 return external_; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void MojoShellConnectionImpl::SetConnectionLostClosure( |
| 139 const base::Closure& closure) { |
| 140 shell_connection_->set_connection_lost_closure(closure); |
| 141 } |
| 142 |
| 138 void MojoShellConnectionImpl::AddListener(Listener* listener) { | 143 void MojoShellConnectionImpl::AddListener(Listener* listener) { |
| 139 DCHECK(std::find(listeners_.begin(), listeners_.end(), listener) == | 144 DCHECK(std::find(listeners_.begin(), listeners_.end(), listener) == |
| 140 listeners_.end()); | 145 listeners_.end()); |
| 141 listeners_.push_back(listener); | 146 listeners_.push_back(listener); |
| 142 } | 147 } |
| 143 | 148 |
| 144 void MojoShellConnectionImpl::RemoveListener(Listener* listener) { | 149 void MojoShellConnectionImpl::RemoveListener(Listener* listener) { |
| 145 auto it = std::find(listeners_.begin(), listeners_.end(), listener); | 150 auto it = std::find(listeners_.begin(), listeners_.end(), listener); |
| 146 DCHECK(it != listeners_.end()); | 151 DCHECK(it != listeners_.end()); |
| 147 listeners_.erase(it); | 152 listeners_.erase(it); |
| 148 } | 153 } |
| 149 | 154 |
| 150 // static | 155 // static |
| 151 MojoShellConnection* MojoShellConnection::Get() { | 156 MojoShellConnection* MojoShellConnection::Get() { |
| 152 return lazy_tls_ptr.Pointer()->Get(); | 157 return lazy_tls_ptr.Pointer()->Get(); |
| 153 } | 158 } |
| 154 | 159 |
| 155 // static | 160 // static |
| 156 void MojoShellConnection::Destroy() { | 161 void MojoShellConnection::Destroy() { |
| 157 // This joins the shell controller thread. | 162 // This joins the shell controller thread. |
| 158 delete Get(); | 163 delete Get(); |
| 159 lazy_tls_ptr.Pointer()->Set(nullptr); | 164 lazy_tls_ptr.Pointer()->Set(nullptr); |
| 160 } | 165 } |
| 161 | 166 |
| 162 MojoShellConnection::~MojoShellConnection() {} | 167 MojoShellConnection::~MojoShellConnection() {} |
| 163 | 168 |
| 164 } // namespace content | 169 } // namespace content |
| OLD | NEW |