| 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 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_ |
| 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_ | 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "services/service_manager/public/cpp/connection.h" | 10 #include "services/service_manager/public/cpp/connection.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 mojo::InterfacePtr<Interface>* ptr) { | 62 mojo::InterfacePtr<Interface>* ptr) { |
| 63 mojo::MessagePipe pipe; | 63 mojo::MessagePipe pipe; |
| 64 ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); | 64 ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); |
| 65 BindInterface(target, Interface::Name_, std::move(pipe.handle1)); | 65 BindInterface(target, Interface::Name_, std::move(pipe.handle1)); |
| 66 } | 66 } |
| 67 template <typename Interface> | 67 template <typename Interface> |
| 68 void BindInterface(const std::string& name, | 68 void BindInterface(const std::string& name, |
| 69 mojo::InterfacePtr<Interface>* ptr) { | 69 mojo::InterfacePtr<Interface>* ptr) { |
| 70 return BindInterface(Identity(name, mojom::kInheritUserID), ptr); | 70 return BindInterface(Identity(name, mojom::kInheritUserID), ptr); |
| 71 } | 71 } |
| 72 template <typename Interface> | |
| 73 void BindInterface(const std::string& name, | |
| 74 mojo::InterfaceRequest<Interface> request) { | |
| 75 return BindInterface(Identity(name, mojom::kInheritUserID), | |
| 76 Interface::Name_, request.PassMessagePipe()); | |
| 77 } | |
| 78 virtual void BindInterface(const Identity& target, | 72 virtual void BindInterface(const Identity& target, |
| 79 const std::string& interface_name, | 73 const std::string& interface_name, |
| 80 mojo::ScopedMessagePipeHandle interface_pipe) = 0; | 74 mojo::ScopedMessagePipeHandle interface_pipe) = 0; |
| 81 | 75 |
| 82 // Creates a new instance of this class which may be passed to another thread. | 76 // Creates a new instance of this class which may be passed to another thread. |
| 83 // The returned object may be passed multiple times until Connect() is called, | 77 // The returned object may be passed multiple times until Connect() is called, |
| 84 // at which point this method must be called again to pass again. | 78 // at which point this method must be called again to pass again. |
| 85 virtual std::unique_ptr<Connector> Clone() = 0; | 79 virtual std::unique_ptr<Connector> Clone() = 0; |
| 86 | 80 |
| 87 // Binds a Connector request to the other end of this Connector. | 81 // Binds a Connector request to the other end of this Connector. |
| 88 virtual void BindConnectorRequest(mojom::ConnectorRequest request) = 0; | 82 virtual void BindConnectorRequest(mojom::ConnectorRequest request) = 0; |
| 89 }; | 83 }; |
| 90 | 84 |
| 91 } // namespace service_manager | 85 } // namespace service_manager |
| 92 | 86 |
| 93 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_ | 87 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_CONNECTOR_H_ |
| OLD | NEW |