diff options
author | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-17 10:20:01 +0000 |
---|---|---|
committer | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-17 10:20:01 +0000 |
commit | 38712b1abf0cd6b2a60387e402f2b05d937a8ba5 (patch) | |
tree | 437dfcc294977e48d8f64c92318846ca01b8b4d2 | |
parent | 9945fd3c89ca1dbfd091ae967f8aae75e3482a9b (diff) | |
download | chromium_src-38712b1abf0cd6b2a60387e402f2b05d937a8ba5.zip chromium_src-38712b1abf0cd6b2a60387e402f2b05d937a8ba5.tar.gz chromium_src-38712b1abf0cd6b2a60387e402f2b05d937a8ba5.tar.bz2 |
Check state in SocketStream delegate methods.
I suspect flaky failure in reload-crash.html was OnSentData is called when state_ has been changed to CLOSED while sending handshake message.
BUG=45720
TEST=none
Review URL: http://codereview.chromium.org/2845012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50087 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/websockets/websocket_job.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/net/websockets/websocket_job.cc b/net/websockets/websocket_job.cc index 0998c98..040fc4d 100644 --- a/net/websockets/websocket_job.cc +++ b/net/websockets/websocket_job.cc @@ -106,6 +106,7 @@ bool WebSocketJob::SendData(const char* data, int len) { int err = 0; if (!send_frame_handler_->GetCurrentBuffer() && (err = send_frame_handler_->UpdateCurrentBuffer(false)) > 0) { + DCHECK(!current_buffer_); current_buffer_ = new DrainableIOBuffer( send_frame_handler_->GetCurrentBuffer(), send_frame_handler_->GetCurrentBufferSize()); @@ -172,17 +173,23 @@ int WebSocketJob::OnStartOpenConnection( void WebSocketJob::OnConnected( SocketStream* socket, int max_pending_send_allowed) { + DCHECK_EQ(CONNECTING, state_); if (delegate_) delegate_->OnConnected(socket, max_pending_send_allowed); } void WebSocketJob::OnSentData(SocketStream* socket, int amount_sent) { + DCHECK_NE(INITIALIZED, state_); + if (state_ == CLOSED) + return; if (state_ == CONNECTING) { OnSentHandshakeRequest(socket, amount_sent); return; } if (delegate_) { + DCHECK(state_ == OPEN || state_ == CLOSING); DCHECK_GT(amount_sent, 0); + DCHECK(current_buffer_); current_buffer_->DidConsume(amount_sent); if (current_buffer_->BytesRemaining() > 0) return; @@ -201,10 +208,14 @@ void WebSocketJob::OnSentData(SocketStream* socket, int amount_sent) { void WebSocketJob::OnReceivedData( SocketStream* socket, const char* data, int len) { + DCHECK_NE(INITIALIZED, state_); + if (state_ == CLOSED) + return; if (state_ == CONNECTING) { OnReceivedHandshakeResponse(socket, data, len); return; } + DCHECK(state_ == OPEN || state_ == CLOSING); std::string received_data; receive_frame_handler_->AppendData(data, len); // Don't buffer receiving data for now. |