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 "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/quic/quic_session.h" | 9 #include "net/quic/quic_session.h" |
10 #include "net/quic/quic_write_blocked_list.h" | 10 #include "net/quic/quic_write_blocked_list.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 QuicReliableClientStream::QuicReliableClientStream(QuicStreamId id, | 14 QuicReliableClientStream::QuicReliableClientStream(QuicStreamId id, |
15 QuicSession* session, | 15 QuicSession* session, |
16 const BoundNetLog& net_log) | 16 const BoundNetLog& net_log) |
17 : QuicDataStream(id, session), | 17 : QuicDataStream(id, session), net_log_(net_log), delegate_(NULL) { |
18 net_log_(net_log), | |
19 delegate_(NULL) { | |
20 } | 18 } |
21 | 19 |
22 QuicReliableClientStream::~QuicReliableClientStream() { | 20 QuicReliableClientStream::~QuicReliableClientStream() { |
23 if (delegate_) | 21 if (delegate_) |
24 delegate_->OnClose(connection_error()); | 22 delegate_->OnClose(connection_error()); |
25 } | 23 } |
26 | 24 |
27 uint32 QuicReliableClientStream::ProcessData(const char* data, | 25 uint32 QuicReliableClientStream::ProcessData(const char* data, |
28 uint32 data_len) { | 26 uint32 data_len) { |
29 // TODO(rch): buffer data if we don't have a delegate. | 27 // TODO(rch): buffer data if we don't have a delegate. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 84 |
87 void QuicReliableClientStream::OnError(int error) { | 85 void QuicReliableClientStream::OnError(int error) { |
88 if (delegate_) { | 86 if (delegate_) { |
89 QuicReliableClientStream::Delegate* delegate = delegate_; | 87 QuicReliableClientStream::Delegate* delegate = delegate_; |
90 delegate_ = NULL; | 88 delegate_ = NULL; |
91 delegate->OnError(error); | 89 delegate->OnError(error); |
92 } | 90 } |
93 } | 91 } |
94 | 92 |
95 bool QuicReliableClientStream::CanWrite(const CompletionCallback& callback) { | 93 bool QuicReliableClientStream::CanWrite(const CompletionCallback& callback) { |
96 bool can_write = session()->connection()->CanWrite( | 94 bool can_write = session()->connection()->CanWrite( |
97 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, | 95 NOT_RETRANSMISSION, |
| 96 HAS_RETRANSMITTABLE_DATA, |
98 id() == kCryptoStreamId ? IS_HANDSHAKE : NOT_HANDSHAKE); | 97 id() == kCryptoStreamId ? IS_HANDSHAKE : NOT_HANDSHAKE); |
99 if (!can_write) { | 98 if (!can_write) { |
100 session()->MarkWriteBlocked(id(), EffectivePriority()); | 99 session()->MarkWriteBlocked(id(), EffectivePriority()); |
101 DCHECK(callback_.is_null()); | 100 DCHECK(callback_.is_null()); |
102 callback_ = callback; | 101 callback_ = callback; |
103 } | 102 } |
104 return can_write; | 103 return can_write; |
105 } | 104 } |
106 | 105 |
107 } // namespace net | 106 } // namespace net |
OLD | NEW |