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

Side by Side Diff: mojo/public/cpp/bindings/binding.h

Issue 1531543003: Modify bindings to enforce that an error handler callback is only set after binding to a msg pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-error-handler
Patch Set: Add error handler comment. Created 5 years 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_BINDING_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "mojo/public/c/environment/async_waiter.h" 9 #include "mojo/public/c/environment/async_waiter.h"
10 #include "mojo/public/cpp/bindings/callback.h" 10 #include "mojo/public/cpp/bindings/callback.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // on to associated interface endpoint handles at both sides of the 186 // on to associated interface endpoint handles at both sides of the
187 // message pipe in order to call this method. We need a way to forcefully 187 // message pipe in order to call this method. We need a way to forcefully
188 // invalidate associated interface endpoint handles. 188 // invalidate associated interface endpoint handles.
189 InterfaceRequest<Interface> Unbind() { 189 InterfaceRequest<Interface> Unbind() {
190 CHECK(!HasAssociatedInterfaces()); 190 CHECK(!HasAssociatedInterfaces());
191 return internal_state_.Unbind(); 191 return internal_state_.Unbind();
192 } 192 }
193 193
194 // Sets an error handler that will be called if a connection error occurs on 194 // Sets an error handler that will be called if a connection error occurs on
195 // the bound message pipe. 195 // the bound message pipe.
196 //
197 // This method may only be called after this Binding has been bound to a
198 // message pipe. The error handler will be reset when this Binding is unbound
199 // or closed.
196 void set_connection_error_handler(const Closure& error_handler) { 200 void set_connection_error_handler(const Closure& error_handler) {
201 DCHECK(is_bound());
197 internal_state_.set_connection_error_handler(error_handler); 202 internal_state_.set_connection_error_handler(error_handler);
198 } 203 }
199 204
200 // Returns the interface implementation that was previously specified. Caller 205 // Returns the interface implementation that was previously specified. Caller
201 // does not take ownership. 206 // does not take ownership.
202 Interface* impl() { return internal_state_.impl(); } 207 Interface* impl() { return internal_state_.impl(); }
203 208
204 // Indicates whether the binding has been completed (i.e., whether a message 209 // Indicates whether the binding has been completed (i.e., whether a message
205 // pipe has been bound to the implementation). 210 // pipe has been bound to the implementation).
206 bool is_bound() const { return internal_state_.is_bound(); } 211 bool is_bound() const { return internal_state_.is_bound(); }
(...skipping 18 matching lines...) Expand all
225 private: 230 private:
226 internal::BindingState<Interface, Interface::PassesAssociatedKinds_> 231 internal::BindingState<Interface, Interface::PassesAssociatedKinds_>
227 internal_state_; 232 internal_state_;
228 233
229 DISALLOW_COPY_AND_ASSIGN(Binding); 234 DISALLOW_COPY_AND_ASSIGN(Binding);
230 }; 235 };
231 236
232 } // namespace mojo 237 } // namespace mojo
233 238
234 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ 239 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/associated_binding.h ('k') | mojo/public/cpp/bindings/lib/binding_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698