Chromium Code Reviews| 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 |