diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 20:08:03 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 20:08:03 +0000 |
commit | 2f497d2c984fe9c7a646d6d78b04a7c922033f50 (patch) | |
tree | 9ed144aa1a4fb14e09b74ed39e680a61679e2ca4 /net/http/http_stream.h | |
parent | cde4e80d78fee0902c0290b2c2a4052e1e7132cd (diff) | |
download | chromium_src-2f497d2c984fe9c7a646d6d78b04a7c922033f50.zip chromium_src-2f497d2c984fe9c7a646d6d78b04a7c922033f50.tar.gz chromium_src-2f497d2c984fe9c7a646d6d78b04a7c922033f50.tar.bz2 |
Reverting 29316.
Review URL: http://codereview.chromium.org/292002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_stream.h')
-rw-r--r-- | net/http/http_stream.h | 81 |
1 files changed, 29 insertions, 52 deletions
diff --git a/net/http/http_stream.h b/net/http/http_stream.h index d0b9dc9..361edb0 100644 --- a/net/http/http_stream.h +++ b/net/http/http_stream.h @@ -6,73 +6,50 @@ // keeps the client agnostic of the actual underlying transport layer. This // provides an abstraction for both a basic http stream as well as http // pipelining implementations. +// +// NOTE(willchan): This interface is a work in progress. It will most likely +// change, since for a pipelining implementation, the stream needs to contain +// the http parsing code. For symmetry, the writing methods will probably +// contain the code for constructing http requests. #ifndef NET_HTTP_HTTP_STREAM_H_ #define NET_HTTP_HTTP_STREAM_H_ -#include <string> - #include "base/basictypes.h" -#include "net/socket/client_socket_handle.h" +#include "net/base/completion_callback.h" namespace net { -class HttpRequestInfo; -class HttpResponseInfo; class IOBuffer; -class UploadDataStream; class HttpStream { public: HttpStream() {} virtual ~HttpStream() {} - // Writes the headers and uploads body data to the underlying socket. - // ERR_IO_PENDING is returned if the operation could not be completed - // synchronously, in which case the result will be passed to the callback - // when available. Returns OK on success. The HttpStream takes ownership - // of the request_body. - virtual int SendRequest(const HttpRequestInfo* request, - const std::string& request_headers, - UploadDataStream* request_body, - CompletionCallback* callback) = 0; - - // Queries the UploadDataStream for its progress (bytes sent). - virtual uint64 GetUploadProgress() const = 0; - - // Reads from the underlying socket until the response headers have been - // completely received. ERR_IO_PENDING is returned if the operation could - // not be completed synchronously, in which case the result will be passed - // to the callback when available. Returns OK on success. The response - // headers are available in the HttpResponseInfo returned by GetResponseInfo - virtual int ReadResponseHeaders(CompletionCallback* callback) = 0; - - // Provides access to HttpResponseInfo (owned by HttpStream). - virtual HttpResponseInfo* GetResponseInfo() const = 0; - - // Reads response body data, up to |buf_len| bytes. The number of bytes read - // is returned, or an error is returned upon failure. ERR_CONNECTION_CLOSED - // is returned to indicate end-of-connection. ERR_IO_PENDING is returned if - // the operation could not be completed synchronously, in which case the - // result will be passed to the callback when available. If the operation is - // not completed immediately, the socket acquires a reference to the provided - // buffer until the callback is invoked or the socket is destroyed. - virtual int ReadResponseBody(IOBuffer* buf, int buf_len, - CompletionCallback* callback) = 0; - - // Indicates if the response body has been completely read. - virtual bool IsResponseBodyComplete() const = 0; - - // Indicates that the end of the response is detectable. This means that - // the response headers indicate either chunked encoding or content length. - // If neither is sent, the server must close the connection for us to detect - // the end of the response. - virtual bool CanFindEndOfResponse() const = 0; - - // After the response headers have been read and after the response body - // is complete, this function indicates if more data (either erroneous or - // as part of the next pipelined response) has been read from the socket. - virtual bool IsMoreDataBuffered() const = 0; + // Reads data, up to buf_len bytes, from the socket. The number of bytes + // read is returned, or an error is returned upon failure. Zero is returned + // to indicate end-of-file. ERR_IO_PENDING is returned if the operation + // could not be completed synchronously, in which case the result will be + // passed to the callback when available. If the operation is not completed + // immediately, the socket acquires a reference to the provided buffer until + // the callback is invoked or the socket is destroyed. + virtual int Read(IOBuffer* buf, + int buf_len, + CompletionCallback* callback) = 0; + + // Writes data, up to buf_len bytes, to the socket. Note: only part of the + // data may be written! The number of bytes written is returned, or an error + // is returned upon failure. ERR_IO_PENDING is returned if the operation + // could not be completed synchronously, in which case the result will be + // passed to the callback when available. If the operation is not completed + // immediately, the socket acquires a reference to the provided buffer until + // the callback is invoked or the socket is destroyed. + // Implementations of this method should not modify the contents of the actual + // buffer that is written to the socket. + virtual int Write(IOBuffer* buf, + int buf_len, + CompletionCallback* callback) = 0; private: DISALLOW_COPY_AND_ASSIGN(HttpStream); |