OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/websockets/websocket_channel.h" | 5 #include "net/websockets/websocket_channel.h" |
6 | 6 |
7 #include <limits.h> // for INT_MAX | 7 #include <limits.h> // for INT_MAX |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 return CHANNEL_DELETED; | 470 return CHANNEL_DELETED; |
471 if (bytes_to_send < data_size) { | 471 if (bytes_to_send < data_size) { |
472 front.DidConsume(bytes_to_send); | 472 front.DidConsume(bytes_to_send); |
473 front.ResetOpcode(); | 473 front.ResetOpcode(); |
474 return CHANNEL_ALIVE; | 474 return CHANNEL_ALIVE; |
475 } | 475 } |
476 quota -= bytes_to_send; | 476 quota -= bytes_to_send; |
477 | 477 |
478 pending_received_frames_.pop(); | 478 pending_received_frames_.pop(); |
479 } | 479 } |
480 if (pending_received_frames_.empty() && has_received_close_frame_) { | 480 if (!InClosingState() && pending_received_frames_.empty() && |
| 481 has_received_close_frame_) { |
481 // We've been waiting for the client to consume the frames before | 482 // We've been waiting for the client to consume the frames before |
482 // responding to the closing handshake initiated by the server. | 483 // responding to the closing handshake initiated by the server. |
483 return RespondToClosingHandshake(); | 484 return RespondToClosingHandshake(); |
484 } | 485 } |
485 | 486 |
486 // If current_receive_quota_ == 0 then there is no pending ReadFrames() | 487 // If current_receive_quota_ == 0 then there is no pending ReadFrames() |
487 // operation. | 488 // operation. |
488 const bool start_read = | 489 const bool start_read = |
489 current_receive_quota_ == 0 && quota > 0 && | 490 current_receive_quota_ == 0 && quota > 0 && |
490 (state_ == CONNECTED || state_ == SEND_CLOSED || state_ == CLOSE_WAIT); | 491 (state_ == CONNECTED || state_ == SEND_CLOSED || state_ == CLOSE_WAIT); |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 } | 1197 } |
1197 | 1198 |
1198 void WebSocketChannel::CloseTimeout() { | 1199 void WebSocketChannel::CloseTimeout() { |
1199 stream_->Close(); | 1200 stream_->Close(); |
1200 SetState(CLOSED); | 1201 SetState(CLOSED); |
1201 DoDropChannel(false, kWebSocketErrorAbnormalClosure, ""); | 1202 DoDropChannel(false, kWebSocketErrorAbnormalClosure, ""); |
1202 // |this| has been deleted. | 1203 // |this| has been deleted. |
1203 } | 1204 } |
1204 | 1205 |
1205 } // namespace net | 1206 } // namespace net |
OLD | NEW |