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/core/quic_spdy_stream.h" | 5 #include "net/quic/core/quic_spdy_stream.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // Tell the peer to stop sending further data. | 54 // Tell the peer to stop sending further data. |
55 DVLOG(1) << ENDPOINT << "Send QUIC_STREAM_NO_ERROR on stream " << id(); | 55 DVLOG(1) << ENDPOINT << "Send QUIC_STREAM_NO_ERROR on stream " << id(); |
56 Reset(QUIC_STREAM_NO_ERROR); | 56 Reset(QUIC_STREAM_NO_ERROR); |
57 } | 57 } |
58 QuicStream::StopReading(); | 58 QuicStream::StopReading(); |
59 } | 59 } |
60 | 60 |
61 size_t QuicSpdyStream::WriteHeaders( | 61 size_t QuicSpdyStream::WriteHeaders( |
62 SpdyHeaderBlock header_block, | 62 SpdyHeaderBlock header_block, |
63 bool fin, | 63 bool fin, |
64 QuicAckListenerInterface* ack_notifier_delegate) { | 64 const scoped_refptr<QuicAckListenerInterface>& ack_notifier_delegate) { |
65 size_t bytes_written = spdy_session_->WriteHeaders( | 65 size_t bytes_written = spdy_session_->WriteHeaders( |
66 id(), std::move(header_block), fin, priority_, ack_notifier_delegate); | 66 id(), std::move(header_block), fin, priority_, ack_notifier_delegate); |
67 if (fin) { | 67 if (fin) { |
68 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent. | 68 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent. |
69 set_fin_sent(true); | 69 set_fin_sent(true); |
70 CloseWriteSide(); | 70 CloseWriteSide(); |
71 } | 71 } |
72 return bytes_written; | 72 return bytes_written; |
73 } | 73 } |
74 | 74 |
75 void QuicSpdyStream::WriteOrBufferBody( | 75 void QuicSpdyStream::WriteOrBufferBody( |
76 const string& data, | 76 const string& data, |
77 bool fin, | 77 bool fin, |
78 QuicAckListenerInterface* ack_notifier_delegate) { | 78 const scoped_refptr<QuicAckListenerInterface>& ack_notifier_delegate) { |
79 WriteOrBufferData(data, fin, ack_notifier_delegate); | 79 WriteOrBufferData(data, fin, ack_notifier_delegate); |
80 } | 80 } |
81 | 81 |
82 size_t QuicSpdyStream::WriteTrailers( | 82 size_t QuicSpdyStream::WriteTrailers( |
83 SpdyHeaderBlock trailer_block, | 83 SpdyHeaderBlock trailer_block, |
84 QuicAckListenerInterface* ack_notifier_delegate) { | 84 const scoped_refptr<QuicAckListenerInterface>& ack_notifier_delegate) { |
85 if (fin_sent()) { | 85 if (fin_sent()) { |
86 QUIC_BUG << "Trailers cannot be sent after a FIN."; | 86 QUIC_BUG << "Trailers cannot be sent after a FIN."; |
87 return 0; | 87 return 0; |
88 } | 88 } |
89 | 89 |
90 // The header block must contain the final offset for this stream, as the | 90 // The header block must contain the final offset for this stream, as the |
91 // trailers may be processed out of order at the peer. | 91 // trailers may be processed out of order at the peer. |
92 DVLOG(1) << "Inserting trailer: (" << kFinalOffsetHeaderKey << ", " | 92 DVLOG(1) << "Inserting trailer: (" << kFinalOffsetHeaderKey << ", " |
93 << stream_bytes_written() + queued_data_bytes() << ")"; | 93 << stream_bytes_written() + queued_data_bytes() << ")"; |
94 trailer_block.insert(std::make_pair( | 94 trailer_block.insert(std::make_pair( |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 } | 323 } |
324 | 324 |
325 void QuicSpdyStream::ClearSession() { | 325 void QuicSpdyStream::ClearSession() { |
326 spdy_session_ = nullptr; | 326 spdy_session_ = nullptr; |
327 } | 327 } |
328 | 328 |
329 QuicConsumedData QuicSpdyStream::WritevDataInner( | 329 QuicConsumedData QuicSpdyStream::WritevDataInner( |
330 QuicIOVector iov, | 330 QuicIOVector iov, |
331 QuicStreamOffset offset, | 331 QuicStreamOffset offset, |
332 bool fin, | 332 bool fin, |
333 QuicAckListenerInterface* ack_notifier_delegate) { | 333 const scoped_refptr<QuicAckListenerInterface>& ack_notifier_delegate) { |
334 if (spdy_session_->headers_stream() != nullptr && | 334 if (spdy_session_->headers_stream() != nullptr && |
335 spdy_session_->force_hol_blocking()) { | 335 spdy_session_->force_hol_blocking()) { |
336 return spdy_session_->headers_stream()->WritevStreamData( | 336 return spdy_session_->headers_stream()->WritevStreamData( |
337 id(), iov, offset, fin, ack_notifier_delegate); | 337 id(), iov, offset, fin, ack_notifier_delegate); |
338 } | 338 } |
339 return QuicStream::WritevDataInner(iov, offset, fin, ack_notifier_delegate); | 339 return QuicStream::WritevDataInner(iov, offset, fin, ack_notifier_delegate); |
340 } | 340 } |
341 | 341 |
342 } // namespace net | 342 } // namespace net |
OLD | NEW |