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