Chromium Code Reviews| Index: net/socket_stream/socket_stream.cc |
| diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc |
| index 98c41666933c24f4f7dbafdedc8b1f829c05a8e6..3d193db4d2eee27dff23e212874812bedd86e613 100644 |
| --- a/net/socket_stream/socket_stream.cc |
| +++ b/net/socket_stream/socket_stream.cc |
| @@ -292,6 +292,8 @@ void SocketStream::DetachDelegate() { |
| if (!delegate_) |
| return; |
| delegate_ = NULL; |
| + if (next_state_ == STATE_NONE) |
| + return; |
|
tyoshino (SeeGerritForStatus)
2013/05/27 05:55:36
what is this change for?
Adam Rice
2013/05/27 07:16:33
Previously, Finish() would set delegate_ to NULL,
tyoshino (SeeGerritForStatus)
2013/05/27 08:09:13
I see. Thanks
|
| net_log_.AddEvent(NetLog::TYPE_CANCELLED); |
| // We don't need to send pending data when client detach the delegate. |
| pending_write_bufs_.clear(); |
| @@ -369,14 +371,13 @@ void SocketStream::Finish(int result) { |
| DVLOG(1) << "Finish result=" << ErrorToString(result); |
| metrics_->OnClose(); |
| - Delegate* delegate = delegate_; |
| + |
| + if (result != ERR_CONNECTION_CLOSED && delegate_) |
| + delegate_->OnError(this, result); |
| + if (result != ERR_PROTOCOL_SWITCHED && delegate_) |
| + delegate_->OnClose(this); |
| delegate_ = NULL; |
| - if (delegate) { |
| - if (result != ERR_CONNECTION_CLOSED) |
| - delegate->OnError(this, result); |
| - if (result != ERR_PROTOCOL_SWITCHED) |
| - delegate->OnClose(this); |
| - } |
| + |
| Release(); |
| } |