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_BINDING_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ |
7 | 7 |
| 8 #include <utility> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
10 #include "mojo/public/cpp/bindings/associated_group.h" | 12 #include "mojo/public/cpp/bindings/associated_group.h" |
11 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 13 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
12 #include "mojo/public/cpp/bindings/callback.h" | 14 #include "mojo/public/cpp/bindings/callback.h" |
13 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" | 15 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" |
14 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | 16 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
15 #include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h" | 17 #include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h" |
16 | 18 |
17 namespace mojo { | 19 namespace mojo { |
(...skipping 22 matching lines...) Expand all Loading... |
40 AssociatedGroup* associated_group) | 42 AssociatedGroup* associated_group) |
41 : AssociatedBinding(impl) { | 43 : AssociatedBinding(impl) { |
42 Bind(ptr_info, associated_group); | 44 Bind(ptr_info, associated_group); |
43 } | 45 } |
44 | 46 |
45 // Constructs a completed associated binding of |impl|. |impl| must outlive | 47 // Constructs a completed associated binding of |impl|. |impl| must outlive |
46 // the binding. | 48 // the binding. |
47 AssociatedBinding(Interface* impl, | 49 AssociatedBinding(Interface* impl, |
48 AssociatedInterfaceRequest<GenericInterface> request) | 50 AssociatedInterfaceRequest<GenericInterface> request) |
49 : AssociatedBinding(impl) { | 51 : AssociatedBinding(impl) { |
50 Bind(request.Pass()); | 52 Bind(std::move(request)); |
51 } | 53 } |
52 | 54 |
53 ~AssociatedBinding() {} | 55 ~AssociatedBinding() {} |
54 | 56 |
55 // Creates an associated inteface and sets up this object as the | 57 // Creates an associated inteface and sets up this object as the |
56 // implementation side. The output |ptr_info| should be passed through the | 58 // implementation side. The output |ptr_info| should be passed through the |
57 // message pipe endpoint referred to by |associated_group| to setup the | 59 // message pipe endpoint referred to by |associated_group| to setup the |
58 // corresponding asssociated interface pointer. | 60 // corresponding asssociated interface pointer. |
59 void Bind(AssociatedInterfacePtrInfo<GenericInterface>* ptr_info, | 61 void Bind(AssociatedInterfacePtrInfo<GenericInterface>* ptr_info, |
60 AssociatedGroup* associated_group) { | 62 AssociatedGroup* associated_group) { |
(...skipping 11 matching lines...) Expand all Loading... |
72 DCHECK(handle.is_local()) | 74 DCHECK(handle.is_local()) |
73 << "The AssociatedInterfaceRequest is supposed to be used at the " | 75 << "The AssociatedInterfaceRequest is supposed to be used at the " |
74 << "other side of the message pipe."; | 76 << "other side of the message pipe."; |
75 | 77 |
76 if (!handle.is_valid() || !handle.is_local()) { | 78 if (!handle.is_valid() || !handle.is_local()) { |
77 endpoint_client_.reset(); | 79 endpoint_client_.reset(); |
78 return; | 80 return; |
79 } | 81 } |
80 | 82 |
81 endpoint_client_.reset(new internal::InterfaceEndpointClient( | 83 endpoint_client_.reset(new internal::InterfaceEndpointClient( |
82 handle.Pass(), &stub_, | 84 std::move(handle), &stub_, |
83 make_scoped_ptr(new typename Interface::RequestValidator_()))); | 85 make_scoped_ptr(new typename Interface::RequestValidator_()))); |
84 endpoint_client_->set_connection_error_handler( | 86 endpoint_client_->set_connection_error_handler( |
85 [this]() { connection_error_handler_.Run(); }); | 87 [this]() { connection_error_handler_.Run(); }); |
86 | 88 |
87 stub_.serialization_context()->router = endpoint_client_->router(); | 89 stub_.serialization_context()->router = endpoint_client_->router(); |
88 } | 90 } |
89 | 91 |
90 // Closes the associated interface. Puts this object into a state where it can | 92 // Closes the associated interface. Puts this object into a state where it can |
91 // be rebound. | 93 // be rebound. |
92 void Close() { | 94 void Close() { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 typename Interface::Stub_ stub_; | 141 typename Interface::Stub_ stub_; |
140 Interface* impl_; | 142 Interface* impl_; |
141 Closure connection_error_handler_; | 143 Closure connection_error_handler_; |
142 | 144 |
143 DISALLOW_COPY_AND_ASSIGN(AssociatedBinding); | 145 DISALLOW_COPY_AND_ASSIGN(AssociatedBinding); |
144 }; | 146 }; |
145 | 147 |
146 } // namespace mojo | 148 } // namespace mojo |
147 | 149 |
148 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ | 150 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ |
OLD | NEW |