OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_spdy_stream.h" | 5 #include "net/quic/quic_spdy_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/quic/quic_spdy_session.h" | 8 #include "net/quic/quic_spdy_session.h" |
9 #include "net/quic/quic_utils.h" | 9 #include "net/quic/quic_utils.h" |
10 #include "net/quic/quic_write_blocked_list.h" | 10 #include "net/quic/quic_write_blocked_list.h" |
11 | 11 |
12 using base::StringPiece; | 12 using base::StringPiece; |
13 using std::min; | 13 using std::min; |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
| 17 #define ENDPOINT \ |
| 18 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ |
| 19 " ") |
| 20 |
17 namespace { | 21 namespace { |
18 | 22 |
19 // This is somewhat arbitrary. It's possible, but unlikely, we will either fail | 23 // This is somewhat arbitrary. It's possible, but unlikely, we will either fail |
20 // to set a priority client-side, or cancel a stream before stripping the | 24 // to set a priority client-side, or cancel a stream before stripping the |
21 // priority from the wire server-side. In either case, start out with a | 25 // priority from the wire server-side. In either case, start out with a |
22 // priority in the middle. | 26 // priority in the middle. |
23 QuicPriority kDefaultPriority = 3; | 27 QuicPriority kDefaultPriority = 3; |
24 | 28 |
25 } // namespace | 29 } // namespace |
26 | 30 |
27 QuicSpdyStream::QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session) | 31 QuicSpdyStream::QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session) |
28 : ReliableQuicStream(id, spdy_session), | 32 : ReliableQuicStream(id, spdy_session), |
29 spdy_session_(spdy_session), | 33 spdy_session_(spdy_session), |
30 visitor_(nullptr), | 34 visitor_(nullptr), |
31 headers_decompressed_(false), | 35 headers_decompressed_(false), |
32 priority_(kDefaultPriority) { | 36 priority_(kDefaultPriority) { |
33 DCHECK_NE(kCryptoStreamId, id); | 37 DCHECK_NE(kCryptoStreamId, id); |
34 // Don't receive any callbacks from the sequencer until headers | 38 // Don't receive any callbacks from the sequencer until headers |
35 // are complete. | 39 // are complete. |
36 sequencer()->SetBlockedUntilFlush(); | 40 sequencer()->SetBlockedUntilFlush(); |
37 } | 41 } |
38 | 42 |
39 QuicSpdyStream::~QuicSpdyStream() {} | 43 QuicSpdyStream::~QuicSpdyStream() {} |
40 | 44 |
| 45 void QuicSpdyStream::CloseWriteSide() { |
| 46 if (version() > QUIC_VERSION_28 && !fin_received() && !rst_received() && |
| 47 sequencer()->ignore_read_data() && !rst_sent()) { |
| 48 DCHECK(fin_sent()); |
| 49 // Tell the peer to stop sending further data. |
| 50 DVLOG(1) << ENDPOINT << "Send QUIC_STREAM_NO_ERROR on stream " << id(); |
| 51 Reset(QUIC_STREAM_NO_ERROR); |
| 52 } |
| 53 |
| 54 ReliableQuicStream::CloseWriteSide(); |
| 55 } |
| 56 |
41 size_t QuicSpdyStream::WriteHeaders( | 57 size_t QuicSpdyStream::WriteHeaders( |
42 const SpdyHeaderBlock& header_block, | 58 const SpdyHeaderBlock& header_block, |
43 bool fin, | 59 bool fin, |
44 QuicAckListenerInterface* ack_notifier_delegate) { | 60 QuicAckListenerInterface* ack_notifier_delegate) { |
45 size_t bytes_written = spdy_session_->WriteHeaders( | 61 size_t bytes_written = spdy_session_->WriteHeaders( |
46 id(), header_block, fin, priority_, ack_notifier_delegate); | 62 id(), header_block, fin, priority_, ack_notifier_delegate); |
47 if (fin) { | 63 if (fin) { |
48 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent. | 64 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent. |
49 set_fin_sent(true); | 65 set_fin_sent(true); |
50 CloseWriteSide(); | 66 CloseWriteSide(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 visitor_ = nullptr; | 152 visitor_ = nullptr; |
137 visitor->OnClose(this); | 153 visitor->OnClose(this); |
138 } | 154 } |
139 } | 155 } |
140 | 156 |
141 bool QuicSpdyStream::FinishedReadingHeaders() const { | 157 bool QuicSpdyStream::FinishedReadingHeaders() const { |
142 return headers_decompressed_ && decompressed_headers_.empty(); | 158 return headers_decompressed_ && decompressed_headers_.empty(); |
143 } | 159 } |
144 | 160 |
145 } // namespace net | 161 } // namespace net |
OLD | NEW |