summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_http_stream.h
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-29 18:41:40 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-29 18:41:40 +0000
commitc638a85ae6661dde9397c17fb17c2d48eb2fe147 (patch)
tree11157aa6f25057a265cf2c3c91f7d724fbd782f3 /net/spdy/spdy_http_stream.h
parent524ff896f45f1a36409d32ac024a6db343d3c685 (diff)
downloadchromium_src-c638a85ae6661dde9397c17fb17c2d48eb2fe147.zip
chromium_src-c638a85ae6661dde9397c17fb17c2d48eb2fe147.tar.gz
chromium_src-c638a85ae6661dde9397c17fb17c2d48eb2fe147.tar.bz2
I've refactored HttpStream, SpdyHttpStream and HttpBasicStream so that
SpdyHttpStream now implements (a slightly wider) HttpStream interface. BUG=50268 TEST=none Review URL: http://codereview.chromium.org/3079002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54154 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_http_stream.h')
-rw-r--r--net/spdy/spdy_http_stream.h60
1 files changed, 35 insertions, 25 deletions
diff --git a/net/spdy/spdy_http_stream.h b/net/spdy/spdy_http_stream.h
index ad643f2..939b929 100644
--- a/net/spdy/spdy_http_stream.h
+++ b/net/spdy/spdy_http_stream.h
@@ -7,6 +7,7 @@
#pragma once
#include <list>
+#include <string>
#include "base/basictypes.h"
#include "base/ref_counted.h"
@@ -14,6 +15,7 @@
#include "net/base/completion_callback.h"
#include "net/base/net_log.h"
#include "net/http/http_request_info.h"
+#include "net/http/http_stream.h"
#include "net/spdy/spdy_protocol.h"
#include "net/spdy/spdy_stream.h"
@@ -26,53 +28,61 @@ class UploadData;
class UploadDataStream;
// The SpdyHttpStream is a HTTP-specific type of stream known to a SpdySession.
-class SpdyHttpStream : public SpdyStream::Delegate {
+class SpdyHttpStream : public SpdyStream::Delegate, public HttpStream {
public:
// SpdyHttpStream constructor
- SpdyHttpStream();
+ explicit SpdyHttpStream(SpdySession* spdy_session);
virtual ~SpdyHttpStream();
SpdyStream* stream() { return stream_.get(); }
- // Initialize stream. Must be called before calling InitializeRequest().
- int InitializeStream(SpdySession* spdy_session,
- const HttpRequestInfo& request_info,
- const BoundNetLog& stream_net_log,
- CompletionCallback* callback);
-
- // Initialize request. Must be called before calling SendRequest().
- // SpdyHttpStream takes ownership of |upload_data|. |upload_data| may be NULL.
- void InitializeRequest(base::Time request_time,
- UploadDataStream* upload_data);
-
- const HttpResponseInfo* GetResponseInfo() const;
-
// ===================================================
- // Interface for [Http|Spdy]NetworkTransaction to use.
+ // HttpStream methods:
+
+ // Initialize stream. Must be called before calling SendRequest().
+ virtual int InitializeStream(const HttpRequestInfo* request_info,
+ const BoundNetLog& net_log,
+ CompletionCallback* callback);
// Sends the request.
// |callback| is used when this completes asynchronously.
+ // SpdyHttpStream takes ownership of |upload_data|. |upload_data| may be NULL.
// The actual SYN_STREAM packet will be sent if the stream is non-pushed.
- int SendRequest(HttpResponseInfo* response,
- CompletionCallback* callback);
+ virtual int SendRequest(const std::string& headers,
+ UploadDataStream* request_body,
+ HttpResponseInfo* response,
+ CompletionCallback* callback);
+
+ // Returns the number of bytes uploaded.
+ virtual uint64 GetUploadProgress() const;
// Reads the response headers. Returns a net error code.
- int ReadResponseHeaders(CompletionCallback* callback);
+ virtual int ReadResponseHeaders(CompletionCallback* callback);
+
+ virtual const HttpResponseInfo* GetResponseInfo() const;
// Reads the response body. Returns a net error code or the number of bytes
// read.
- int ReadResponseBody(
+ virtual int ReadResponseBody(
IOBuffer* buf, int buf_len, CompletionCallback* callback);
- // Cancels any callbacks from being invoked and deletes the stream.
- void Cancel();
+ // Indicates if the response body has been completely read.
+ virtual bool IsResponseBodyComplete() const {
+ return stream_->response_complete();
+ }
- // Returns the number of bytes uploaded.
- uint64 GetUploadProgress() const;
+ // With SPDY the end of response is always detectable.
+ virtual bool CanFindEndOfResponse() const { return true; }
+
+ // A SPDY stream never has more data after the FIN.
+ virtual bool IsMoreDataBuffered() const { return false; }
// ===================================================
// SpdyStream::Delegate.
+ // Cancels any callbacks from being invoked and deletes the stream.
+ void Cancel();
+
virtual bool OnSendHeadersComplete(int status);
virtual int OnSendBody();
virtual bool OnSendBodyComplete(int status);
@@ -118,7 +128,7 @@ class SpdyHttpStream : public SpdyStream::Delegate {
scoped_refptr<SpdySession> spdy_session_;
// The request to send.
- HttpRequestInfo request_info_;
+ const HttpRequestInfo* request_info_;
scoped_ptr<UploadDataStream> request_body_stream_;