OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_reliable_client_stream.h" | 5 #include "net/quic/quic_reliable_client_stream.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/quic/quic_spdy_session.h" | 12 #include "net/quic/quic_spdy_session.h" |
13 #include "net/quic/quic_write_blocked_list.h" | 13 #include "net/quic/quic_write_blocked_list.h" |
14 #include "net/quic/spdy_utils.h" | 14 #include "net/quic/spdy_utils.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 QuicReliableClientStream::QuicReliableClientStream(QuicStreamId id, | 18 QuicReliableClientStream::QuicReliableClientStream(QuicStreamId id, |
19 QuicSpdySession* session, | 19 QuicSpdySession* session, |
20 const BoundNetLog& net_log) | 20 const BoundNetLog& net_log) |
21 : QuicDataStream(id, session), | 21 : QuicSpdyStream(id, session), |
22 net_log_(net_log), | 22 net_log_(net_log), |
23 delegate_(nullptr), | 23 delegate_(nullptr), |
24 headers_delivered_(false), | 24 headers_delivered_(false), |
25 weak_factory_(this) {} | 25 weak_factory_(this) {} |
26 | 26 |
27 QuicReliableClientStream::~QuicReliableClientStream() { | 27 QuicReliableClientStream::~QuicReliableClientStream() { |
28 if (delegate_) | 28 if (delegate_) |
29 delegate_->OnClose(connection_error()); | 29 delegate_->OnClose(connection_error()); |
30 } | 30 } |
31 | 31 |
32 void QuicReliableClientStream::OnStreamHeadersComplete(bool fin, | 32 void QuicReliableClientStream::OnStreamHeadersComplete(bool fin, |
33 size_t frame_len) { | 33 size_t frame_len) { |
34 QuicDataStream::OnStreamHeadersComplete(fin, frame_len); | 34 QuicSpdyStream::OnStreamHeadersComplete(fin, frame_len); |
35 // The delegate will read the headers via a posted task. | 35 // The delegate will read the headers via a posted task. |
36 NotifyDelegateOfHeadersCompleteLater(frame_len); | 36 NotifyDelegateOfHeadersCompleteLater(frame_len); |
37 } | 37 } |
38 | 38 |
39 void QuicReliableClientStream::OnDataAvailable() { | 39 void QuicReliableClientStream::OnDataAvailable() { |
40 // TODO(rch): buffer data if we don't have a delegate. | 40 // TODO(rch): buffer data if we don't have a delegate. |
41 if (!delegate_) { | 41 if (!delegate_) { |
42 DLOG(ERROR) << "Missing delegate"; | 42 DLOG(ERROR) << "Missing delegate"; |
43 Reset(QUIC_STREAM_CANCELLED); | 43 Reset(QUIC_STREAM_CANCELLED); |
44 return; | 44 return; |
(...skipping 20 matching lines...) Expand all Loading... |
65 void QuicReliableClientStream::OnCanWrite() { | 65 void QuicReliableClientStream::OnCanWrite() { |
66 ReliableQuicStream::OnCanWrite(); | 66 ReliableQuicStream::OnCanWrite(); |
67 | 67 |
68 if (!HasBufferedData() && !callback_.is_null()) { | 68 if (!HasBufferedData() && !callback_.is_null()) { |
69 base::ResetAndReturn(&callback_).Run(OK); | 69 base::ResetAndReturn(&callback_).Run(OK); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 QuicPriority QuicReliableClientStream::EffectivePriority() const { | 73 QuicPriority QuicReliableClientStream::EffectivePriority() const { |
74 if (delegate_ && delegate_->HasSendHeadersComplete()) { | 74 if (delegate_ && delegate_->HasSendHeadersComplete()) { |
75 return QuicDataStream::EffectivePriority(); | 75 return QuicSpdyStream::EffectivePriority(); |
76 } | 76 } |
77 return QuicWriteBlockedList::kHighestPriority; | 77 return QuicWriteBlockedList::kHighestPriority; |
78 } | 78 } |
79 | 79 |
80 int QuicReliableClientStream::WriteStreamData( | 80 int QuicReliableClientStream::WriteStreamData( |
81 base::StringPiece data, | 81 base::StringPiece data, |
82 bool fin, | 82 bool fin, |
83 const CompletionCallback& callback) { | 83 const CompletionCallback& callback) { |
84 // We should not have data buffered. | 84 // We should not have data buffered. |
85 DCHECK(!HasBufferedData()); | 85 DCHECK(!HasBufferedData()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 base::Bind(&QuicReliableClientStream::NotifyDelegateOfDataAvailable, | 170 base::Bind(&QuicReliableClientStream::NotifyDelegateOfDataAvailable, |
171 weak_factory_.GetWeakPtr())); | 171 weak_factory_.GetWeakPtr())); |
172 } | 172 } |
173 | 173 |
174 void QuicReliableClientStream::NotifyDelegateOfDataAvailable() { | 174 void QuicReliableClientStream::NotifyDelegateOfDataAvailable() { |
175 if (delegate_) | 175 if (delegate_) |
176 delegate_->OnDataAvailable(); | 176 delegate_->OnDataAvailable(); |
177 } | 177 } |
178 | 178 |
179 } // namespace net | 179 } // namespace net |
OLD | NEW |