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 // |
| 22 // This is analogous to shell::InterfaceProvider in that it provides a means of |
| 23 // binding proxies to remote interfaces, but this is specifically for interfaces |
| 24 // which must be assocaited with an IPC::Channel, i.e. retain FIFO message |
| 25 // ordering with respect to legacy IPC messages. |
| 26 // |
| 27 // The Channel with which the remote interfaces are associated depends on |
| 28 // the configuration of the specific AssociatedInterfaceProvider instance. For |
| 29 // example, RenderFrameHost exposes an instance of this class for which all |
| 30 // interfaces are associted with the IPC::ChannelProxy to the render process |
| 31 // which hosts its corresponding RenderFrame. |
| 32 class AssociatedInterfaceProvider { |
| 33 public: |
| 34 virtual ~AssociatedInterfaceProvider() {} |
| 35 |
| 36 // Passes an associated endpoint handle to the remote end to be bound to a |
| 37 // Channel-associated interface named |name|. |
| 38 virtual void GetInterface(const std::string& name, |
| 39 mojo::ScopedInterfaceEndpointHandle handle) = 0; |
| 40 |
| 41 // Returns an AssociatedGroup for the provider. This may be used to create |
| 42 // new associated endpoints for use with Channel-associated interfaces. |
| 43 virtual mojo::AssociatedGroup* GetAssociatedGroup() = 0; |
| 44 |
| 45 // Templated helper for GetInterface(). |
| 46 template <typename Interface> |
| 47 void GetInterface(mojo::AssociatedInterfacePtr<Interface>* proxy) { |
| 48 mojo::AssociatedInterfaceRequest<Interface> request = |
| 49 mojo::GetProxy(proxy, GetAssociatedGroup()); |
| 50 GetInterface(Interface::Name_, request.PassHandle()); |
| 51 } |
| 52 }; |
| 53 |
| 54 } // namespace content |
| 55 |
| 56 #endif // CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ |
OLD | NEW |