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/core/quic_session.h" | 5 #include "net/quic/core/quic_session.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 if (stream_id == kConnectionLevelId) { | 152 if (stream_id == kConnectionLevelId) { |
153 // This is a window update that applies to the connection, rather than an | 153 // This is a window update that applies to the connection, rather than an |
154 // individual stream. | 154 // individual stream. |
155 DVLOG(1) << ENDPOINT << "Received connection level flow control window " | 155 DVLOG(1) << ENDPOINT << "Received connection level flow control window " |
156 "update with byte offset: " | 156 "update with byte offset: " |
157 << frame.byte_offset; | 157 << frame.byte_offset; |
158 flow_controller_.UpdateSendWindowOffset(frame.byte_offset); | 158 flow_controller_.UpdateSendWindowOffset(frame.byte_offset); |
159 return; | 159 return; |
160 } | 160 } |
161 ReliableQuicStream* stream = GetOrCreateStream(stream_id); | 161 ReliableQuicStream* stream = GetOrCreateStream(stream_id); |
162 if (stream) { | 162 if (stream != nullptr) { |
163 stream->OnWindowUpdateFrame(frame); | 163 stream->OnWindowUpdateFrame(frame); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void QuicSession::OnBlockedFrame(const QuicBlockedFrame& frame) { | 167 void QuicSession::OnBlockedFrame(const QuicBlockedFrame& frame) { |
168 // TODO(rjshade): Compare our flow control receive windows for specified | 168 // TODO(rjshade): Compare our flow control receive windows for specified |
169 // streams: if we have a large window then maybe something | 169 // streams: if we have a large window then maybe something |
170 // had gone wrong with the flow control accounting. | 170 // had gone wrong with the flow control accounting. |
171 DVLOG(1) << ENDPOINT | 171 DVLOG(1) << ENDPOINT |
172 << "Received BLOCKED frame with stream id: " << frame.stream_id; | 172 << "Received BLOCKED frame with stream id: " << frame.stream_id; |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 } | 624 } |
625 | 625 |
626 // Check if the new number of available streams would cause the number of | 626 // Check if the new number of available streams would cause the number of |
627 // available streams to exceed the limit. Note that the peer can create | 627 // available streams to exceed the limit. Note that the peer can create |
628 // only alternately-numbered streams. | 628 // only alternately-numbered streams. |
629 size_t additional_available_streams = | 629 size_t additional_available_streams = |
630 (stream_id - largest_peer_created_stream_id_) / 2 - 1; | 630 (stream_id - largest_peer_created_stream_id_) / 2 - 1; |
631 size_t new_num_available_streams = | 631 size_t new_num_available_streams = |
632 GetNumAvailableStreams() + additional_available_streams; | 632 GetNumAvailableStreams() + additional_available_streams; |
633 if (new_num_available_streams > MaxAvailableStreams()) { | 633 if (new_num_available_streams > MaxAvailableStreams()) { |
634 DVLOG(1) << "Failed to create a new incoming stream with id:" << stream_id | 634 DVLOG(1) << ENDPOINT |
| 635 << "Failed to create a new incoming stream with id:" << stream_id |
635 << ". There are already " << GetNumAvailableStreams() | 636 << ". There are already " << GetNumAvailableStreams() |
636 << " streams available, which would become " | 637 << " streams available, which would become " |
637 << new_num_available_streams << ", which exceeds the limit " | 638 << new_num_available_streams << ", which exceeds the limit " |
638 << MaxAvailableStreams() << "."; | 639 << MaxAvailableStreams() << "."; |
639 string details = IntToString(new_num_available_streams) + " above " + | 640 string details = IntToString(new_num_available_streams) + " above " + |
640 IntToString(MaxAvailableStreams()); | 641 IntToString(MaxAvailableStreams()); |
641 connection()->CloseConnection( | 642 connection()->CloseConnection( |
642 QUIC_TOO_MANY_AVAILABLE_STREAMS, details.c_str(), | 643 QUIC_TOO_MANY_AVAILABLE_STREAMS, details.c_str(), |
643 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 644 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
644 return false; | 645 return false; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 | 820 |
820 size_t QuicSession::MaxAvailableStreams() const { | 821 size_t QuicSession::MaxAvailableStreams() const { |
821 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; | 822 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; |
822 } | 823 } |
823 | 824 |
824 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 825 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
825 return id % 2 != next_outgoing_stream_id_ % 2; | 826 return id % 2 != next_outgoing_stream_id_ % 2; |
826 } | 827 } |
827 | 828 |
828 } // namespace net | 829 } // namespace net |
OLD | NEW |