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

Unified Diff: mojo/public/cpp/bindings/interface_ptr.h

Issue 1174073002: C++ bindings: support using a callback as connection error handler. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/interface_ptr.h
diff --git a/mojo/public/cpp/bindings/interface_ptr.h b/mojo/public/cpp/bindings/interface_ptr.h
index 124eba9a3cc9e3056035618102a39b698516f3a6..1a3be9dc9b7fc15c66385c229244e9cf70df2a38 100644
--- a/mojo/public/cpp/bindings/interface_ptr.h
+++ b/mojo/public/cpp/bindings/interface_ptr.h
@@ -7,6 +7,7 @@
#include <algorithm>
+#include "mojo/public/cpp/bindings/callback.h"
#include "mojo/public/cpp/bindings/error_handler.h"
#include "mojo/public/cpp/bindings/interface_ptr_info.h"
#include "mojo/public/cpp/bindings/lib/interface_ptr_internal.h"
@@ -14,7 +15,6 @@
#include "mojo/public/cpp/system/macros.h"
namespace mojo {
-class ErrorHandler;
// A pointer to a local proxy of a remote Interface implementation. Uses a
// message pipe to communicate with the remote implementation, and automatically
@@ -130,8 +130,17 @@ class InterfacePtr {
//
// This method may only be called after the InterfacePtr has been bound to a
// message pipe.
+ void set_connection_error_handler(const Closure& error_handler) {
+ internal_state_.set_connection_error_handler(error_handler);
+ }
+
+ // Similar to the method above but uses the ErrorHandler interface instead of
+ // a callback.
+ // NOTE: Deprecated. Please use the method above.
+ // TODO(yzshen): Remove this method once all callsites are converted.
void set_error_handler(ErrorHandler* error_handler) {
- internal_state_.set_error_handler(error_handler);
+ set_connection_error_handler(
+ [error_handler]() { error_handler->OnConnectionError(); });
}
// Unbinds the InterfacePtr and returns the information which could be used

Powered by Google App Engine
This is Rietveld 408576698