| 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/quic_session.h" | 5 #include "net/quic/quic_session.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "net/quic/crypto/proof_verifier.h" | 9 #include "net/quic/crypto/proof_verifier.h" |
| 10 #include "net/quic/quic_bug_tracker.h" |
| 10 #include "net/quic/quic_connection.h" | 11 #include "net/quic/quic_connection.h" |
| 11 #include "net/quic/quic_flags.h" | 12 #include "net/quic/quic_flags.h" |
| 12 #include "net/quic/quic_flow_controller.h" | 13 #include "net/quic/quic_flow_controller.h" |
| 13 #include "net/ssl/ssl_info.h" | 14 #include "net/ssl/ssl_info.h" |
| 14 | 15 |
| 15 using base::StringPiece; | 16 using base::StringPiece; |
| 16 using base::hash_map; | 17 using base::hash_map; |
| 17 using base::hash_set; | 18 using base::hash_set; |
| 18 using std::make_pair; | 19 using std::make_pair; |
| 19 using std::map; | 20 using std::map; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (error_ == QUIC_NO_ERROR) { | 189 if (error_ == QUIC_NO_ERROR) { |
| 189 error_ = error; | 190 error_ = error; |
| 190 } | 191 } |
| 191 | 192 |
| 192 while (!dynamic_stream_map_.empty()) { | 193 while (!dynamic_stream_map_.empty()) { |
| 193 StreamMap::iterator it = dynamic_stream_map_.begin(); | 194 StreamMap::iterator it = dynamic_stream_map_.begin(); |
| 194 QuicStreamId id = it->first; | 195 QuicStreamId id = it->first; |
| 195 it->second->OnConnectionClosed(error, from_peer); | 196 it->second->OnConnectionClosed(error, from_peer); |
| 196 // The stream should call CloseStream as part of OnConnectionClosed. | 197 // The stream should call CloseStream as part of OnConnectionClosed. |
| 197 if (dynamic_stream_map_.find(id) != dynamic_stream_map_.end()) { | 198 if (dynamic_stream_map_.find(id) != dynamic_stream_map_.end()) { |
| 198 LOG(DFATAL) << ENDPOINT | 199 QUIC_BUG << ENDPOINT << "Stream failed to close under OnConnectionClosed"; |
| 199 << "Stream failed to close under OnConnectionClosed"; | |
| 200 CloseStream(id); | 200 CloseStream(id); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 void QuicSession::OnSuccessfulVersionNegotiation( | 205 void QuicSession::OnSuccessfulVersionNegotiation( |
| 206 const QuicVersion& /*version*/) {} | 206 const QuicVersion& /*version*/) {} |
| 207 | 207 |
| 208 void QuicSession::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { | 208 void QuicSession::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { |
| 209 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't | 209 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 if (num_writes == 0) { | 253 if (num_writes == 0) { |
| 254 return; | 254 return; |
| 255 } | 255 } |
| 256 | 256 |
| 257 QuicConnection::ScopedPacketBundler ack_bundler(connection_.get(), | 257 QuicConnection::ScopedPacketBundler ack_bundler(connection_.get(), |
| 258 QuicConnection::NO_ACK); | 258 QuicConnection::NO_ACK); |
| 259 for (size_t i = 0; i < num_writes; ++i) { | 259 for (size_t i = 0; i < num_writes; ++i) { |
| 260 if (!(write_blocked_streams_.HasWriteBlockedCryptoOrHeadersStream() || | 260 if (!(write_blocked_streams_.HasWriteBlockedCryptoOrHeadersStream() || |
| 261 write_blocked_streams_.HasWriteBlockedDataStreams())) { | 261 write_blocked_streams_.HasWriteBlockedDataStreams())) { |
| 262 // Writing one stream removed another!? Something's broken. | 262 // Writing one stream removed another!? Something's broken. |
| 263 LOG(DFATAL) << "WriteBlockedStream is missing"; | 263 QUIC_BUG << "WriteBlockedStream is missing"; |
| 264 connection_->CloseConnection(QUIC_INTERNAL_ERROR, false); | 264 connection_->CloseConnection(QUIC_INTERNAL_ERROR, false); |
| 265 return; | 265 return; |
| 266 } | 266 } |
| 267 if (!connection_->CanWriteStreamData()) { | 267 if (!connection_->CanWriteStreamData()) { |
| 268 return; | 268 return; |
| 269 } | 269 } |
| 270 QuicStreamId stream_id = write_blocked_streams_.PopFront(); | 270 QuicStreamId stream_id = write_blocked_streams_.PopFront(); |
| 271 ReliableQuicStream* stream = GetStream(stream_id); | 271 ReliableQuicStream* stream = GetStream(stream_id); |
| 272 if (stream != nullptr && !stream->flow_controller()->IsBlocked()) { | 272 if (stream != nullptr && !stream->flow_controller()->IsBlocked()) { |
| 273 // If the stream can't write all bytes it'll re-add itself to the blocked | 273 // If the stream can't write all bytes it'll re-add itself to the blocked |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 QuicConsumedData data = connection_->SendStreamData( | 312 QuicConsumedData data = connection_->SendStreamData( |
| 313 id, iov, offset, fin, fec_protection, ack_notifier_delegate); | 313 id, iov, offset, fin, fec_protection, ack_notifier_delegate); |
| 314 write_blocked_streams_.UpdateBytesForStream(id, data.bytes_consumed); | 314 write_blocked_streams_.UpdateBytesForStream(id, data.bytes_consumed); |
| 315 return data; | 315 return data; |
| 316 } | 316 } |
| 317 | 317 |
| 318 void QuicSession::SendRstStream(QuicStreamId id, | 318 void QuicSession::SendRstStream(QuicStreamId id, |
| 319 QuicRstStreamErrorCode error, | 319 QuicRstStreamErrorCode error, |
| 320 QuicStreamOffset bytes_written) { | 320 QuicStreamOffset bytes_written) { |
| 321 if (ContainsKey(static_stream_map_, id)) { | 321 if (ContainsKey(static_stream_map_, id)) { |
| 322 LOG(DFATAL) << "Cannot send RST for a static stream with ID " << id; | 322 QUIC_BUG << "Cannot send RST for a static stream with ID " << id; |
| 323 return; | 323 return; |
| 324 } | 324 } |
| 325 | 325 |
| 326 if (connection()->connected()) { | 326 if (connection()->connected()) { |
| 327 // Only send a RST_STREAM frame if still connected. | 327 // Only send a RST_STREAM frame if still connected. |
| 328 connection_->SendRstStream(id, error, bytes_written); | 328 connection_->SendRstStream(id, error, bytes_written); |
| 329 } | 329 } |
| 330 CloseStreamInner(id, true); | 330 CloseStreamInner(id, true); |
| 331 } | 331 } |
| 332 | 332 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 void QuicSession::MarkConnectionLevelWriteBlocked(QuicStreamId id, | 769 void QuicSession::MarkConnectionLevelWriteBlocked(QuicStreamId id, |
| 770 SpdyPriority priority) { | 770 SpdyPriority priority) { |
| 771 #ifndef NDEBUG | 771 #ifndef NDEBUG |
| 772 ReliableQuicStream* stream = GetStream(id); | 772 ReliableQuicStream* stream = GetStream(id); |
| 773 if (stream != nullptr) { | 773 if (stream != nullptr) { |
| 774 LOG_IF(DFATAL, priority != stream->Priority()) | 774 LOG_IF(DFATAL, priority != stream->Priority()) |
| 775 << ENDPOINT << "Stream " << id | 775 << ENDPOINT << "Stream " << id |
| 776 << "Priorities do not match. Got: " << static_cast<int>(priority) | 776 << "Priorities do not match. Got: " << static_cast<int>(priority) |
| 777 << " Expected: " << static_cast<int>(stream->Priority()); | 777 << " Expected: " << static_cast<int>(stream->Priority()); |
| 778 } else { | 778 } else { |
| 779 LOG(DFATAL) << "Marking unknown stream " << id << " blocked."; | 779 QUIC_BUG << "Marking unknown stream " << id << " blocked."; |
| 780 } | 780 } |
| 781 #endif | 781 #endif |
| 782 | 782 |
| 783 write_blocked_streams_.AddStream(id, priority); | 783 write_blocked_streams_.AddStream(id, priority); |
| 784 } | 784 } |
| 785 | 785 |
| 786 bool QuicSession::HasDataToWrite() const { | 786 bool QuicSession::HasDataToWrite() const { |
| 787 return write_blocked_streams_.HasWriteBlockedCryptoOrHeadersStream() || | 787 return write_blocked_streams_.HasWriteBlockedCryptoOrHeadersStream() || |
| 788 write_blocked_streams_.HasWriteBlockedDataStreams() || | 788 write_blocked_streams_.HasWriteBlockedDataStreams() || |
| 789 connection_->HasQueuedData(); | 789 connection_->HasQueuedData(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 } | 823 } |
| 824 } | 824 } |
| 825 return false; | 825 return false; |
| 826 } | 826 } |
| 827 | 827 |
| 828 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 828 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
| 829 return id % 2 != next_outgoing_stream_id_ % 2; | 829 return id % 2 != next_outgoing_stream_id_ % 2; |
| 830 } | 830 } |
| 831 | 831 |
| 832 } // namespace net | 832 } // namespace net |
| OLD | NEW |