Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Unified Diff: net/quic/quic_http_stream.h

Issue 11364068: Add a QuicHttpStream class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bugs Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/quic/quic_http_stream.h
diff --git a/net/quic/quic_http_stream.h b/net/quic/quic_http_stream.h
new file mode 100644
index 0000000000000000000000000000000000000000..df3ae0701440905b88e69cf56dc3122361fa0c4a
--- /dev/null
+++ b/net/quic/quic_http_stream.h
@@ -0,0 +1,128 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_QUIC_QUIC_HTTP_STREAM_H_
+#define NET_QUIC_QUIC_HTTP_STREAM_H_
+
+#include <list>
+
+#include "base/memory/weak_ptr.h"
+#include "net/base/io_buffer.h"
+#include "net/http/http_stream.h"
+#include "net/quic/quic_reliable_client_stream.h"
+
+namespace net {
+
+// The SpdyHttpStream is a QUIC-specific HttpStream subclass.
+class NET_EXPORT_PRIVATE QuicHttpStream :
+ public QuicReliableClientStream::Delegate,
+ public HttpStream {
+ public:
+ explicit QuicHttpStream(QuicReliableClientStream* stream);
+
+ virtual ~QuicHttpStream();
+
+ // HttpStream implementation.
+ virtual int InitializeStream(const HttpRequestInfo* request_info,
+ const BoundNetLog& net_log,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual int SendRequest(const HttpRequestHeaders& request_headers,
+ HttpResponseInfo* response,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual UploadProgress GetUploadProgress() const OVERRIDE;
+ virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE;
+ virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE;
+ virtual int ReadResponseBody(IOBuffer* buf,
+ int buf_len,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual void Close(bool not_reusable) OVERRIDE;
+ virtual HttpStream* RenewStreamForAuth() OVERRIDE;
+ virtual bool IsResponseBodyComplete() const OVERRIDE;
+ virtual bool CanFindEndOfResponse() const OVERRIDE;
+ virtual bool IsMoreDataBuffered() const OVERRIDE;
+ virtual bool IsConnectionReused() const OVERRIDE;
+ virtual void SetConnectionReused() OVERRIDE;
+ virtual bool IsConnectionReusable() const OVERRIDE;
+ virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
+ virtual void GetSSLCertRequestInfo(
+ SSLCertRequestInfo* cert_request_info) OVERRIDE;
+ virtual bool IsSpdyHttpStream() const OVERRIDE;
+ virtual void LogNumRttVsBytesMetrics() const OVERRIDE {}
+ virtual void Drain(HttpNetworkSession* session) OVERRIDE;
+
+ // QuicReliableClientStream::Delegate implementation
+ virtual int OnSendData() OVERRIDE;
+ virtual int OnSendDataComplete(int status, bool* eof) OVERRIDE;
+ virtual int OnDataReceived(const char* data, int length) OVERRIDE;
+ virtual void OnClose(QuicErrorCode error) OVERRIDE;
+
+ private:
+ enum State {
+ STATE_NONE,
+ STATE_SEND_HEADERS,
+ STATE_SEND_HEADERS_COMPLETE,
+ STATE_READ_REQUEST_BODY,
+ STATE_READ_REQUEST_BODY_COMPLETE,
+ STATE_SEND_BODY,
+ STATE_OPEN,
+ };
+
+ void OnIOComplete(int rv);
+ void DoCallback(int rv);
+
+ int DoLoop(int);
+ int DoSendHeaders();
+ int DoSendHeadersComplete(int rv);
+ int DoReadRequestBody();
+ int DoReadRequestBodyComplete(int rv);
+ int DoSendBody(int rv);
+ int DoReadResponseHeaders();
+ int DoReadResponseHeadersComplete(int rv);
+
+ int ParseResponseHeaders();
+
+ void BufferResponseBody(const char* data, int length);
+
+ State io_state_;
+
+ 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
+
+ // The request to send, onder by the caller.
+ 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
+ // Serialized HTTP request.
+ 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
+
+ // 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
+ UploadDataStream* request_body_stream_;
+
+ // |response_info_| is the HTTP response data object which is filled in
+ // 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.
+ HttpResponseInfo* response_info_;
+ bool response_headers_received_;
+
+ // Buffer into which response header data is read.
+ 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,
+
+ // We buffer the response body as it arrives asynchronously from the stream.
+ // TODO(rch): This is infinite buffering, which is bad.
+ std::list<scoped_refptr<IOBufferWithSize> > response_body_;
+
+ // The caller's callback to be used for asynchronous operations.
+ CompletionCallback callback_;
+
+ // Caller provided buffer for the ReadResponseBody() response.
+ scoped_refptr<IOBuffer> user_buffer_;
+ int user_buffer_len_;
+
+ // Temporary buffer used to read the request body from UploadDataStream.
+ scoped_refptr<IOBufferWithSize> raw_request_body_buf_;
+ // Wraps raw_request_body_buf_ to read the remaining data progressively.
+ scoped_refptr<DrainableIOBuffer> request_body_buf_;
+
+ base::WeakPtrFactory<QuicHttpStream> weak_factory_;
+};
+
+} // namespace net
+
+#endif // NET_QUIC_QUIC_HTTP_STREAM_H_

Powered by Google App Engine
This is Rietveld 408576698