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_INTERFACE_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Closes the associated interface (if any) and returns the pointer to the | 121 // Closes the associated interface (if any) and returns the pointer to the |
122 // unbound state. | 122 // unbound state. |
123 void reset() { | 123 void reset() { |
124 State doomed; | 124 State doomed; |
125 internal_state_.Swap(&doomed); | 125 internal_state_.Swap(&doomed); |
126 } | 126 } |
127 | 127 |
128 // Similar to the method above, but also specifies a disconnect reason. | 128 // Similar to the method above, but also specifies a disconnect reason. |
129 void ResetWithReason(uint32_t custom_reason, const std::string& description) { | 129 void ResetWithReason(uint32_t custom_reason, const std::string& description) { |
130 if (internal_state_.is_bound()) | 130 if (internal_state_.is_bound()) |
131 internal_state_.SendDisconnectReason(custom_reason, description); | 131 internal_state_.CloseWithReason(custom_reason, description); |
132 reset(); | 132 reset(); |
133 } | 133 } |
134 | 134 |
135 // Indicates whether an error has been encountered. If true, method calls made | 135 // Indicates whether an error has been encountered. If true, method calls made |
136 // on this interface will be dropped (and may already have been dropped). | 136 // on this interface will be dropped (and may already have been dropped). |
137 bool encountered_error() const { return internal_state_.encountered_error(); } | 137 bool encountered_error() const { return internal_state_.encountered_error(); } |
138 | 138 |
139 // Registers a handler to receive error notifications. | 139 // Registers a handler to receive error notifications. |
140 // | 140 // |
141 // This method may only be called after the AssociatedInterfacePtr has been | 141 // This method may only be called after the AssociatedInterfacePtr has been |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 Interface::Version_)); | 288 Interface::Version_)); |
289 | 289 |
290 AssociatedInterfaceRequest<Interface> request; | 290 AssociatedInterfaceRequest<Interface> request; |
291 request.Bind(std::move(endpoint1)); | 291 request.Bind(std::move(endpoint1)); |
292 return request; | 292 return request; |
293 } | 293 } |
294 | 294 |
295 } // namespace mojo | 295 } // namespace mojo |
296 | 296 |
297 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ | 297 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ |
OLD | NEW |