Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: net/quic/quic_spdy_stream.cc

Issue 1437023002: Landing Recent QUIC changes until 2015-11-09 20:32 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_spdy_stream.h ('k') | net/quic/quic_stream_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
57 void QuicSpdyStream::StopReading() {
58 if (version() > QUIC_VERSION_28 && !fin_received() && !rst_received() &&
59 write_side_closed() && !rst_sent()) {
60 DCHECK(fin_sent());
61 // Tell the peer to stop sending further data.
62 DVLOG(1) << ENDPOINT << "Send QUIC_STREAM_NO_ERROR on stream " << id();
63 Reset(QUIC_STREAM_NO_ERROR);
64 }
65 ReliableQuicStream::StopReading();
66 }
67
41 size_t QuicSpdyStream::WriteHeaders( 68 size_t QuicSpdyStream::WriteHeaders(
42 const SpdyHeaderBlock& header_block, 69 const SpdyHeaderBlock& header_block,
43 bool fin, 70 bool fin,
44 QuicAckListenerInterface* ack_notifier_delegate) { 71 QuicAckListenerInterface* ack_notifier_delegate) {
45 size_t bytes_written = spdy_session_->WriteHeaders( 72 size_t bytes_written = spdy_session_->WriteHeaders(
46 id(), header_block, fin, priority_, ack_notifier_delegate); 73 id(), header_block, fin, priority_, ack_notifier_delegate);
47 if (fin) { 74 if (fin) {
48 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent. 75 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent.
49 set_fin_sent(true); 76 set_fin_sent(true);
50 CloseWriteSide(); 77 CloseWriteSide();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 visitor_ = nullptr; 163 visitor_ = nullptr;
137 visitor->OnClose(this); 164 visitor->OnClose(this);
138 } 165 }
139 } 166 }
140 167
141 bool QuicSpdyStream::FinishedReadingHeaders() const { 168 bool QuicSpdyStream::FinishedReadingHeaders() const {
142 return headers_decompressed_ && decompressed_headers_.empty(); 169 return headers_decompressed_ && decompressed_headers_.empty();
143 } 170 }
144 171
145 } // namespace net 172 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_spdy_stream.h ('k') | net/quic/quic_stream_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698