| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return shell_connection_->identity(); | 138 return shell_connection_->identity(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void MojoShellConnectionImpl::SetConnectionLostClosure( | 141 void MojoShellConnectionImpl::SetConnectionLostClosure( |
| 142 const base::Closure& closure) { | 142 const base::Closure& closure) { |
| 143 shell_connection_->SetConnectionLostClosure(closure); | 143 shell_connection_->SetConnectionLostClosure(closure); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void MojoShellConnectionImpl::AddEmbeddedShellClient( | 146 void MojoShellConnectionImpl::AddEmbeddedShellClient( |
| 147 std::unique_ptr<shell::ShellClient> shell_client) { | 147 std::unique_ptr<shell::ShellClient> shell_client) { |
| 148 embedded_shell_clients_.push_back(std::move(shell_client)); | 148 embedded_shell_clients_.push_back(shell_client.get()); |
| 149 owned_shell_clients_.push_back(std::move(shell_client)); |
| 150 } |
| 151 |
| 152 void MojoShellConnectionImpl::AddEmbeddedShellClient( |
| 153 shell::ShellClient* shell_client) { |
| 154 embedded_shell_clients_.push_back(shell_client); |
| 149 } | 155 } |
| 150 | 156 |
| 151 void MojoShellConnectionImpl::AddEmbeddedService( | 157 void MojoShellConnectionImpl::AddEmbeddedService( |
| 152 const std::string& name, | 158 const std::string& name, |
| 153 const MojoApplicationInfo& info) { | 159 const MojoApplicationInfo& info) { |
| 154 std::unique_ptr<EmbeddedApplicationRunner> app( | 160 std::unique_ptr<EmbeddedApplicationRunner> app( |
| 155 new EmbeddedApplicationRunner(name, info)); | 161 new EmbeddedApplicationRunner(name, info)); |
| 156 AddShellClientRequestHandler( | 162 AddShellClientRequestHandler( |
| 157 name, base::Bind(&EmbeddedApplicationRunner::BindShellClientRequest, | 163 name, base::Bind(&EmbeddedApplicationRunner::BindShellClientRequest, |
| 158 base::Unretained(app.get()))); | 164 base::Unretained(app.get()))); |
| 159 auto result = embedded_apps_.insert(std::make_pair(name, std::move(app))); | 165 auto result = embedded_apps_.insert(std::make_pair(name, std::move(app))); |
| 160 DCHECK(result.second); | 166 DCHECK(result.second); |
| 161 } | 167 } |
| 162 | 168 |
| 163 void MojoShellConnectionImpl::AddShellClientRequestHandler( | 169 void MojoShellConnectionImpl::AddShellClientRequestHandler( |
| 164 const std::string& name, | 170 const std::string& name, |
| 165 const ShellClientRequestHandler& handler) { | 171 const ShellClientRequestHandler& handler) { |
| 166 auto result = request_handlers_.insert(std::make_pair(name, handler)); | 172 auto result = request_handlers_.insert(std::make_pair(name, handler)); |
| 167 DCHECK(result.second); | 173 DCHECK(result.second); |
| 168 } | 174 } |
| 169 | 175 |
| 170 } // namespace content | 176 } // namespace content |
| OLD | NEW |