OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ASSOCIATED_GROUP_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" | 9 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
10 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 10 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // remote side of the message pipe. | 37 // remote side of the message pipe. |
38 // | 38 // |
39 // NOTE: If |config| is |WILL_PASS_REQUEST|, you will want to bind |ptr_info| | 39 // NOTE: If |config| is |WILL_PASS_REQUEST|, you will want to bind |ptr_info| |
40 // to a local AssociatedInterfacePtr to make calls. However, there is one | 40 // to a local AssociatedInterfacePtr to make calls. However, there is one |
41 // restriction: the pointer should NOT be used to make calls before |request| | 41 // restriction: the pointer should NOT be used to make calls before |request| |
42 // is sent. Violating that will cause the message pipe to be closed. On the | 42 // is sent. Violating that will cause the message pipe to be closed. On the |
43 // other hand, as soon as |request| is sent, the pointer is usable. There is | 43 // other hand, as soon as |request| is sent, the pointer is usable. There is |
44 // no need to wait until |request| is bound to an implementation at the remote | 44 // no need to wait until |request| is bound to an implementation at the remote |
45 // side. | 45 // side. |
46 template <typename T> | 46 template <typename T> |
47 void CreateAssociatedInterface(AssociatedInterfaceConfig config, | 47 void CreateAssociatedInterface( |
48 AssociatedInterfacePtrInfo<T>* ptr_info, | 48 AssociatedInterfaceConfig config, |
49 AssociatedInterfaceRequest<T>* request) { | 49 AssociatedInterfacePtrInfo<T>* ptr_info, |
| 50 AssociatedInterfaceRequest<T>* request) { |
50 internal::ScopedInterfaceEndpointHandle local; | 51 internal::ScopedInterfaceEndpointHandle local; |
51 internal::ScopedInterfaceEndpointHandle remote; | 52 internal::ScopedInterfaceEndpointHandle remote; |
52 CreateEndpointHandlePair(&local, &remote); | 53 CreateEndpointHandlePair(&local, &remote); |
53 | 54 |
54 if (!local.is_valid() || !remote.is_valid()) { | 55 if (!local.is_valid() || !remote.is_valid()) { |
55 *ptr_info = AssociatedInterfacePtrInfo<T>(); | 56 *ptr_info = AssociatedInterfacePtrInfo<T>(); |
56 *request = AssociatedInterfaceRequest<T>(); | 57 *request = AssociatedInterfaceRequest<T>(); |
57 return; | 58 return; |
58 } | 59 } |
59 | 60 |
(...skipping 22 matching lines...) Expand all Loading... |
82 void CreateEndpointHandlePair( | 83 void CreateEndpointHandlePair( |
83 internal::ScopedInterfaceEndpointHandle* local_endpoint, | 84 internal::ScopedInterfaceEndpointHandle* local_endpoint, |
84 internal::ScopedInterfaceEndpointHandle* remote_endpoint); | 85 internal::ScopedInterfaceEndpointHandle* remote_endpoint); |
85 | 86 |
86 scoped_refptr<internal::MultiplexRouter> router_; | 87 scoped_refptr<internal::MultiplexRouter> router_; |
87 }; | 88 }; |
88 | 89 |
89 } // namespace mojo | 90 } // namespace mojo |
90 | 91 |
91 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ | 92 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ |
OLD | NEW |