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

Side by Side Diff: net/http/http_stream.h

Issue 3079002: Refactor SpdyHttpStream to implement HttpStream. Required adding a new... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // HttpStream is an interface for reading and writing data to an HttpStream that 5 // HttpStream is an interface for reading and writing data to an HttpStream that
6 // keeps the client agnostic of the actual underlying transport layer. This 6 // keeps the client agnostic of the actual underlying transport layer. This
7 // provides an abstraction for both a basic http stream as well as http 7 // provides an abstraction for both a basic http stream as well as http
8 // pipelining implementations. 8 // pipelining implementations.
9 9
10 #ifndef NET_HTTP_HTTP_STREAM_H_ 10 #ifndef NET_HTTP_HTTP_STREAM_H_
11 #define NET_HTTP_HTTP_STREAM_H_ 11 #define NET_HTTP_HTTP_STREAM_H_
12 #pragma once 12 #pragma once
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "net/base/completion_callback.h" 17 #include "net/base/completion_callback.h"
18 18
19 namespace net { 19 namespace net {
20 20
21 struct HttpRequestInfo; 21 struct HttpRequestInfo;
22 class HttpResponseInfo; 22 class HttpResponseInfo;
23 class IOBuffer; 23 class IOBuffer;
24 class UploadDataStream; 24 class UploadDataStream;
25 class BoundNetLog;
25 26
26 class HttpStream { 27 class HttpStream {
27 public: 28 public:
28 HttpStream() {} 29 HttpStream() {}
29 virtual ~HttpStream() {} 30 virtual ~HttpStream() {}
30 31
32 // Initialize stream. Must be called before calling SendRequest().
33 // Returns a net error code, possibly ERR_IO_PENDING.
34 virtual int InitializeStream(const HttpRequestInfo* request_info,
35 const BoundNetLog& net_log,
36 CompletionCallback* callback) = 0;
37
31 // Writes the headers and uploads body data to the underlying socket. 38 // Writes the headers and uploads body data to the underlying socket.
32 // ERR_IO_PENDING is returned if the operation could not be completed 39 // ERR_IO_PENDING is returned if the operation could not be completed
33 // synchronously, in which case the result will be passed to the callback 40 // synchronously, in which case the result will be passed to the callback
34 // when available. Returns OK on success. The HttpStream takes ownership 41 // when available. Returns OK on success. The HttpStream takes ownership
35 // of the request_body. 42 // of the request_body.
36 virtual int SendRequest(const HttpRequestInfo* request, 43 virtual int SendRequest(const std::string& request_headers,
37 const std::string& request_headers,
38 UploadDataStream* request_body, 44 UploadDataStream* request_body,
39 HttpResponseInfo* response, 45 HttpResponseInfo* response,
40 CompletionCallback* callback) = 0; 46 CompletionCallback* callback) = 0;
41 47
42 // Queries the UploadDataStream for its progress (bytes sent). 48 // Queries the UploadDataStream for its progress (bytes sent).
43 virtual uint64 GetUploadProgress() const = 0; 49 virtual uint64 GetUploadProgress() const = 0;
44 50
45 // Reads from the underlying socket until the response headers have been 51 // Reads from the underlying socket until the response headers have been
46 // completely received. ERR_IO_PENDING is returned if the operation could 52 // completely received. ERR_IO_PENDING is returned if the operation could
47 // not be completed synchronously, in which case the result will be passed 53 // not be completed synchronously, in which case the result will be passed
48 // to the callback when available. Returns OK on success. The response 54 // to the callback when available. Returns OK on success. The response
49 // headers are available in the HttpResponseInfo returned by GetResponseInfo 55 // headers are available in the HttpResponseInfo returned by GetResponseInfo
50 virtual int ReadResponseHeaders(CompletionCallback* callback) = 0; 56 virtual int ReadResponseHeaders(CompletionCallback* callback) = 0;
51 57
52 // Provides access to HttpResponseInfo (owned by HttpStream). 58 // Provides access to HttpResponseInfo (owned by HttpStream).
53 virtual HttpResponseInfo* GetResponseInfo() const = 0; 59 virtual const HttpResponseInfo* GetResponseInfo() const = 0;
54 60
55 // Reads response body data, up to |buf_len| bytes. |buf_len| should be a 61 // Reads response body data, up to |buf_len| bytes. |buf_len| should be a
56 // reasonable size (<2MB). The number of bytes read is returned, or an 62 // reasonable size (<2MB). The number of bytes read is returned, or an
57 // error is returned upon failure. 0 indicates that the request has been 63 // error is returned upon failure. 0 indicates that the request has been
58 // fully satisfied and there is no more data to read. 64 // fully satisfied and there is no more data to read.
59 // ERR_CONNECTION_CLOSED is returned when the connection has been closed 65 // ERR_CONNECTION_CLOSED is returned when the connection has been closed
60 // prematurely. ERR_IO_PENDING is returned if the operation could not be 66 // prematurely. ERR_IO_PENDING is returned if the operation could not be
61 // completed synchronously, in which case the result will be passed to the 67 // completed synchronously, in which case the result will be passed to the
62 // callback when available. If the operation is not completed immediately, 68 // callback when available. If the operation is not completed immediately,
63 // the socket acquires a reference to the provided buffer until the callback 69 // the socket acquires a reference to the provided buffer until the callback
(...skipping 15 matching lines...) Expand all
79 // as part of the next pipelined response) has been read from the socket. 85 // as part of the next pipelined response) has been read from the socket.
80 virtual bool IsMoreDataBuffered() const = 0; 86 virtual bool IsMoreDataBuffered() const = 0;
81 87
82 private: 88 private:
83 DISALLOW_COPY_AND_ASSIGN(HttpStream); 89 DISALLOW_COPY_AND_ASSIGN(HttpStream);
84 }; 90 };
85 91
86 } // namespace net 92 } // namespace net
87 93
88 #endif // NET_HTTP_HTTP_STREAM_H_ 94 #endif // NET_HTTP_HTTP_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698