| 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 "services/service_manager/public/cpp/lib/connector_impl.h" | 5 #include "services/service_manager/public/cpp/lib/connector_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "services/service_manager/public/cpp/identity.h" | 8 #include "services/service_manager/public/cpp/identity.h" |
| 9 #include "services/service_manager/public/cpp/lib/connection_impl.h" | 9 #include "services/service_manager/public/cpp/lib/connection_impl.h" |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 std::unique_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) { | 44 std::unique_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) { |
| 45 if (!BindIfNecessary()) | 45 if (!BindIfNecessary()) |
| 46 return nullptr; | 46 return nullptr; |
| 47 | 47 |
| 48 DCHECK(thread_checker_.CalledOnValidThread()); | 48 DCHECK(thread_checker_.CalledOnValidThread()); |
| 49 DCHECK(params); | 49 DCHECK(params); |
| 50 | 50 |
| 51 mojom::InterfaceProviderPtr remote_interfaces; | 51 mojom::InterfaceProviderPtr remote_interfaces; |
| 52 mojom::InterfaceProviderRequest remote_request = | 52 mojom::InterfaceProviderRequest remote_request(&remote_interfaces); |
| 53 MakeRequest(&remote_interfaces); | |
| 54 std::unique_ptr<internal::ConnectionImpl> connection( | 53 std::unique_ptr<internal::ConnectionImpl> connection( |
| 55 new internal::ConnectionImpl(params->target(), | 54 new internal::ConnectionImpl(params->target(), |
| 56 Connection::State::PENDING)); | 55 Connection::State::PENDING)); |
| 57 if (params->remote_interfaces()) { | 56 if (params->remote_interfaces()) { |
| 58 params->remote_interfaces()->Bind(std::move(remote_interfaces)); | 57 params->remote_interfaces()->Bind(std::move(remote_interfaces)); |
| 59 connection->set_remote_interfaces(params->remote_interfaces()); | 58 connection->set_remote_interfaces(params->remote_interfaces()); |
| 60 } else { | 59 } else { |
| 61 std::unique_ptr<InterfaceProvider> remote_interface_provider( | 60 std::unique_ptr<InterfaceProvider> remote_interface_provider( |
| 62 new InterfaceProvider); | 61 new InterfaceProvider); |
| 63 remote_interface_provider->Bind(std::move(remote_interfaces)); | 62 remote_interface_provider->Bind(std::move(remote_interfaces)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 83 std::move(client_process_connection), | 82 std::move(client_process_connection), |
| 84 connection->GetConnectCallback()); | 83 connection->GetConnectCallback()); |
| 85 return std::move(connection); | 84 return std::move(connection); |
| 86 } | 85 } |
| 87 | 86 |
| 88 std::unique_ptr<Connector> ConnectorImpl::Clone() { | 87 std::unique_ptr<Connector> ConnectorImpl::Clone() { |
| 89 if (!BindIfNecessary()) | 88 if (!BindIfNecessary()) |
| 90 return nullptr; | 89 return nullptr; |
| 91 | 90 |
| 92 mojom::ConnectorPtr connector; | 91 mojom::ConnectorPtr connector; |
| 93 mojom::ConnectorRequest request = MakeRequest(&connector); | 92 mojom::ConnectorRequest request(&connector); |
| 94 connector_->Clone(std::move(request)); | 93 connector_->Clone(std::move(request)); |
| 95 return base::MakeUnique<ConnectorImpl>(connector.PassInterface()); | 94 return base::MakeUnique<ConnectorImpl>(connector.PassInterface()); |
| 96 } | 95 } |
| 97 | 96 |
| 98 void ConnectorImpl::BindRequest(mojom::ConnectorRequest request) { | 97 void ConnectorImpl::BindRequest(mojom::ConnectorRequest request) { |
| 99 if (!BindIfNecessary()) | 98 if (!BindIfNecessary()) |
| 100 return; | 99 return; |
| 101 connector_->Clone(std::move(request)); | 100 connector_->Clone(std::move(request)); |
| 102 } | 101 } |
| 103 | 102 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 124 return true; | 123 return true; |
| 125 } | 124 } |
| 126 | 125 |
| 127 std::unique_ptr<Connector> Connector::Create(mojom::ConnectorRequest* request) { | 126 std::unique_ptr<Connector> Connector::Create(mojom::ConnectorRequest* request) { |
| 128 mojom::ConnectorPtr proxy; | 127 mojom::ConnectorPtr proxy; |
| 129 *request = mojo::MakeRequest(&proxy); | 128 *request = mojo::MakeRequest(&proxy); |
| 130 return base::MakeUnique<ConnectorImpl>(proxy.PassInterface()); | 129 return base::MakeUnique<ConnectorImpl>(proxy.PassInterface()); |
| 131 } | 130 } |
| 132 | 131 |
| 133 } // namespace service_manager | 132 } // namespace service_manager |
| OLD | NEW |