| 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 <cstddef> | 8 #include <cstddef> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/system/message_pipe.h" | 10 #include "mojo/public/cpp/system/message_pipe.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 | 13 |
| 14 template <typename I> | 14 template <typename I> |
| 15 class InterfacePtr; | 15 class InterfacePtr; |
| 16 | 16 |
| 17 template <typename I> | 17 template <typename I> |
| 18 class InterfacePtrInfo; | 18 class InterfaceHandle; |
| 19 | 19 |
| 20 // Represents a request from a remote client for an implementation of Interface | 20 // Represents a request from a remote client for an implementation of Interface |
| 21 // over a specified message pipe. The implementor of the interface should | 21 // over a specified message pipe. The implementor of the interface should |
| 22 // remove the message pipe by calling PassMessagePipe() and bind it to the | 22 // remove the message pipe by calling PassMessagePipe() and bind it to the |
| 23 // implementation. If this is not done, the InterfaceRequest will automatically | 23 // implementation. If this is not done, the InterfaceRequest will automatically |
| 24 // close the pipe on destruction. Can also represent the absence of a request | 24 // close the pipe on destruction. Can also represent the absence of a request |
| 25 // if the client did not provide a message pipe. | 25 // if the client did not provide a message pipe. |
| 26 template <typename Interface> | 26 template <typename Interface> |
| 27 class InterfaceRequest { | 27 class InterfaceRequest { |
| 28 public: | 28 public: |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // | 111 // |
| 112 // CollectorPtr collector = ...; // Connect to Collector. | 112 // CollectorPtr collector = ...; // Connect to Collector. |
| 113 // SourcePtr source; | 113 // SourcePtr source; |
| 114 // InterfaceRequest<Source> source_request = GetProxy(&source); | 114 // InterfaceRequest<Source> source_request = GetProxy(&source); |
| 115 // collector->RegisterSource(source.Pass()); | 115 // collector->RegisterSource(source.Pass()); |
| 116 // CreateSource(source_request.Pass()); // Create implementation locally. | 116 // CreateSource(source_request.Pass()); // Create implementation locally. |
| 117 // | 117 // |
| 118 template <typename Interface> | 118 template <typename Interface> |
| 119 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { | 119 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { |
| 120 MessagePipe pipe; | 120 MessagePipe pipe; |
| 121 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u)); | 121 ptr->Bind(InterfaceHandle<Interface>(pipe.handle0.Pass(), 0u)); |
| 122 return MakeRequest<Interface>(pipe.handle1.Pass()); | 122 return MakeRequest<Interface>(pipe.handle1.Pass()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace mojo | 125 } // namespace mojo |
| 126 | 126 |
| 127 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 127 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
| OLD | NEW |