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

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

Issue 2332353004: Mojo C++ bindings: support closing [Associated]InterfaceRequest with 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_request.h
diff --git a/mojo/public/cpp/bindings/interface_request.h b/mojo/public/cpp/bindings/interface_request.h
index fc23aec3ee73be187dabf450972a4a8906cf3626..5d75dd3e610deddefff8f773d348b4094eb76f09 100644
--- a/mojo/public/cpp/bindings/interface_request.h
+++ b/mojo/public/cpp/bindings/interface_request.h
@@ -5,12 +5,15 @@
#ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_
#define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_
+#include <string>
#include <utility>
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
+#include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
+#include "mojo/public/cpp/system/message_pipe.h"
namespace mojo {
@@ -64,6 +67,20 @@ class InterfaceRequest {
return !is_pending() && !other.is_pending();
}
+ void ResetWithReason(uint32_t custom_reason, const std::string& description) {
+ if (!handle_.is_valid())
+ return;
+
+ Message message =
+ internal::ControlMessageProxy::ConstructDisconnectReasonMessage(
+ custom_reason, description);
+ MojoResult result = WriteMessageNew(
+ handle_.get(), message.TakeMojoMessage(), MOJO_WRITE_MESSAGE_FLAG_NONE);
+ DCHECK_EQ(MOJO_RESULT_OK, result);
+
+ handle_.reset();
+ }
+
private:
ScopedMessagePipeHandle handle_;
« no previous file with comments | « mojo/public/cpp/bindings/associated_interface_request.h ('k') | mojo/public/cpp/bindings/lib/control_message_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698