| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_stream.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/quic/iovector.h" | 8 #include "net/quic/iovector.h" |
| 9 #include "net/quic/quic_ack_listener_interface.h" | 9 #include "net/quic/quic_ack_listener_interface.h" |
| 10 #include "net/quic/quic_bug_tracker.h" |
| 10 #include "net/quic/quic_flags.h" | 11 #include "net/quic/quic_flags.h" |
| 11 #include "net/quic/quic_flow_controller.h" | 12 #include "net/quic/quic_flow_controller.h" |
| 12 #include "net/quic/quic_session.h" | 13 #include "net/quic/quic_session.h" |
| 13 #include "net/quic/quic_write_blocked_list.h" | 14 #include "net/quic/quic_write_blocked_list.h" |
| 14 | 15 |
| 15 using base::StringPiece; | 16 using base::StringPiece; |
| 16 using std::min; | 17 using std::min; |
| 17 using std::string; | 18 using std::string; |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 void ReliableQuicStream::CloseConnectionWithDetails(QuicErrorCode error, | 184 void ReliableQuicStream::CloseConnectionWithDetails(QuicErrorCode error, |
| 184 const string& details) { | 185 const string& details) { |
| 185 session()->connection()->SendConnectionCloseWithDetails(error, details); | 186 session()->connection()->SendConnectionCloseWithDetails(error, details); |
| 186 } | 187 } |
| 187 | 188 |
| 188 void ReliableQuicStream::WriteOrBufferData( | 189 void ReliableQuicStream::WriteOrBufferData( |
| 189 StringPiece data, | 190 StringPiece data, |
| 190 bool fin, | 191 bool fin, |
| 191 QuicAckListenerInterface* ack_listener) { | 192 QuicAckListenerInterface* ack_listener) { |
| 192 if (data.empty() && !fin) { | 193 if (data.empty() && !fin) { |
| 193 LOG(DFATAL) << "data.empty() && !fin"; | 194 QUIC_BUG << "data.empty() && !fin"; |
| 194 return; | 195 return; |
| 195 } | 196 } |
| 196 | 197 |
| 197 if (fin_buffered_) { | 198 if (fin_buffered_) { |
| 198 LOG(DFATAL) << "Fin already buffered"; | 199 QUIC_BUG << "Fin already buffered"; |
| 199 return; | 200 return; |
| 200 } | 201 } |
| 201 if (write_side_closed_) { | 202 if (write_side_closed_) { |
| 202 DLOG(ERROR) << ENDPOINT << "Attempt to write when the write side is closed"; | 203 DLOG(ERROR) << ENDPOINT << "Attempt to write when the write side is closed"; |
| 203 return; | 204 return; |
| 204 } | 205 } |
| 205 | 206 |
| 206 QuicConsumedData consumed_data(0, false); | 207 QuicConsumedData consumed_data(0, false); |
| 207 fin_buffered_ = fin; | 208 fin_buffered_ = fin; |
| 208 | 209 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 226 while (!queued_data_.empty()) { | 227 while (!queued_data_.empty()) { |
| 227 PendingData* pending_data = &queued_data_.front(); | 228 PendingData* pending_data = &queued_data_.front(); |
| 228 QuicAckListenerInterface* ack_listener = pending_data->ack_listener.get(); | 229 QuicAckListenerInterface* ack_listener = pending_data->ack_listener.get(); |
| 229 if (queued_data_.size() == 1 && fin_buffered_) { | 230 if (queued_data_.size() == 1 && fin_buffered_) { |
| 230 fin = true; | 231 fin = true; |
| 231 } | 232 } |
| 232 if (pending_data->offset > 0 && | 233 if (pending_data->offset > 0 && |
| 233 pending_data->offset >= pending_data->data.size()) { | 234 pending_data->offset >= pending_data->data.size()) { |
| 234 // This should be impossible because offset tracks the amount of | 235 // This should be impossible because offset tracks the amount of |
| 235 // pending_data written thus far. | 236 // pending_data written thus far. |
| 236 LOG(DFATAL) << "Pending offset is beyond available data. offset: " | 237 QUIC_BUG << "Pending offset is beyond available data. offset: " |
| 237 << pending_data->offset | 238 << pending_data->offset << " vs: " << pending_data->data.size(); |
| 238 << " vs: " << pending_data->data.size(); | |
| 239 return; | 239 return; |
| 240 } | 240 } |
| 241 size_t remaining_len = pending_data->data.size() - pending_data->offset; | 241 size_t remaining_len = pending_data->data.size() - pending_data->offset; |
| 242 struct iovec iov = { | 242 struct iovec iov = { |
| 243 const_cast<char*>(pending_data->data.data()) + pending_data->offset, | 243 const_cast<char*>(pending_data->data.data()) + pending_data->offset, |
| 244 remaining_len}; | 244 remaining_len}; |
| 245 QuicConsumedData consumed_data = WritevData(&iov, 1, fin, ack_listener); | 245 QuicConsumedData consumed_data = WritevData(&iov, 1, fin, ack_listener); |
| 246 queued_data_bytes_ -= consumed_data.bytes_consumed; | 246 queued_data_bytes_ -= consumed_data.bytes_consumed; |
| 247 if (consumed_data.bytes_consumed == remaining_len && | 247 if (consumed_data.bytes_consumed == remaining_len && |
| 248 fin == consumed_data.fin_consumed) { | 248 fin == consumed_data.fin_consumed) { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 } | 457 } |
| 458 } | 458 } |
| 459 | 459 |
| 460 void ReliableQuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { | 460 void ReliableQuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { |
| 461 if (flow_controller_.UpdateSendWindowOffset(new_window)) { | 461 if (flow_controller_.UpdateSendWindowOffset(new_window)) { |
| 462 OnCanWrite(); | 462 OnCanWrite(); |
| 463 } | 463 } |
| 464 } | 464 } |
| 465 | 465 |
| 466 } // namespace net | 466 } // namespace net |
| OLD | NEW |