| 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" |
| 11 #include "content/common/mojo/embedded_application_runner.h" | 11 #include "content/common/mojo/embedded_application_runner.h" |
| 12 #include "services/shell/public/cpp/service.h" | 12 #include "services/shell/public/cpp/service.h" |
| 13 #include "services/shell/public/cpp/shell_connection.h" | 13 #include "services/shell/public/cpp/service_context.h" |
| 14 #include "services/shell/runner/common/client_util.h" | 14 #include "services/shell/runner/common/client_util.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 using MojoShellConnectionPtr = | 19 using MojoShellConnectionPtr = |
| 20 base::ThreadLocalPointer<MojoShellConnection>; | 20 base::ThreadLocalPointer<MojoShellConnection>; |
| 21 | 21 |
| 22 // Env is thread local so that aura may be used on multiple threads. | 22 // Env is thread local so that aura may be used on multiple threads. |
| 23 base::LazyInstance<MojoShellConnectionPtr>::Leaky lazy_tls_ptr = | 23 base::LazyInstance<MojoShellConnectionPtr>::Leaky lazy_tls_ptr = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 return base::WrapUnique(new MojoShellConnectionImpl(std::move(request))); | 63 return base::WrapUnique(new MojoShellConnectionImpl(std::move(request))); |
| 64 } | 64 } |
| 65 | 65 |
| 66 MojoShellConnection::~MojoShellConnection() {} | 66 MojoShellConnection::~MojoShellConnection() {} |
| 67 | 67 |
| 68 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
| 69 // MojoShellConnectionImpl, public: | 69 // MojoShellConnectionImpl, public: |
| 70 | 70 |
| 71 MojoShellConnectionImpl::MojoShellConnectionImpl( | 71 MojoShellConnectionImpl::MojoShellConnectionImpl( |
| 72 shell::mojom::ServiceRequest request) | 72 shell::mojom::ServiceRequest request) |
| 73 : shell_connection_(new shell::ShellConnection(this, std::move(request))) {} | 73 : shell_connection_(new shell::ServiceContext(this, std::move(request))) {} |
| 74 | 74 |
| 75 MojoShellConnectionImpl::~MojoShellConnectionImpl() {} | 75 MojoShellConnectionImpl::~MojoShellConnectionImpl() {} |
| 76 | 76 |
| 77 //////////////////////////////////////////////////////////////////////////////// | 77 //////////////////////////////////////////////////////////////////////////////// |
| 78 // MojoShellConnectionImpl, shell::Service implementation: | 78 // MojoShellConnectionImpl, shell::Service implementation: |
| 79 | 79 |
| 80 void MojoShellConnectionImpl::OnStart(shell::Connector* connector, | 80 void MojoShellConnectionImpl::OnStart(shell::Connector* connector, |
| 81 const shell::Identity& identity, | 81 const shell::Identity& identity, |
| 82 uint32_t id) { | 82 uint32_t id) { |
| 83 for (auto& client : embedded_services_) | 83 for (auto& client : embedded_services_) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 shell::mojom::ServiceRequest request, | 143 shell::mojom::ServiceRequest request, |
| 144 const mojo::String& name) { | 144 const mojo::String& name) { |
| 145 auto it = request_handlers_.find(name); | 145 auto it = request_handlers_.find(name); |
| 146 if (it != request_handlers_.end()) | 146 if (it != request_handlers_.end()) |
| 147 it->second.Run(std::move(request)); | 147 it->second.Run(std::move(request)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 //////////////////////////////////////////////////////////////////////////////// | 150 //////////////////////////////////////////////////////////////////////////////// |
| 151 // MojoShellConnectionImpl, MojoShellConnection implementation: | 151 // MojoShellConnectionImpl, MojoShellConnection implementation: |
| 152 | 152 |
| 153 shell::ShellConnection* MojoShellConnectionImpl::GetShellConnection() { | 153 shell::ServiceContext* MojoShellConnectionImpl::GetShellConnection() { |
| 154 return shell_connection_.get(); | 154 return shell_connection_.get(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 shell::Connector* MojoShellConnectionImpl::GetConnector() { | 157 shell::Connector* MojoShellConnectionImpl::GetConnector() { |
| 158 DCHECK(shell_connection_); | 158 DCHECK(shell_connection_); |
| 159 return shell_connection_->connector(); | 159 return shell_connection_->connector(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 const shell::Identity& MojoShellConnectionImpl::GetIdentity() const { | 162 const shell::Identity& MojoShellConnectionImpl::GetIdentity() const { |
| 163 DCHECK(shell_connection_); | 163 DCHECK(shell_connection_); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 193 } | 193 } |
| 194 | 194 |
| 195 void MojoShellConnectionImpl::AddServiceRequestHandler( | 195 void MojoShellConnectionImpl::AddServiceRequestHandler( |
| 196 const std::string& name, | 196 const std::string& name, |
| 197 const ServiceRequestHandler& handler) { | 197 const ServiceRequestHandler& handler) { |
| 198 auto result = request_handlers_.insert(std::make_pair(name, handler)); | 198 auto result = request_handlers_.insert(std::make_pair(name, handler)); |
| 199 DCHECK(result.second); | 199 DCHECK(result.second); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace content | 202 } // namespace content |
| OLD | NEW |