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 #ifndef NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_ | 5 #ifndef NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_ |
6 #define NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_ | 6 #define NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_ |
7 | 7 |
| 8 #include <sys/types.h> |
| 9 #include <string> |
| 10 |
8 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
9 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
10 #include "net/tools/quic/quic_reliable_client_stream.h" | 13 #include "net/quic/quic_data_stream.h" |
| 14 #include "net/quic/quic_protocol.h" |
| 15 #include "net/tools/balsa/balsa_frame.h" |
| 16 #include "net/tools/balsa/balsa_headers.h" |
11 | 17 |
12 namespace net { | 18 namespace net { |
13 | 19 |
14 class BalsaHeaders; | |
15 | |
16 namespace tools { | 20 namespace tools { |
17 | 21 |
18 class QuicClientSession; | 22 class QuicClientSession; |
19 | 23 |
20 // All this does right now is send an SPDY request, and aggregate the | 24 // All this does right now is send an SPDY request, and aggregate the |
21 // SPDY response. | 25 // SPDY response. |
22 class QuicSpdyClientStream : public QuicReliableClientStream { | 26 class QuicSpdyClientStream : public QuicDataStream { |
23 public: | 27 public: |
24 QuicSpdyClientStream(QuicStreamId id, QuicClientSession* session); | 28 QuicSpdyClientStream(QuicStreamId id, QuicClientSession* session); |
25 virtual ~QuicSpdyClientStream(); | 29 virtual ~QuicSpdyClientStream(); |
26 | 30 |
| 31 // Override the base class to close the write side as soon as we get a |
| 32 // response. |
| 33 // SPDY/HTTP does not support bidirectional streaming. |
| 34 virtual bool OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE; |
| 35 |
27 // ReliableQuicStream implementation called by the session when there's | 36 // ReliableQuicStream implementation called by the session when there's |
28 // data for us. | 37 // data for us. |
29 virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE; | 38 virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE; |
30 | 39 |
31 virtual void OnFinRead() OVERRIDE; | 40 virtual void OnFinRead() OVERRIDE; |
32 | 41 |
33 virtual ssize_t SendRequest(const BalsaHeaders& headers, | 42 // Serializes the headers and body, sends it to the server, and |
34 base::StringPiece body, | 43 // returns the number of bytes sent. |
35 bool fin) OVERRIDE; | 44 ssize_t SendRequest(const BalsaHeaders& headers, |
| 45 base::StringPiece body, |
| 46 bool fin); |
| 47 |
| 48 // Sends body data to the server, or buffers if it can't be sent immediately. |
| 49 void SendBody(const std::string& data, bool fin); |
| 50 |
| 51 // Returns the response data. |
| 52 const std::string& data() { return data_; } |
| 53 |
| 54 // Returns whatever headers have been received for this stream. |
| 55 const BalsaHeaders& headers() { return headers_; } |
36 | 56 |
37 // While the server's set_priority shouldn't be called externally, the creator | 57 // While the server's set_priority shouldn't be called externally, the creator |
38 // of client-side streams should be able to set the priority. | 58 // of client-side streams should be able to set the priority. |
39 using QuicReliableClientStream::set_priority; | 59 using QuicDataStream::set_priority; |
40 | 60 |
41 private: | 61 private: |
42 int ParseResponseHeaders(); | 62 int ParseResponseHeaders(); |
43 | 63 |
| 64 BalsaHeaders headers_; |
| 65 std::string data_; |
| 66 |
44 scoped_refptr<GrowableIOBuffer> read_buf_; | 67 scoped_refptr<GrowableIOBuffer> read_buf_; |
45 bool response_headers_received_; | 68 bool response_headers_received_; |
46 }; | 69 }; |
47 | 70 |
48 } // namespace tools | 71 } // namespace tools |
49 } // namespace net | 72 } // namespace net |
50 | 73 |
51 #endif // NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_ | 74 #endif // NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_ |
OLD | NEW |