| 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_data_stream.h" | 5 #include "net/quic/quic_data_stream.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/quic/quic_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 \ | 17 #define ENDPOINT \ |
| 18 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ | 18 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ |
| 19 " ") | 19 " ") |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // 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 |
| 24 // 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 |
| 25 // 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 |
| 26 // priority in the middle. | 26 // priority in the middle. |
| 27 QuicPriority kDefaultPriority = 3; | 27 QuicPriority kDefaultPriority = 3; |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 QuicDataStream::QuicDataStream(QuicStreamId id, QuicSession* session) | 31 QuicDataStream::QuicDataStream(QuicStreamId id, QuicSpdySession* spdy_session) |
| 32 : ReliableQuicStream(id, session), | 32 : ReliableQuicStream(id, spdy_session), |
| 33 spdy_session_(spdy_session), |
| 33 visitor_(nullptr), | 34 visitor_(nullptr), |
| 34 headers_decompressed_(false), | 35 headers_decompressed_(false), |
| 35 priority_(kDefaultPriority) { | 36 priority_(kDefaultPriority) { |
| 36 DCHECK_NE(kCryptoStreamId, id); | 37 DCHECK_NE(kCryptoStreamId, id); |
| 37 // Don't receive any callbacks from the sequencer until headers | 38 // Don't receive any callbacks from the sequencer until headers |
| 38 // are complete. | 39 // are complete. |
| 39 sequencer()->SetBlockedUntilFlush(); | 40 sequencer()->SetBlockedUntilFlush(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 QuicDataStream::~QuicDataStream() { | 43 QuicDataStream::~QuicDataStream() { |
| 43 } | 44 } |
| 44 | 45 |
| 45 size_t QuicDataStream::WriteHeaders( | 46 size_t QuicDataStream::WriteHeaders( |
| 46 const SpdyHeaderBlock& header_block, | 47 const SpdyHeaderBlock& header_block, |
| 47 bool fin, | 48 bool fin, |
| 48 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) { | 49 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) { |
| 49 size_t bytes_written = session()->WriteHeaders( | 50 size_t bytes_written = spdy_session_->WriteHeaders( |
| 50 id(), header_block, fin, priority_, ack_notifier_delegate); | 51 id(), header_block, fin, priority_, ack_notifier_delegate); |
| 51 if (fin) { | 52 if (fin) { |
| 52 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent. | 53 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent. |
| 53 set_fin_sent(true); | 54 set_fin_sent(true); |
| 54 CloseWriteSide(); | 55 CloseWriteSide(); |
| 55 } | 56 } |
| 56 return bytes_written; | 57 return bytes_written; |
| 57 } | 58 } |
| 58 | 59 |
| 59 size_t QuicDataStream::Readv(const struct iovec* iov, size_t iov_len) { | 60 size_t QuicDataStream::Readv(const struct iovec* iov, size_t iov_len) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 visitor_ = nullptr; | 170 visitor_ = nullptr; |
| 170 visitor->OnClose(this); | 171 visitor->OnClose(this); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 | 174 |
| 174 bool QuicDataStream::FinishedReadingHeaders() { | 175 bool QuicDataStream::FinishedReadingHeaders() { |
| 175 return headers_decompressed_ && decompressed_headers_.empty(); | 176 return headers_decompressed_ && decompressed_headers_.empty(); |
| 176 } | 177 } |
| 177 | 178 |
| 178 } // namespace net | 179 } // namespace net |
| OLD | NEW |