| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_client_session_base.h" | 5 #include "net/quic/core/quic_client_session_base.h" |
| 6 | 6 |
| 7 #include "net/quic/core/quic_client_promised_info.h" | 7 #include "net/quic/core/quic_client_promised_info.h" |
| 8 #include "net/quic/core/quic_flags.h" | 8 #include "net/quic/core/quic_flags.h" |
| 9 #include "net/quic/core/spdy_utils.h" | 9 #include "net/quic/core/spdy_utils.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 void QuicClientSessionBase::OnConfigNegotiated() { | 33 void QuicClientSessionBase::OnConfigNegotiated() { |
| 34 QuicSpdySession::OnConfigNegotiated(); | 34 QuicSpdySession::OnConfigNegotiated(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void QuicClientSessionBase::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { | 37 void QuicClientSessionBase::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { |
| 38 QuicSession::OnCryptoHandshakeEvent(event); | 38 QuicSession::OnCryptoHandshakeEvent(event); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void QuicClientSessionBase::OnPromiseHeaders(QuicStreamId stream_id, | |
| 42 StringPiece headers_data) { | |
| 43 QuicSpdyStream* stream = GetSpdyDataStream(stream_id); | |
| 44 if (!stream) { | |
| 45 // It's quite possible to receive headers after a stream has been reset. | |
| 46 return; | |
| 47 } | |
| 48 stream->OnPromiseHeaders(headers_data); | |
| 49 } | |
| 50 | |
| 51 void QuicClientSessionBase::OnInitialHeadersComplete( | 41 void QuicClientSessionBase::OnInitialHeadersComplete( |
| 52 QuicStreamId stream_id, | 42 QuicStreamId stream_id, |
| 53 const SpdyHeaderBlock& response_headers) { | 43 const SpdyHeaderBlock& response_headers) { |
| 54 // Note that the strong ordering of the headers stream means that | 44 // Note that the strong ordering of the headers stream means that |
| 55 // QuicSpdyClientStream::OnPromiseHeadersComplete must have already | 45 // QuicSpdyClientStream::OnPromiseHeadersComplete must have already |
| 56 // been called (on the associated stream) if this is a promised | 46 // been called (on the associated stream) if this is a promised |
| 57 // stream. However, this stream may not have existed at this time, | 47 // stream. However, this stream may not have existed at this time, |
| 58 // hence the need to query the session. | 48 // hence the need to query the session. |
| 59 QuicClientPromisedInfo* promised = GetPromisedById(stream_id); | 49 QuicClientPromisedInfo* promised = GetPromisedById(stream_id); |
| 60 if (!promised) | 50 if (!promised) |
| 61 return; | 51 return; |
| 62 | 52 |
| 63 promised->OnResponseHeaders(response_headers); | 53 promised->OnResponseHeaders(response_headers); |
| 64 } | 54 } |
| 65 | 55 |
| 66 void QuicClientSessionBase::OnPromiseHeadersComplete( | |
| 67 QuicStreamId stream_id, | |
| 68 QuicStreamId promised_stream_id, | |
| 69 size_t frame_len) { | |
| 70 if (promised_stream_id != kInvalidStreamId && | |
| 71 promised_stream_id <= largest_promised_stream_id_) { | |
| 72 connection()->CloseConnection( | |
| 73 QUIC_INVALID_STREAM_ID, | |
| 74 "Received push stream id lesser or equal to the" | |
| 75 " last accepted before", | |
| 76 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | |
| 77 return; | |
| 78 } | |
| 79 largest_promised_stream_id_ = promised_stream_id; | |
| 80 | |
| 81 QuicSpdyStream* stream = GetSpdyDataStream(stream_id); | |
| 82 if (!stream) { | |
| 83 // It's quite possible to receive headers after a stream has been reset. | |
| 84 return; | |
| 85 } | |
| 86 stream->OnPromiseHeadersComplete(promised_stream_id, frame_len); | |
| 87 } | |
| 88 | |
| 89 void QuicClientSessionBase::OnPromiseHeaderList( | 56 void QuicClientSessionBase::OnPromiseHeaderList( |
| 90 QuicStreamId stream_id, | 57 QuicStreamId stream_id, |
| 91 QuicStreamId promised_stream_id, | 58 QuicStreamId promised_stream_id, |
| 92 size_t frame_len, | 59 size_t frame_len, |
| 93 const QuicHeaderList& header_list) { | 60 const QuicHeaderList& header_list) { |
| 94 if (promised_stream_id != kInvalidStreamId && | 61 if (promised_stream_id != kInvalidStreamId && |
| 95 promised_stream_id <= largest_promised_stream_id_) { | 62 promised_stream_id <= largest_promised_stream_id_) { |
| 96 connection()->CloseConnection( | 63 connection()->CloseConnection( |
| 97 QUIC_INVALID_STREAM_ID, | 64 QUIC_INVALID_STREAM_ID, |
| 98 "Received push stream id lesser or equal to the" | 65 "Received push stream id lesser or equal to the" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 bool locally_reset) { | 175 bool locally_reset) { |
| 209 QuicSpdySession::CloseStreamInner(stream_id, locally_reset); | 176 QuicSpdySession::CloseStreamInner(stream_id, locally_reset); |
| 210 headers_stream()->MaybeReleaseSequencerBuffer(); | 177 headers_stream()->MaybeReleaseSequencerBuffer(); |
| 211 } | 178 } |
| 212 | 179 |
| 213 bool QuicClientSessionBase::ShouldReleaseHeadersStreamSequencerBuffer() { | 180 bool QuicClientSessionBase::ShouldReleaseHeadersStreamSequencerBuffer() { |
| 214 return num_active_requests() == 0 && promised_by_id_.empty(); | 181 return num_active_requests() == 0 && promised_by_id_.empty(); |
| 215 } | 182 } |
| 216 | 183 |
| 217 } // namespace net | 184 } // namespace net |
| OLD | NEW |