| 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 "net/quic/core/crypto/proof_verifier.h" | 10 #include "net/quic/core/crypto/proof_verifier.h" |
| 11 #include "net/quic/core/quic_bug_tracker.h" | 11 #include "net/quic/core/quic_bug_tracker.h" |
| 12 #include "net/quic/core/quic_connection.h" | 12 #include "net/quic/core/quic_connection.h" |
| 13 #include "net/quic/core/quic_flags.h" | 13 #include "net/quic/core/quic_flags.h" |
| 14 #include "net/quic/core/quic_flow_controller.h" | 14 #include "net/quic/core/quic_flow_controller.h" |
| 15 #include "net/quic/platform/api/quic_str_cat.h" |
| 15 | 16 |
| 16 using base::IntToString; | 17 using base::IntToString; |
| 17 using base::StringPiece; | 18 using base::StringPiece; |
| 18 using std::string; | 19 using std::string; |
| 19 using net::SpdyPriority; | 20 using net::SpdyPriority; |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| 22 | 23 |
| 23 #define ENDPOINT \ | 24 #define ENDPOINT \ |
| 24 (perspective() == Perspective::IS_SERVER ? "Server: " : " Client: ") | 25 (perspective() == Perspective::IS_SERVER ? "Server: " : " Client: ") |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 (stream_id - largest_peer_created_stream_id_) / 2 - 1; | 671 (stream_id - largest_peer_created_stream_id_) / 2 - 1; |
| 671 size_t new_num_available_streams = | 672 size_t new_num_available_streams = |
| 672 GetNumAvailableStreams() + additional_available_streams; | 673 GetNumAvailableStreams() + additional_available_streams; |
| 673 if (new_num_available_streams > MaxAvailableStreams()) { | 674 if (new_num_available_streams > MaxAvailableStreams()) { |
| 674 DVLOG(1) << ENDPOINT | 675 DVLOG(1) << ENDPOINT |
| 675 << "Failed to create a new incoming stream with id:" << stream_id | 676 << "Failed to create a new incoming stream with id:" << stream_id |
| 676 << ". There are already " << GetNumAvailableStreams() | 677 << ". There are already " << GetNumAvailableStreams() |
| 677 << " streams available, which would become " | 678 << " streams available, which would become " |
| 678 << new_num_available_streams << ", which exceeds the limit " | 679 << new_num_available_streams << ", which exceeds the limit " |
| 679 << MaxAvailableStreams() << "."; | 680 << MaxAvailableStreams() << "."; |
| 680 string details = IntToString(new_num_available_streams) + " above " + | |
| 681 IntToString(MaxAvailableStreams()); | |
| 682 connection()->CloseConnection( | 681 connection()->CloseConnection( |
| 683 QUIC_TOO_MANY_AVAILABLE_STREAMS, details.c_str(), | 682 QUIC_TOO_MANY_AVAILABLE_STREAMS, |
| 683 QuicStrCat(new_num_available_streams, " above ", MaxAvailableStreams()), |
| 684 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 684 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 685 return false; | 685 return false; |
| 686 } | 686 } |
| 687 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; id < stream_id; | 687 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; id < stream_id; |
| 688 id += 2) { | 688 id += 2) { |
| 689 available_streams_.insert(id); | 689 available_streams_.insert(id); |
| 690 } | 690 } |
| 691 largest_peer_created_stream_id_ = stream_id; | 691 largest_peer_created_stream_id_ = stream_id; |
| 692 | 692 |
| 693 return true; | 693 return true; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 860 |
| 861 size_t QuicSession::MaxAvailableStreams() const { | 861 size_t QuicSession::MaxAvailableStreams() const { |
| 862 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; | 862 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; |
| 863 } | 863 } |
| 864 | 864 |
| 865 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 865 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
| 866 return id % 2 != next_outgoing_stream_id_ % 2; | 866 return id % 2 != next_outgoing_stream_id_ % 2; |
| 867 } | 867 } |
| 868 | 868 |
| 869 } // namespace net | 869 } // namespace net |
| OLD | NEW |