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

Unified Diff: mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.cc

Issue 2649573004: Mojo bindings: merge the control messages of sending disconnect reason and notifying endpoint close… (Closed)
Patch Set: Created 3 years, 11 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/lib/scoped_interface_endpoint_handle.cc
diff --git a/mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.cc b/mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.cc
index f54c3f749c437165efeeab20f1a3fad684f474e0..1dffcb3f1eed05af373da344b7d83a4d409c08e8 100644
--- a/mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.cc
+++ b/mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.cc
@@ -32,14 +32,15 @@ ScopedInterfaceEndpointHandle& ScopedInterfaceEndpointHandle::operator=(
}
void ScopedInterfaceEndpointHandle::reset() {
- if (!IsValidInterfaceId(id_))
- return;
-
- group_controller_->CloseEndpointHandle(id_, is_local_);
+ ResetInternal(base::nullopt);
+}
- id_ = kInvalidInterfaceId;
- is_local_ = true;
- group_controller_ = nullptr;
+void ScopedInterfaceEndpointHandle::ResetWithReason(
+ uint32_t custom_reason,
+ const std::string& description) {
+ base::Optional<DisconnectReason> reason;
+ reason.emplace(custom_reason, description);
+ ResetInternal(reason);
dcheng 2017/01/23 23:20:22 FWIW, here and a couple other places ResetInterna
yzshen1 2017/01/23 23:30:09 I think the original code doesn't copy either. Hav
dcheng 2017/01/24 03:39:21 Ah, you're right: my comment is only true if |reas
}
void ScopedInterfaceEndpointHandle::swap(ScopedInterfaceEndpointHandle& other) {
@@ -69,4 +70,16 @@ ScopedInterfaceEndpointHandle::ScopedInterfaceEndpointHandle(
DCHECK(!IsValidInterfaceId(id) || group_controller_);
}
+void ScopedInterfaceEndpointHandle::ResetInternal(
+ const base::Optional<DisconnectReason>& reason) {
+ if (!IsValidInterfaceId(id_))
+ return;
+
+ group_controller_->CloseEndpointHandle(id_, is_local_, reason);
+
+ id_ = kInvalidInterfaceId;
+ is_local_ = true;
+ group_controller_ = nullptr;
+}
+
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/pipe_control_message_proxy.cc ('k') | mojo/public/cpp/bindings/pipe_control_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698