Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: mojo/public/cpp/bindings/lib/interface_ptr_state.h

Issue 2932193002: Use OnceCallback for Mojo binding connection error handlers. (Closed)
Patch Set: Call Run() on rvalue. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_LIB_INTERFACE_PTR_STATE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> // For |std::swap()|. 10 #include <algorithm> // For |std::swap()|.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return InterfacePtrInfo<Interface>( 118 return InterfacePtrInfo<Interface>(
119 router_ ? router_->PassMessagePipe() : std::move(handle_), version_); 119 router_ ? router_->PassMessagePipe() : std::move(handle_), version_);
120 } 120 }
121 121
122 bool is_bound() const { return handle_.is_valid() || endpoint_client_; } 122 bool is_bound() const { return handle_.is_valid() || endpoint_client_; }
123 123
124 bool encountered_error() const { 124 bool encountered_error() const {
125 return endpoint_client_ ? endpoint_client_->encountered_error() : false; 125 return endpoint_client_ ? endpoint_client_->encountered_error() : false;
126 } 126 }
127 127
128 void set_connection_error_handler(const base::Closure& error_handler) { 128 void set_connection_error_handler(base::OnceClosure error_handler) {
129 ConfigureProxyIfNecessary(); 129 ConfigureProxyIfNecessary();
130 130
131 DCHECK(endpoint_client_); 131 DCHECK(endpoint_client_);
132 endpoint_client_->set_connection_error_handler(error_handler); 132 endpoint_client_->set_connection_error_handler(std::move(error_handler));
133 } 133 }
134 134
135 void set_connection_error_with_reason_handler( 135 void set_connection_error_with_reason_handler(
136 const ConnectionErrorWithReasonCallback& error_handler) { 136 ConnectionErrorWithReasonCallback error_handler) {
137 ConfigureProxyIfNecessary(); 137 ConfigureProxyIfNecessary();
138 138
139 DCHECK(endpoint_client_); 139 DCHECK(endpoint_client_);
140 endpoint_client_->set_connection_error_with_reason_handler(error_handler); 140 endpoint_client_->set_connection_error_with_reason_handler(
141 std::move(error_handler));
141 } 142 }
142 143
143 // Returns true if bound and awaiting a response to a message. 144 // Returns true if bound and awaiting a response to a message.
144 bool has_pending_callbacks() const { 145 bool has_pending_callbacks() const {
145 return endpoint_client_ && endpoint_client_->has_pending_responders(); 146 return endpoint_client_ && endpoint_client_->has_pending_responders();
146 } 147 }
147 148
148 AssociatedGroup* associated_group() { 149 AssociatedGroup* associated_group() {
149 ConfigureProxyIfNecessary(); 150 ConfigureProxyIfNecessary();
150 return endpoint_client_->associated_group(); 151 return endpoint_client_->associated_group();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 218
218 uint32_t version_; 219 uint32_t version_;
219 220
220 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); 221 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
221 }; 222 };
222 223
223 } // namespace internal 224 } // namespace internal
224 } // namespace mojo 225 } // namespace mojo
225 226
226 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ 227 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_endpoint_client.cc ('k') | mojo/public/cpp/bindings/strong_associated_binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698