| 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 <utility> |
| 9 |
| 8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 9 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" | 11 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
| 10 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 12 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
| 11 #include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h" | 13 #include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h" |
| 12 | 14 |
| 13 namespace mojo { | 15 namespace mojo { |
| 14 | 16 |
| 15 namespace internal { | 17 namespace internal { |
| 16 class MultiplexRouter; | 18 class MultiplexRouter; |
| 17 } | 19 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 CreateEndpointHandlePair(&local, &remote); | 55 CreateEndpointHandlePair(&local, &remote); |
| 54 | 56 |
| 55 if (!local.is_valid() || !remote.is_valid()) { | 57 if (!local.is_valid() || !remote.is_valid()) { |
| 56 *ptr_info = AssociatedInterfacePtrInfo<T>(); | 58 *ptr_info = AssociatedInterfacePtrInfo<T>(); |
| 57 *request = AssociatedInterfaceRequest<T>(); | 59 *request = AssociatedInterfaceRequest<T>(); |
| 58 return; | 60 return; |
| 59 } | 61 } |
| 60 | 62 |
| 61 if (config == WILL_PASS_PTR) { | 63 if (config == WILL_PASS_PTR) { |
| 62 internal::AssociatedInterfacePtrInfoHelper::SetHandle(ptr_info, | 64 internal::AssociatedInterfacePtrInfoHelper::SetHandle(ptr_info, |
| 63 remote.Pass()); | 65 std::move(remote)); |
| 64 // The implementation is local, therefore set the version according to | 66 // The implementation is local, therefore set the version according to |
| 65 // the interface definition that this code is built against. | 67 // the interface definition that this code is built against. |
| 66 ptr_info->set_version(T::Version_); | 68 ptr_info->set_version(T::Version_); |
| 67 internal::AssociatedInterfaceRequestHelper::SetHandle(request, | 69 internal::AssociatedInterfaceRequestHelper::SetHandle(request, |
| 68 local.Pass()); | 70 std::move(local)); |
| 69 } else { | 71 } else { |
| 70 internal::AssociatedInterfacePtrInfoHelper::SetHandle(ptr_info, | 72 internal::AssociatedInterfacePtrInfoHelper::SetHandle(ptr_info, |
| 71 local.Pass()); | 73 std::move(local)); |
| 72 // The implementation is remote, we don't know about its actual version | 74 // The implementation is remote, we don't know about its actual version |
| 73 // yet. | 75 // yet. |
| 74 ptr_info->set_version(0u); | 76 ptr_info->set_version(0u); |
| 75 internal::AssociatedInterfaceRequestHelper::SetHandle(request, | 77 internal::AssociatedInterfaceRequestHelper::SetHandle(request, |
| 76 remote.Pass()); | 78 std::move(remote)); |
| 77 } | 79 } |
| 78 } | 80 } |
| 79 | 81 |
| 80 private: | 82 private: |
| 81 friend class internal::MultiplexRouter; | 83 friend class internal::MultiplexRouter; |
| 82 | 84 |
| 83 void CreateEndpointHandlePair( | 85 void CreateEndpointHandlePair( |
| 84 internal::ScopedInterfaceEndpointHandle* local_endpoint, | 86 internal::ScopedInterfaceEndpointHandle* local_endpoint, |
| 85 internal::ScopedInterfaceEndpointHandle* remote_endpoint); | 87 internal::ScopedInterfaceEndpointHandle* remote_endpoint); |
| 86 | 88 |
| 87 scoped_refptr<internal::MultiplexRouter> router_; | 89 scoped_refptr<internal::MultiplexRouter> router_; |
| 88 }; | 90 }; |
| 89 | 91 |
| 90 } // namespace mojo | 92 } // namespace mojo |
| 91 | 93 |
| 92 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ | 94 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ |
| OLD | NEW |