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/tools/quic/quic_spdy_client_stream.h" | 5 #include "net/tools/quic/quic_spdy_client_stream.h" |
6 | 6 |
7 #include "net/spdy/spdy_framer.h" | 7 #include "net/spdy/spdy_framer.h" |
8 #include "net/tools/quic/quic_client_session.h" | 8 #include "net/tools/quic/quic_client_session.h" |
9 #include "net/tools/quic/spdy_utils.h" | 9 #include "net/tools/quic/spdy_utils.h" |
10 | 10 |
11 using base::StringPiece; | 11 using base::StringPiece; |
12 using std::string; | 12 using std::string; |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 namespace tools { | 15 namespace tools { |
16 | 16 |
17 static const size_t kHeaderBufInitialSize = 4096; | 17 static const size_t kHeaderBufInitialSize = 4096; |
18 | 18 |
19 QuicSpdyClientStream::QuicSpdyClientStream(QuicStreamId id, | 19 QuicSpdyClientStream::QuicSpdyClientStream(QuicStreamId id, |
20 QuicClientSession* session) | 20 QuicClientSession* session) |
21 : ReliableQuicStream(id, session), | 21 : QuicDataStream(id, session), |
22 read_buf_(new GrowableIOBuffer()), | 22 read_buf_(new GrowableIOBuffer()), |
23 response_headers_received_(false) { | 23 response_headers_received_(false) { |
24 } | 24 } |
25 | 25 |
26 QuicSpdyClientStream::~QuicSpdyClientStream() { | 26 QuicSpdyClientStream::~QuicSpdyClientStream() { |
27 } | 27 } |
28 | 28 |
29 bool QuicSpdyClientStream::OnStreamFrame(const QuicStreamFrame& frame) { | 29 bool QuicSpdyClientStream::OnStreamFrame(const QuicStreamFrame& frame) { |
30 if (!write_side_closed()) { | 30 if (!write_side_closed()) { |
31 DLOG(INFO) << "Got a response before the request was complete. " | 31 DLOG(INFO) << "Got a response before the request was complete. " |
32 << "Aborting request."; | 32 << "Aborting request."; |
33 CloseWriteSide(); | 33 CloseWriteSide(); |
34 } | 34 } |
35 return ReliableQuicStream::OnStreamFrame(frame); | 35 return QuicDataStream::OnStreamFrame(frame); |
36 } | 36 } |
37 | 37 |
38 uint32 QuicSpdyClientStream::ProcessData(const char* data, uint32 length) { | 38 uint32 QuicSpdyClientStream::ProcessData(const char* data, uint32 length) { |
39 uint32 total_bytes_processed = 0; | 39 uint32 total_bytes_processed = 0; |
40 | 40 |
41 // Are we still reading the response headers. | 41 // Are we still reading the response headers. |
42 if (!response_headers_received_) { | 42 if (!response_headers_received_) { |
43 // Grow the read buffer if necessary. | 43 // Grow the read buffer if necessary. |
44 if (read_buf_->RemainingCapacity() < (int)length) { | 44 if (read_buf_->RemainingCapacity() < (int)length) { |
45 read_buf_->SetCapacity(read_buf_->capacity() + kHeaderBufInitialSize); | 45 read_buf_->SetCapacity(read_buf_->capacity() + kHeaderBufInitialSize); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return len; | 109 return len; |
110 } | 110 } |
111 | 111 |
112 // Sends body data to the server and returns the number of bytes sent. | 112 // Sends body data to the server and returns the number of bytes sent. |
113 void QuicSpdyClientStream::SendBody(const string& data, bool fin) { | 113 void QuicSpdyClientStream::SendBody(const string& data, bool fin) { |
114 return WriteOrBufferData(data, fin); | 114 return WriteOrBufferData(data, fin); |
115 } | 115 } |
116 | 116 |
117 } // namespace tools | 117 } // namespace tools |
118 } // namespace net | 118 } // namespace net |
OLD | NEW |