| 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_QUIC_QUIC_HTTP_STREAM_H_ | 5 #ifndef NET_QUIC_QUIC_HTTP_STREAM_H_ |
| 6 #define NET_QUIC_QUIC_HTTP_STREAM_H_ | 6 #define NET_QUIC_QUIC_HTTP_STREAM_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
| 12 #include "net/http/http_stream.h" | 12 #include "net/http/http_stream.h" |
| 13 #include "net/quic/quic_client_session.h" | 13 #include "net/quic/quic_client_session.h" |
| 14 #include "net/quic/quic_reliable_client_stream.h" | 14 #include "net/quic/quic_reliable_client_stream.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 namespace test { |
| 19 class QuicHttpStreamPeer; |
| 20 } // namespace test |
| 21 |
| 18 // The QuicHttpStream is a QUIC-specific HttpStream subclass. It holds a | 22 // The QuicHttpStream is a QUIC-specific HttpStream subclass. It holds a |
| 19 // non-owning pointer to a QuicReliableClientStream which it uses to | 23 // non-owning pointer to a QuicReliableClientStream which it uses to |
| 20 // send and receive data. | 24 // send and receive data. |
| 21 class NET_EXPORT_PRIVATE QuicHttpStream : | 25 class NET_EXPORT_PRIVATE QuicHttpStream : |
| 22 public QuicReliableClientStream::Delegate, | 26 public QuicReliableClientStream::Delegate, |
| 23 public HttpStream { | 27 public HttpStream { |
| 24 public: | 28 public: |
| 25 explicit QuicHttpStream(const base::WeakPtr<QuicClientSession> session); | 29 explicit QuicHttpStream(const base::WeakPtr<QuicClientSession> session); |
| 26 | 30 |
| 27 virtual ~QuicHttpStream(); | 31 virtual ~QuicHttpStream(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 55 virtual bool IsSpdyHttpStream() const OVERRIDE; | 59 virtual bool IsSpdyHttpStream() const OVERRIDE; |
| 56 virtual void Drain(HttpNetworkSession* session) OVERRIDE; | 60 virtual void Drain(HttpNetworkSession* session) OVERRIDE; |
| 57 virtual void SetPriority(RequestPriority priority) OVERRIDE; | 61 virtual void SetPriority(RequestPriority priority) OVERRIDE; |
| 58 | 62 |
| 59 // QuicReliableClientStream::Delegate implementation | 63 // QuicReliableClientStream::Delegate implementation |
| 60 virtual int OnSendData() OVERRIDE; | 64 virtual int OnSendData() OVERRIDE; |
| 61 virtual int OnSendDataComplete(int status, bool* eof) OVERRIDE; | 65 virtual int OnSendDataComplete(int status, bool* eof) OVERRIDE; |
| 62 virtual int OnDataReceived(const char* data, int length) OVERRIDE; | 66 virtual int OnDataReceived(const char* data, int length) OVERRIDE; |
| 63 virtual void OnClose(QuicErrorCode error) OVERRIDE; | 67 virtual void OnClose(QuicErrorCode error) OVERRIDE; |
| 64 virtual void OnError(int error) OVERRIDE; | 68 virtual void OnError(int error) OVERRIDE; |
| 69 virtual bool HasSendHeadersComplete() OVERRIDE; |
| 65 | 70 |
| 66 private: | 71 private: |
| 72 friend class test::QuicHttpStreamPeer; |
| 73 |
| 67 enum State { | 74 enum State { |
| 68 STATE_NONE, | 75 STATE_NONE, |
| 69 STATE_SEND_HEADERS, | 76 STATE_SEND_HEADERS, |
| 70 STATE_SEND_HEADERS_COMPLETE, | 77 STATE_SEND_HEADERS_COMPLETE, |
| 71 STATE_READ_REQUEST_BODY, | 78 STATE_READ_REQUEST_BODY, |
| 72 STATE_READ_REQUEST_BODY_COMPLETE, | 79 STATE_READ_REQUEST_BODY_COMPLETE, |
| 73 STATE_SEND_BODY, | 80 STATE_SEND_BODY, |
| 74 STATE_SEND_BODY_COMPLETE, | 81 STATE_SEND_BODY_COMPLETE, |
| 75 STATE_OPEN, | 82 STATE_OPEN, |
| 76 }; | 83 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 99 QuicClientSession::StreamRequest stream_request_; | 106 QuicClientSession::StreamRequest stream_request_; |
| 100 QuicReliableClientStream* stream_; // Non-owning. | 107 QuicReliableClientStream* stream_; // Non-owning. |
| 101 | 108 |
| 102 // The following three fields are all owned by the caller and must | 109 // The following three fields are all owned by the caller and must |
| 103 // outlive this object, according to the HttpStream contract. | 110 // outlive this object, according to the HttpStream contract. |
| 104 | 111 |
| 105 // The request to send. | 112 // The request to send. |
| 106 const HttpRequestInfo* request_info_; | 113 const HttpRequestInfo* request_info_; |
| 107 // The request body to send, if any, owned by the caller. | 114 // The request body to send, if any, owned by the caller. |
| 108 UploadDataStream* request_body_stream_; | 115 UploadDataStream* request_body_stream_; |
| 116 // The priority of the request. |
| 117 RequestPriority priority_; |
| 109 // |response_info_| is the HTTP response data object which is filled in | 118 // |response_info_| is the HTTP response data object which is filled in |
| 110 // when a the response headers are read. It is not owned by this stream. | 119 // when a the response headers are read. It is not owned by this stream. |
| 111 HttpResponseInfo* response_info_; | 120 HttpResponseInfo* response_info_; |
| 112 // Because response data is buffered, also buffer the response status if the | 121 // Because response data is buffered, also buffer the response status if the |
| 113 // stream is explicitly closed via OnError or OnClose with an error. | 122 // stream is explicitly closed via OnError or OnClose with an error. |
| 114 // Once all buffered data has been returned, this will be used as the final | 123 // Once all buffered data has been returned, this will be used as the final |
| 115 // response. | 124 // response. |
| 116 int response_status_; | 125 int response_status_; |
| 117 | 126 |
| 118 bool response_headers_received_; | 127 bool response_headers_received_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 140 scoped_refptr<DrainableIOBuffer> request_body_buf_; | 149 scoped_refptr<DrainableIOBuffer> request_body_buf_; |
| 141 | 150 |
| 142 BoundNetLog stream_net_log_; | 151 BoundNetLog stream_net_log_; |
| 143 | 152 |
| 144 base::WeakPtrFactory<QuicHttpStream> weak_factory_; | 153 base::WeakPtrFactory<QuicHttpStream> weak_factory_; |
| 145 }; | 154 }; |
| 146 | 155 |
| 147 } // namespace net | 156 } // namespace net |
| 148 | 157 |
| 149 #endif // NET_QUIC_QUIC_HTTP_STREAM_H_ | 158 #endif // NET_QUIC_QUIC_HTTP_STREAM_H_ |
| OLD | NEW |