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/shell/public/cpp/lib/connector_impl.h" | 5 #include "services/shell/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/shell/public/cpp/identity.h" | 8 #include "services/shell/public/cpp/identity.h" |
9 #include "services/shell/public/cpp/lib/connection_impl.h" | 9 #include "services/shell/public/cpp/lib/connection_impl.h" |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // a position to know who we're talking to. | 53 // a position to know who we're talking to. |
54 CapabilityRequest request; | 54 CapabilityRequest request; |
55 request.interfaces.insert("*"); | 55 request.interfaces.insert("*"); |
56 mojom::InterfaceProviderPtr local_interfaces; | 56 mojom::InterfaceProviderPtr local_interfaces; |
57 mojom::InterfaceProviderRequest local_request = GetProxy(&local_interfaces); | 57 mojom::InterfaceProviderRequest local_request = GetProxy(&local_interfaces); |
58 mojom::InterfaceProviderPtr remote_interfaces; | 58 mojom::InterfaceProviderPtr remote_interfaces; |
59 mojom::InterfaceProviderRequest remote_request = GetProxy(&remote_interfaces); | 59 mojom::InterfaceProviderRequest remote_request = GetProxy(&remote_interfaces); |
60 std::unique_ptr<internal::ConnectionImpl> registry( | 60 std::unique_ptr<internal::ConnectionImpl> registry( |
61 new internal::ConnectionImpl( | 61 new internal::ConnectionImpl( |
62 params->target().name(), params->target(), mojom::kInvalidInstanceID, | 62 params->target().name(), params->target(), mojom::kInvalidInstanceID, |
63 std::move(remote_interfaces), std::move(local_request), request, | 63 request, Connection::State::PENDING)); |
64 Connection::State::PENDING)); | 64 if (params->exposed_interfaces()) { |
| 65 params->exposed_interfaces()->Bind(std::move(local_request)); |
| 66 registry->set_exposed_interfaces(params->exposed_interfaces()); |
| 67 } else { |
| 68 std::unique_ptr<InterfaceRegistry> exposed_interfaces( |
| 69 new InterfaceRegistry(registry.get())); |
| 70 exposed_interfaces->Bind(std::move(local_request)); |
| 71 registry->SetExposedInterfaces(std::move(exposed_interfaces)); |
| 72 } |
| 73 if (params->remote_interfaces()) { |
| 74 params->remote_interfaces()->Bind(std::move(remote_interfaces)); |
| 75 registry->set_remote_interfaces(params->remote_interfaces()); |
| 76 } else { |
| 77 std::unique_ptr<InterfaceProvider> remote_interface_provider( |
| 78 new InterfaceProvider); |
| 79 remote_interface_provider->Bind(std::move(remote_interfaces)); |
| 80 registry->SetRemoteInterfaces(std::move(remote_interface_provider)); |
| 81 } |
65 | 82 |
66 mojom::ShellClientPtr shell_client; | 83 mojom::ShellClientPtr shell_client; |
67 mojom::PIDReceiverRequest pid_receiver_request; | 84 mojom::PIDReceiverRequest pid_receiver_request; |
68 params->TakeClientProcessConnection(&shell_client, &pid_receiver_request); | 85 params->TakeClientProcessConnection(&shell_client, &pid_receiver_request); |
69 mojom::ClientProcessConnectionPtr client_process_connection; | 86 mojom::ClientProcessConnectionPtr client_process_connection; |
70 if (shell_client.is_bound() && pid_receiver_request.is_pending()) { | 87 if (shell_client.is_bound() && pid_receiver_request.is_pending()) { |
71 client_process_connection = mojom::ClientProcessConnection::New(); | 88 client_process_connection = mojom::ClientProcessConnection::New(); |
72 client_process_connection->shell_client = | 89 client_process_connection->shell_client = |
73 shell_client.PassInterface().PassHandle(); | 90 shell_client.PassInterface().PassHandle(); |
74 client_process_connection->pid_receiver_request = | 91 client_process_connection->pid_receiver_request = |
(...skipping 10 matching lines...) Expand all Loading... |
85 return std::move(registry); | 102 return std::move(registry); |
86 } | 103 } |
87 | 104 |
88 std::unique_ptr<Connector> ConnectorImpl::Clone() { | 105 std::unique_ptr<Connector> ConnectorImpl::Clone() { |
89 mojom::ConnectorPtr connector; | 106 mojom::ConnectorPtr connector; |
90 connector_->Clone(GetProxy(&connector)); | 107 connector_->Clone(GetProxy(&connector)); |
91 return base::WrapUnique(new ConnectorImpl(connector.PassInterface())); | 108 return base::WrapUnique(new ConnectorImpl(connector.PassInterface())); |
92 } | 109 } |
93 | 110 |
94 } // namespace shell | 111 } // namespace shell |
OLD | NEW |