Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_QUIC_QUIC_HTTP_STREAM_H_ | |
| 6 #define NET_QUIC_QUIC_HTTP_STREAM_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "net/base/io_buffer.h" | |
| 12 #include "net/http/http_stream.h" | |
| 13 #include "net/quic/quic_reliable_client_stream.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 // The SpdyHttpStream is a QUIC-specific HttpStream subclass. | |
| 18 class NET_EXPORT_PRIVATE QuicHttpStream : | |
| 19 public QuicReliableClientStream::Delegate, | |
| 20 public HttpStream { | |
| 21 public: | |
| 22 explicit QuicHttpStream(QuicReliableClientStream* stream); | |
| 23 | |
| 24 virtual ~QuicHttpStream(); | |
| 25 | |
| 26 // HttpStream implementation. | |
| 27 virtual int InitializeStream(const HttpRequestInfo* request_info, | |
| 28 const BoundNetLog& net_log, | |
| 29 const CompletionCallback& callback) OVERRIDE; | |
| 30 virtual int SendRequest(const HttpRequestHeaders& request_headers, | |
| 31 HttpResponseInfo* response, | |
| 32 const CompletionCallback& callback) OVERRIDE; | |
| 33 virtual UploadProgress GetUploadProgress() const OVERRIDE; | |
| 34 virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE; | |
| 35 virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE; | |
| 36 virtual int ReadResponseBody(IOBuffer* buf, | |
| 37 int buf_len, | |
| 38 const CompletionCallback& callback) OVERRIDE; | |
| 39 virtual void Close(bool not_reusable) OVERRIDE; | |
| 40 virtual HttpStream* RenewStreamForAuth() OVERRIDE; | |
| 41 virtual bool IsResponseBodyComplete() const OVERRIDE; | |
| 42 virtual bool CanFindEndOfResponse() const OVERRIDE; | |
| 43 virtual bool IsMoreDataBuffered() const OVERRIDE; | |
| 44 virtual bool IsConnectionReused() const OVERRIDE; | |
| 45 virtual void SetConnectionReused() OVERRIDE; | |
| 46 virtual bool IsConnectionReusable() const OVERRIDE; | |
| 47 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; | |
| 48 virtual void GetSSLCertRequestInfo( | |
| 49 SSLCertRequestInfo* cert_request_info) OVERRIDE; | |
| 50 virtual bool IsSpdyHttpStream() const OVERRIDE; | |
| 51 virtual void LogNumRttVsBytesMetrics() const OVERRIDE {} | |
| 52 virtual void Drain(HttpNetworkSession* session) OVERRIDE; | |
| 53 | |
| 54 // QuicReliableClientStream::Delegate implementation | |
| 55 virtual int OnSendData() OVERRIDE; | |
| 56 virtual int OnSendDataComplete(int status, bool* eof) OVERRIDE; | |
| 57 virtual int OnDataReceived(const char* data, int length) OVERRIDE; | |
| 58 virtual void OnClose(QuicErrorCode error) OVERRIDE; | |
| 59 | |
| 60 private: | |
| 61 enum State { | |
| 62 STATE_NONE, | |
| 63 STATE_SEND_HEADERS, | |
| 64 STATE_SEND_HEADERS_COMPLETE, | |
| 65 STATE_READ_REQUEST_BODY, | |
| 66 STATE_READ_REQUEST_BODY_COMPLETE, | |
| 67 STATE_SEND_BODY, | |
| 68 STATE_OPEN, | |
| 69 }; | |
| 70 | |
| 71 void OnIOComplete(int rv); | |
| 72 void DoCallback(int rv); | |
| 73 | |
| 74 int DoLoop(int); | |
| 75 int DoSendHeaders(); | |
| 76 int DoSendHeadersComplete(int rv); | |
| 77 int DoReadRequestBody(); | |
| 78 int DoReadRequestBodyComplete(int rv); | |
| 79 int DoSendBody(int rv); | |
| 80 int DoReadResponseHeaders(); | |
| 81 int DoReadResponseHeadersComplete(int rv); | |
| 82 | |
| 83 int ParseResponseHeaders(); | |
| 84 | |
| 85 void BufferResponseBody(const char* data, int length); | |
| 86 | |
| 87 State io_state_; | |
| 88 | |
| 89 QuicReliableClientStream* stream_; // Non-owning. | |
|
willchan no longer on Chromium
2012/11/21 23:07:04
Is there a comment somewhere that describes the ow
Ryan Hamilton
2012/11/21 23:35:09
There is not. I'll update the comments in the hea
| |
| 90 | |
| 91 // The request to send, onder by the caller. | |
| 92 const HttpRequestInfo* request_info_; | |
|
willchan no longer on Chromium
2012/11/21 23:07:04
This is also non-owning. I think that this must ou
Ryan Hamilton
2012/11/21 23:35:09
updated http_stream_base.h
| |
| 93 // Serialized HTTP request. | |
| 94 std::string request_; | |
|
willchan no longer on Chromium
2012/11/21 23:07:04
I can't seem to find where this gets used. What's
Ryan Hamilton
2012/11/21 23:35:09
It is the serialized HTTP request which is created
| |
| 95 | |
| 96 // The request body to send, if any, owned by the caller. | |
|
willchan no longer on Chromium
2012/11/21 23:07:04
Like HttpRequestInfo, we should document this in t
Ryan Hamilton
2012/11/21 23:35:09
Updated http_stream_base.h
| |
| 97 UploadDataStream* request_body_stream_; | |
| 98 | |
| 99 // |response_info_| is the HTTP response data object which is filled in | |
| 100 // when a the reponse headers are read. It is not owned by this stream. | |
|
willchan no longer on Chromium
2012/11/21 23:07:04
s/reponse/response/
Again, document ownership in H
Ryan Hamilton
2012/11/21 23:35:09
Done.
| |
| 101 HttpResponseInfo* response_info_; | |
| 102 bool response_headers_received_; | |
| 103 | |
| 104 // Buffer into which response header data is read. | |
| 105 scoped_refptr<GrowableIOBuffer> read_buf_; | |
|
willchan no longer on Chromium
2012/11/21 23:07:04
I really hate GrowableIOBuffer and DrainableIOBuff
Ryan Hamilton
2012/11/21 23:35:09
Well, I definitely don't *need* GrowableIOBuffer,
| |
| 106 | |
| 107 // We buffer the response body as it arrives asynchronously from the stream. | |
| 108 // TODO(rch): This is infinite buffering, which is bad. | |
| 109 std::list<scoped_refptr<IOBufferWithSize> > response_body_; | |
| 110 | |
| 111 // The caller's callback to be used for asynchronous operations. | |
| 112 CompletionCallback callback_; | |
| 113 | |
| 114 // Caller provided buffer for the ReadResponseBody() response. | |
| 115 scoped_refptr<IOBuffer> user_buffer_; | |
| 116 int user_buffer_len_; | |
| 117 | |
| 118 // Temporary buffer used to read the request body from UploadDataStream. | |
| 119 scoped_refptr<IOBufferWithSize> raw_request_body_buf_; | |
| 120 // Wraps raw_request_body_buf_ to read the remaining data progressively. | |
| 121 scoped_refptr<DrainableIOBuffer> request_body_buf_; | |
| 122 | |
| 123 base::WeakPtrFactory<QuicHttpStream> weak_factory_; | |
| 124 }; | |
| 125 | |
| 126 } // namespace net | |
| 127 | |
| 128 #endif // NET_QUIC_QUIC_HTTP_STREAM_H_ | |
| OLD | NEW |