| 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 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 DCHECK_LE(quota, INT_MAX); | 400 DCHECK_LE(quota, INT_MAX); |
| 401 if (!pending_received_frames_.empty()) { | 401 if (!pending_received_frames_.empty()) { |
| 402 DCHECK_EQ(0, current_receive_quota_); | 402 DCHECK_EQ(0, current_receive_quota_); |
| 403 } | 403 } |
| 404 while (!pending_received_frames_.empty() && quota > 0) { | 404 while (!pending_received_frames_.empty() && quota > 0) { |
| 405 PendingReceivedFrame& front = pending_received_frames_.front(); | 405 PendingReceivedFrame& front = pending_received_frames_.front(); |
| 406 const size_t data_size = front.size() - front.offset(); | 406 const size_t data_size = front.size() - front.offset(); |
| 407 const size_t bytes_to_send = | 407 const size_t bytes_to_send = |
| 408 std::min(base::checked_cast<size_t>(quota), data_size); | 408 std::min(base::checked_cast<size_t>(quota), data_size); |
| 409 const bool final = front.final() && data_size == bytes_to_send; | 409 const bool final = front.final() && data_size == bytes_to_send; |
| 410 const char* data = front.data()->data() + front.offset(); | 410 const char* data = front.data() ? |
| 411 front.data()->data() + front.offset() : NULL; |
| 412 DCHECK(!bytes_to_send || data) << "Non empty data should not be null."; |
| 411 const std::vector<char> data_vector(data, data + bytes_to_send); | 413 const std::vector<char> data_vector(data, data + bytes_to_send); |
| 412 DVLOG(3) << "Sending frame previously split due to quota to the " | 414 DVLOG(3) << "Sending frame previously split due to quota to the " |
| 413 << "renderer: quota=" << quota << " data_size=" << data_size | 415 << "renderer: quota=" << quota << " data_size=" << data_size |
| 414 << " bytes_to_send=" << bytes_to_send; | 416 << " bytes_to_send=" << bytes_to_send; |
| 415 if (event_interface_->OnDataFrame(final, front.opcode(), data_vector) == | 417 if (event_interface_->OnDataFrame(final, front.opcode(), data_vector) == |
| 416 CHANNEL_DELETED) | 418 CHANNEL_DELETED) |
| 417 return; | 419 return; |
| 418 if (bytes_to_send < data_size) { | 420 if (bytes_to_send < data_size) { |
| 419 front.DidConsume(bytes_to_send); | 421 front.DidConsume(bytes_to_send); |
| 420 front.ResetOpcode(); | 422 front.ResetOpcode(); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 | 1065 |
| 1064 void WebSocketChannel::CloseTimeout() { | 1066 void WebSocketChannel::CloseTimeout() { |
| 1065 stream_->Close(); | 1067 stream_->Close(); |
| 1066 DCHECK_NE(CLOSED, state_); | 1068 DCHECK_NE(CLOSED, state_); |
| 1067 state_ = CLOSED; | 1069 state_ = CLOSED; |
| 1068 AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, "")); | 1070 AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, "")); |
| 1069 // |this| has been deleted. | 1071 // |this| has been deleted. |
| 1070 } | 1072 } |
| 1071 | 1073 |
| 1072 } // namespace net | 1074 } // namespace net |
| OLD | NEW |