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

Side by Side Diff: mojo/public/cpp/bindings/lib/associated_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 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_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 proxy_.reset(); 100 proxy_.reset();
101 return AssociatedInterfacePtrInfo<Interface>(std::move(handle), version_); 101 return AssociatedInterfacePtrInfo<Interface>(std::move(handle), version_);
102 } 102 }
103 103
104 bool is_bound() const { return !!endpoint_client_; } 104 bool is_bound() const { return !!endpoint_client_; }
105 105
106 bool encountered_error() const { 106 bool encountered_error() const {
107 return endpoint_client_ ? endpoint_client_->encountered_error() : false; 107 return endpoint_client_ ? endpoint_client_->encountered_error() : false;
108 } 108 }
109 109
110 void set_connection_error_handler(const base::Closure& error_handler) { 110 void set_connection_error_handler(base::OnceClosure error_handler) {
111 DCHECK(endpoint_client_); 111 DCHECK(endpoint_client_);
112 endpoint_client_->set_connection_error_handler(error_handler); 112 endpoint_client_->set_connection_error_handler(std::move(error_handler));
113 } 113 }
114 114
115 void set_connection_error_with_reason_handler( 115 void set_connection_error_with_reason_handler(
116 const ConnectionErrorWithReasonCallback& error_handler) { 116 ConnectionErrorWithReasonCallback error_handler) {
117 DCHECK(endpoint_client_); 117 DCHECK(endpoint_client_);
118 endpoint_client_->set_connection_error_with_reason_handler(error_handler); 118 endpoint_client_->set_connection_error_with_reason_handler(
119 std::move(error_handler));
119 } 120 }
120 121
121 // Returns true if bound and awaiting a response to a message. 122 // Returns true if bound and awaiting a response to a message.
122 bool has_pending_callbacks() const { 123 bool has_pending_callbacks() const {
123 return endpoint_client_ && endpoint_client_->has_pending_responders(); 124 return endpoint_client_ && endpoint_client_->has_pending_responders();
124 } 125 }
125 126
126 AssociatedGroup* associated_group() { 127 AssociatedGroup* associated_group() {
127 return endpoint_client_ ? endpoint_client_->associated_group() : nullptr; 128 return endpoint_client_ ? endpoint_client_->associated_group() : nullptr;
128 } 129 }
(...skipping 19 matching lines...) Expand all
148 149
149 uint32_t version_; 150 uint32_t version_;
150 151
151 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtrState); 152 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtrState);
152 }; 153 };
153 154
154 } // namespace internal 155 } // namespace internal
155 } // namespace mojo 156 } // namespace mojo
156 157
157 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ 158 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/associated_binding.cc ('k') | mojo/public/cpp/bindings/lib/binding_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698