| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // Given the following interface: | 53 // Given the following interface: |
| 54 // | 54 // |
| 55 // interface Foo { | 55 // interface Foo { |
| 56 // CreateBar(Bar& bar); | 56 // CreateBar(Bar& bar); |
| 57 // } | 57 // } |
| 58 // | 58 // |
| 59 // The caller of CreateBar would have code similar to the following: | 59 // The caller of CreateBar would have code similar to the following: |
| 60 // | 60 // |
| 61 // InterfacePtr<Foo> foo = ...; | 61 // InterfacePtr<Foo> foo = ...; |
| 62 // InterfacePtr<Bar> bar; | 62 // InterfacePtr<Bar> bar; |
| 63 // foo->CreateBar(Get(&bar)); | 63 // foo->CreateBar(GetProxy(&bar)); |
| 64 // | 64 // |
| 65 // Upon return from CreateBar, |bar| is ready to have methods called on it. | 65 // Upon return from CreateBar, |bar| is ready to have methods called on it. |
| 66 // | 66 // |
| 67 template <typename Interface> | 67 template <typename Interface> |
| 68 InterfaceRequest<Interface> Get(InterfacePtr<Interface>* ptr) { | 68 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { |
| 69 MessagePipe pipe; | 69 MessagePipe pipe; |
| 70 ptr->Bind(pipe.handle0.Pass()); | 70 ptr->Bind(pipe.handle0.Pass()); |
| 71 return MakeRequest<Interface>(pipe.handle1.Pass()); | 71 return MakeRequest<Interface>(pipe.handle1.Pass()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace mojo | 74 } // namespace mojo |
| 75 | 75 |
| 76 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 76 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
| OLD | NEW |