| 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/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "net/quic/crypto/proof_verifier.h" | 10 #include "net/quic/crypto/proof_verifier.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 void QuicSession::OnConnectionClosed(QuicErrorCode error, | 115 void QuicSession::OnConnectionClosed(QuicErrorCode error, |
| 116 const string& /*error_details*/, | 116 const string& /*error_details*/, |
| 117 ConnectionCloseSource source) { | 117 ConnectionCloseSource source) { |
| 118 DCHECK(!connection_->connected()); | 118 DCHECK(!connection_->connected()); |
| 119 if (error_ == QUIC_NO_ERROR) { | 119 if (error_ == QUIC_NO_ERROR) { |
| 120 error_ = error; | 120 error_ = error; |
| 121 } | 121 } |
| 122 | 122 |
| 123 while (!dynamic_stream_map_.empty()) { | 123 while (!dynamic_stream_map_.empty()) { |
| 124 StreamMap::iterator it = dynamic_stream_map_.begin(); | 124 DynamicStreamMap::iterator it = dynamic_stream_map_.begin(); |
| 125 QuicStreamId id = it->first; | 125 QuicStreamId id = it->first; |
| 126 it->second->OnConnectionClosed(error, source); | 126 it->second->OnConnectionClosed(error, source); |
| 127 // The stream should call CloseStream as part of OnConnectionClosed. | 127 // The stream should call CloseStream as part of OnConnectionClosed. |
| 128 if (dynamic_stream_map_.find(id) != dynamic_stream_map_.end()) { | 128 if (dynamic_stream_map_.find(id) != dynamic_stream_map_.end()) { |
| 129 QUIC_BUG << ENDPOINT << "Stream failed to close under OnConnectionClosed"; | 129 QUIC_BUG << ENDPOINT << "Stream failed to close under OnConnectionClosed"; |
| 130 CloseStream(id); | 130 CloseStream(id); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 QuicStreamOffset offset) { | 301 QuicStreamOffset offset) { |
| 302 locally_closed_streams_highest_offset_[id] = offset; | 302 locally_closed_streams_highest_offset_[id] = offset; |
| 303 if (IsIncomingStream(id)) { | 303 if (IsIncomingStream(id)) { |
| 304 ++num_locally_closed_incoming_streams_highest_offset_; | 304 ++num_locally_closed_incoming_streams_highest_offset_; |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 void QuicSession::CloseStreamInner(QuicStreamId stream_id, bool locally_reset) { | 308 void QuicSession::CloseStreamInner(QuicStreamId stream_id, bool locally_reset) { |
| 309 DVLOG(1) << ENDPOINT << "Closing stream " << stream_id; | 309 DVLOG(1) << ENDPOINT << "Closing stream " << stream_id; |
| 310 | 310 |
| 311 StreamMap::iterator it = dynamic_stream_map_.find(stream_id); | 311 DynamicStreamMap::iterator it = dynamic_stream_map_.find(stream_id); |
| 312 if (it == dynamic_stream_map_.end()) { | 312 if (it == dynamic_stream_map_.end()) { |
| 313 // When CloseStreamInner has been called recursively (via | 313 // When CloseStreamInner has been called recursively (via |
| 314 // ReliableQuicStream::OnClose), the stream will already have been deleted | 314 // ReliableQuicStream::OnClose), the stream will already have been deleted |
| 315 // from stream_map_, so return immediately. | 315 // from stream_map_, so return immediately. |
| 316 DVLOG(1) << ENDPOINT << "Stream is already closed: " << stream_id; | 316 DVLOG(1) << ENDPOINT << "Stream is already closed: " << stream_id; |
| 317 return; | 317 return; |
| 318 } | 318 } |
| 319 ReliableQuicStream* stream = it->second; | 319 ReliableQuicStream* stream = it->second; |
| 320 | 320 |
| 321 // Tell the stream that a RST has been sent. | 321 // Tell the stream that a RST has been sent. |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 } | 608 } |
| 609 | 609 |
| 610 QuicStreamId QuicSession::GetNextOutgoingStreamId() { | 610 QuicStreamId QuicSession::GetNextOutgoingStreamId() { |
| 611 QuicStreamId id = next_outgoing_stream_id_; | 611 QuicStreamId id = next_outgoing_stream_id_; |
| 612 next_outgoing_stream_id_ += 2; | 612 next_outgoing_stream_id_ += 2; |
| 613 return id; | 613 return id; |
| 614 } | 614 } |
| 615 | 615 |
| 616 ReliableQuicStream* QuicSession::GetOrCreateStream( | 616 ReliableQuicStream* QuicSession::GetOrCreateStream( |
| 617 const QuicStreamId stream_id) { | 617 const QuicStreamId stream_id) { |
| 618 StreamMap::iterator it = static_stream_map_.find(stream_id); | 618 StaticStreamMap::iterator it = static_stream_map_.find(stream_id); |
| 619 if (it != static_stream_map_.end()) { | 619 if (it != static_stream_map_.end()) { |
| 620 return it->second; | 620 return it->second; |
| 621 } | 621 } |
| 622 return GetOrCreateDynamicStream(stream_id); | 622 return GetOrCreateDynamicStream(stream_id); |
| 623 } | 623 } |
| 624 | 624 |
| 625 void QuicSession::StreamDraining(QuicStreamId stream_id) { | 625 void QuicSession::StreamDraining(QuicStreamId stream_id) { |
| 626 DCHECK(ContainsKey(dynamic_stream_map_, stream_id)); | 626 DCHECK(ContainsKey(dynamic_stream_map_, stream_id)); |
| 627 if (!ContainsKey(draining_streams_, stream_id)) { | 627 if (!ContainsKey(draining_streams_, stream_id)) { |
| 628 draining_streams_.insert(stream_id); | 628 draining_streams_.insert(stream_id); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 return false; | 672 return false; |
| 673 } | 673 } |
| 674 return write_blocked_streams()->ShouldYield(stream_id); | 674 return write_blocked_streams()->ShouldYield(stream_id); |
| 675 } | 675 } |
| 676 | 676 |
| 677 ReliableQuicStream* QuicSession::GetOrCreateDynamicStream( | 677 ReliableQuicStream* QuicSession::GetOrCreateDynamicStream( |
| 678 const QuicStreamId stream_id) { | 678 const QuicStreamId stream_id) { |
| 679 DCHECK(!ContainsKey(static_stream_map_, stream_id)) | 679 DCHECK(!ContainsKey(static_stream_map_, stream_id)) |
| 680 << "Attempt to call GetOrCreateDynamicStream for a static stream"; | 680 << "Attempt to call GetOrCreateDynamicStream for a static stream"; |
| 681 | 681 |
| 682 StreamMap::iterator it = dynamic_stream_map_.find(stream_id); | 682 DynamicStreamMap::iterator it = dynamic_stream_map_.find(stream_id); |
| 683 if (it != dynamic_stream_map_.end()) { | 683 if (it != dynamic_stream_map_.end()) { |
| 684 return it->second; | 684 return it->second; |
| 685 } | 685 } |
| 686 | 686 |
| 687 if (IsClosedStream(stream_id)) { | 687 if (IsClosedStream(stream_id)) { |
| 688 return nullptr; | 688 return nullptr; |
| 689 } | 689 } |
| 690 | 690 |
| 691 if (!IsIncomingStream(stream_id)) { | 691 if (!IsIncomingStream(stream_id)) { |
| 692 HandleFrameOnNonexistentOutgoingStream(stream_id); | 692 HandleFrameOnNonexistentOutgoingStream(stream_id); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 | 833 |
| 834 size_t QuicSession::MaxAvailableStreams() const { | 834 size_t QuicSession::MaxAvailableStreams() const { |
| 835 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; | 835 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; |
| 836 } | 836 } |
| 837 | 837 |
| 838 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 838 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
| 839 return id % 2 != next_outgoing_stream_id_ % 2; | 839 return id % 2 != next_outgoing_stream_id_ % 2; |
| 840 } | 840 } |
| 841 | 841 |
| 842 } // namespace net | 842 } // namespace net |
| OLD | NEW |