summaryrefslogtreecommitdiffstats
path: root/net/websockets/websocket_channel.cc
diff options
context:
space:
mode:
authorricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-10 13:16:16 +0000
committerricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-10 13:16:16 +0000
commit86ec5550eb81c98bdebe8f61dfe13c2ee24b2b96 (patch)
tree957b761793127c6395ee31534688dc998f664559 /net/websockets/websocket_channel.cc
parente802c0f7ebdf5984007bec3e4bb6512d124e993e (diff)
downloadchromium_src-86ec5550eb81c98bdebe8f61dfe13c2ee24b2b96.zip
chromium_src-86ec5550eb81c98bdebe8f61dfe13c2ee24b2b96.tar.gz
chromium_src-86ec5550eb81c98bdebe8f61dfe13c2ee24b2b96.tar.bz2
Pass was_clean from WebSocketChannel to renderer
Previously, the browser always set |was_clean| to true when it sent an OnDropChannel message to the renderer. Set the value correctly in WebSocketChannel and pass it through to WebSocketDispatcherHost. BUG=341343 Review URL: https://codereview.chromium.org/149793006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets/websocket_channel.cc')
-rw-r--r--net/websockets/websocket_channel.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/net/websockets/websocket_channel.cc b/net/websockets/websocket_channel.cc
index 94baafd..6760849 100644
--- a/net/websockets/websocket_channel.cc
+++ b/net/websockets/websocket_channel.cc
@@ -321,7 +321,7 @@ void WebSocketChannel::StartClosingHandshake(uint16 code,
// Abort the in-progress handshake and drop the connection immediately.
stream_request_.reset();
state_ = CLOSED;
- AllowUnused(DoDropChannel(kWebSocketErrorAbnormalClosure, ""));
+ AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, ""));
return;
}
if (state_ != CONNECTED) {
@@ -504,7 +504,7 @@ ChannelState WebSocketChannel::OnWriteDone(bool synchronous, int result) {
stream_->Close();
DCHECK_NE(CLOSED, state_);
state_ = CLOSED;
- return DoDropChannel(kWebSocketErrorAbnormalClosure, "");
+ return DoDropChannel(false, kWebSocketErrorAbnormalClosure, "");
}
}
@@ -568,11 +568,13 @@ ChannelState WebSocketChannel::OnReadDone(bool synchronous, int result) {
state_ = CLOSED;
uint16 code = kWebSocketErrorAbnormalClosure;
std::string reason = "";
+ bool was_clean = false;
if (closing_code_ != 0) {
code = closing_code_;
reason = closing_reason_;
+ was_clean = (result == ERR_CONNECTION_CLOSED);
}
- return DoDropChannel(code, reason);
+ return DoDropChannel(was_clean, code, reason);
}
}
@@ -859,19 +861,20 @@ bool WebSocketChannel::ParseClose(const scoped_refptr<IOBuffer>& buffer,
return parsed_ok;
}
-ChannelState WebSocketChannel::DoDropChannel(uint16 code,
+ChannelState WebSocketChannel::DoDropChannel(bool was_clean,
+ uint16 code,
const std::string& reason) {
if (CHANNEL_DELETED ==
notification_sender_->SendImmediately(event_interface_.get()))
return CHANNEL_DELETED;
- return event_interface_->OnDropChannel(code, reason);
+ return event_interface_->OnDropChannel(was_clean, code, reason);
}
void WebSocketChannel::CloseTimeout() {
stream_->Close();
DCHECK_NE(CLOSED, state_);
state_ = CLOSED;
- AllowUnused(DoDropChannel(kWebSocketErrorAbnormalClosure, ""));
+ AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, ""));
// |this| has been deleted.
}