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 CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ |
6 #define CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ | 6 #define CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 10 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 // which must be assocaited with an IPC::Channel, i.e. retain FIFO message | 24 // which must be assocaited with an IPC::Channel, i.e. retain FIFO message |
25 // ordering with respect to legacy IPC messages. | 25 // ordering with respect to legacy IPC messages. |
26 // | 26 // |
27 // The Channel with which the remote interfaces are associated depends on | 27 // The Channel with which the remote interfaces are associated depends on |
28 // the configuration of the specific AssociatedInterfaceProvider instance. For | 28 // the configuration of the specific AssociatedInterfaceProvider instance. For |
29 // example, RenderFrameHost exposes an instance of this class for which all | 29 // example, RenderFrameHost exposes an instance of this class for which all |
30 // interfaces are associted with the IPC::ChannelProxy to the render process | 30 // interfaces are associted with the IPC::ChannelProxy to the render process |
31 // which hosts its corresponding RenderFrame. | 31 // which hosts its corresponding RenderFrame. |
32 class AssociatedInterfaceProvider { | 32 class AssociatedInterfaceProvider { |
33 public: | 33 public: |
34 class TestApi { | |
Ken Rockot(use gerrit already)
2016/09/20 18:26:20
I don't think we need to emulate what's done in In
leonhsl(Using Gerrit)
2016/09/21 11:46:57
Done and thanks!
| |
35 public: | |
36 explicit TestApi(AssociatedInterfaceProvider* provider) | |
37 : provider_(provider) {} | |
38 ~TestApi() {} | |
39 | |
40 void SetBinderForName(const std::string& name, | |
41 const base::Callback<void( | |
42 mojo::ScopedInterfaceEndpointHandle)>& binder) { | |
43 provider_->SetBinderForName(name, binder); | |
44 } | |
45 | |
46 void ClearBinders() { provider_->ClearBinders(); } | |
47 | |
48 private: | |
49 AssociatedInterfaceProvider* provider_; | |
50 DISALLOW_COPY_AND_ASSIGN(TestApi); | |
51 }; | |
52 | |
34 virtual ~AssociatedInterfaceProvider() {} | 53 virtual ~AssociatedInterfaceProvider() {} |
35 | 54 |
36 // Passes an associated endpoint handle to the remote end to be bound to a | 55 // Passes an associated endpoint handle to the remote end to be bound to a |
37 // Channel-associated interface named |name|. | 56 // Channel-associated interface named |name|. |
38 virtual void GetInterface(const std::string& name, | 57 virtual void GetInterface(const std::string& name, |
39 mojo::ScopedInterfaceEndpointHandle handle) = 0; | 58 mojo::ScopedInterfaceEndpointHandle handle) = 0; |
40 | 59 |
41 // Returns an AssociatedGroup for the provider. This may be used to create | 60 // Returns an AssociatedGroup for the provider. This may be used to create |
42 // new associated endpoints for use with Channel-associated interfaces. | 61 // new associated endpoints for use with Channel-associated interfaces. |
43 virtual mojo::AssociatedGroup* GetAssociatedGroup() = 0; | 62 virtual mojo::AssociatedGroup* GetAssociatedGroup() = 0; |
44 | 63 |
45 // Templated helper for GetInterface(). | 64 // Templated helper for GetInterface(). |
46 template <typename Interface> | 65 template <typename Interface> |
47 void GetInterface(mojo::AssociatedInterfacePtr<Interface>* proxy) { | 66 void GetInterface(mojo::AssociatedInterfacePtr<Interface>* proxy) { |
48 mojo::AssociatedInterfaceRequest<Interface> request = | 67 mojo::AssociatedInterfaceRequest<Interface> request = |
49 mojo::GetProxy(proxy, GetAssociatedGroup()); | 68 mojo::GetProxy(proxy, GetAssociatedGroup()); |
50 GetInterface(Interface::Name_, request.PassHandle()); | 69 GetInterface(Interface::Name_, request.PassHandle()); |
51 } | 70 } |
71 | |
72 private: | |
73 virtual void SetBinderForName( | |
74 const std::string& name, | |
75 const base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>& | |
76 binder) = 0; | |
77 virtual void ClearBinders() = 0; | |
52 }; | 78 }; |
53 | 79 |
54 } // namespace content | 80 } // namespace content |
55 | 81 |
56 #endif // CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ | 82 #endif // CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_PROVIDER_H_ |
OLD | NEW |