OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| 11 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
| 12 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
| 13 |
| 14 namespace mojo { |
| 15 class AssociatedGroup; |
| 16 } |
| 17 |
| 18 namespace content { |
| 19 |
| 20 // A helper interface for connecting to remote Channel-associated interfaces. |
| 21 class AssociatedInterfaceProvider { |
| 22 public: |
| 23 virtual ~AssociatedInterfaceProvider() {} |
| 24 |
| 25 // Passes an associated endpoint handle to the remote end to be bound to a |
| 26 // Channel-associated interface named |name|. |
| 27 virtual void GetInterface(const std::string& name, |
| 28 mojo::ScopedInterfaceEndpointHandle handle) = 0; |
| 29 |
| 30 // Returns an AssociatedGroup for the provider. This may be used to create |
| 31 // new associated endpoints for use with Channel-associated interfaces. |
| 32 virtual mojo::AssociatedGroup* GetAssociatedGroup() = 0; |
| 33 |
| 34 // Templated helper for GetInterface(). |
| 35 template <typename Interface> |
| 36 void GetInterface(mojo::AssociatedInterfacePtr<Interface>* proxy) { |
| 37 mojo::AssociatedInterfaceRequest<Interface> request = |
| 38 mojo::GetProxy(proxy, GetAssociatedGroup()); |
| 39 GetInterface(Interface::Name_, request.PassHandle()); |
| 40 } |
| 41 }; |
| 42 |
| 43 } // namespace content |
| 44 |
| 45 #endif // CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ |
OLD | NEW |