OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
7 | 7 |
8 #include "mojo/public/cpp/bindings/interface_ptr.h" | 8 #include "mojo/public/cpp/bindings/interface_ptr.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // | 100 // |
101 // The client would have code similar to the following: | 101 // The client would have code similar to the following: |
102 // | 102 // |
103 // CollectorPtr collector = ...; // Connect to Collector. | 103 // CollectorPtr collector = ...; // Connect to Collector. |
104 // SourcePtr source; | 104 // SourcePtr source; |
105 // InterfaceRequest<Source> source_request = GetProxy(&source); | 105 // InterfaceRequest<Source> source_request = GetProxy(&source); |
106 // collector->RegisterSource(source.Pass()); | 106 // collector->RegisterSource(source.Pass()); |
107 // CreateSource(source_request.Pass()); // Create implementation locally. | 107 // CreateSource(source_request.Pass()); // Create implementation locally. |
108 // | 108 // |
109 template <typename Interface> | 109 template <typename Interface> |
110 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { | 110 InterfaceRequest<typename Interface::GenericInterface> |
| 111 GetProxy(InterfacePtr<Interface>* ptr) { |
111 MessagePipe pipe; | 112 MessagePipe pipe; |
112 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u)); | 113 ptr->Bind(InterfacePtrInfo<typename Interface::GenericInterface>( |
113 return MakeRequest<Interface>(pipe.handle1.Pass()); | 114 pipe.handle0.Pass(), 0u)); |
| 115 return MakeRequest<typename Interface::GenericInterface>( |
| 116 pipe.handle1.Pass()); |
114 } | 117 } |
115 | 118 |
116 } // namespace mojo | 119 } // namespace mojo |
117 | 120 |
118 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 121 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
OLD | NEW |