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

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

Issue 2318793002: Mojo C++ bindings: support disconnect with a reason. (Closed)
Patch Set: . Created 4 years, 3 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 1a133fa3d833d6cd5aa5ddae4763c9c9033f877d..29d362e0f6122377f6998b9c2ad64907f3ea938c 100644
--- a/mojo/public/cpp/bindings/interface_ptr.h
+++ b/mojo/public/cpp/bindings/interface_ptr.h
@@ -6,6 +6,8 @@
#define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_
#include <stdint.h>
+
+#include <string>
#include <utility>
#include "base/callback_forward.h"
@@ -14,6 +16,7 @@
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "mojo/public/cpp/bindings/connection_error_callback.h"
#include "mojo/public/cpp/bindings/interface_ptr_info.h"
#include "mojo/public/cpp/bindings/lib/interface_ptr_state.h"
@@ -127,6 +130,13 @@ class InterfacePtr {
internal_state_.Swap(&doomed);
}
+ // Similar to the method above, but also specifies a disconnect reason.
+ void ResetWithReason(uint32_t custom_reason, const std::string& description) {
+ if (internal_state_.is_bound())
+ internal_state_.SendDisconnectReason(custom_reason, description);
+ reset();
+ }
+
// Whether there are any associated interfaces running on the pipe currently.
bool HasAssociatedInterfaces() const {
return internal_state_.HasAssociatedInterfaces();
@@ -146,6 +156,11 @@ class InterfacePtr {
internal_state_.set_connection_error_handler(error_handler);
}
+ void set_connection_error_with_reason_handler(
+ const ConnectionErrorWithReasonCallback& error_handler) {
+ internal_state_.set_connection_error_with_reason_handler(error_handler);
+ }
+
// Unbinds the InterfacePtr and returns the information which could be used
// to setup an InterfacePtr again. This method may be used to move the proxy
// to a different thread (see class comments for details).
« no previous file with comments | « mojo/public/cpp/bindings/interface_endpoint_client.h ('k') | mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698