OLD | NEW |
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 // HttpBasicStream is a simple implementation of HttpStream. It assumes it is | 5 // HttpBasicStream is a simple implementation of HttpStream. It assumes it is |
6 // not sharing a sharing with any other HttpStreams, therefore it just reads and | 6 // not sharing a sharing with any other HttpStreams, therefore it just reads and |
7 // writes directly to the Http Stream. | 7 // writes directly to the Http Stream. |
8 | 8 |
9 #ifndef NET_HTTP_HTTP_BASIC_STREAM_H_ | 9 #ifndef NET_HTTP_HTTP_BASIC_STREAM_H_ |
10 #define NET_HTTP_HTTP_BASIC_STREAM_H_ | 10 #define NET_HTTP_HTTP_BASIC_STREAM_H_ |
11 | 11 |
| 12 #include <string> |
| 13 |
12 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "net/base/io_buffer.h" |
13 #include "net/http/http_stream.h" | 16 #include "net/http/http_stream.h" |
14 #include "net/socket/client_socket_handle.h" | 17 #include "net/http/http_stream_parser.h" |
15 | 18 |
16 namespace net { | 19 namespace net { |
17 | 20 |
| 21 class ClientSocketHandle; |
| 22 class HttpRequestInfo; |
| 23 class HttpResponseInfo; |
| 24 class UploadDataStream; |
| 25 |
18 class HttpBasicStream : public HttpStream { | 26 class HttpBasicStream : public HttpStream { |
19 public: | 27 public: |
20 explicit HttpBasicStream(ClientSocketHandle* handle) : handle_(handle) {} | 28 explicit HttpBasicStream(ClientSocketHandle* handle); |
21 virtual ~HttpBasicStream() {} | 29 virtual ~HttpBasicStream() {} |
22 | 30 |
23 // HttpStream methods: | 31 // HttpStream methods: |
24 virtual int Read(IOBuffer* buf, | 32 virtual int SendRequest(const HttpRequestInfo* request, |
25 int buf_len, | 33 const std::string& headers, |
26 CompletionCallback* callback) { | 34 UploadDataStream* request_body, |
27 return handle_->socket()->Read(buf, buf_len, callback); | 35 CompletionCallback* callback); |
28 } | |
29 | 36 |
30 virtual int Write(IOBuffer* buf, | 37 virtual uint64 GetUploadProgress() const; |
31 int buf_len, | 38 |
32 CompletionCallback* callback) { | 39 virtual int ReadResponseHeaders(CompletionCallback* callback); |
33 return handle_->socket()->Write(buf, buf_len, callback); | 40 |
34 } | 41 virtual HttpResponseInfo* GetResponseInfo() const; |
| 42 |
| 43 virtual int ReadResponseBody(IOBuffer* buf, int buf_len, |
| 44 CompletionCallback* callback); |
| 45 |
| 46 virtual bool IsResponseBodyComplete() const; |
| 47 |
| 48 virtual bool CanFindEndOfResponse() const; |
| 49 |
| 50 virtual bool IsMoreDataBuffered() const; |
35 | 51 |
36 private: | 52 private: |
37 ClientSocketHandle* const handle_; | 53 scoped_refptr<GrowableIOBuffer> read_buf_; |
| 54 |
| 55 scoped_ptr<HttpStreamParser> parser_; |
38 | 56 |
39 DISALLOW_COPY_AND_ASSIGN(HttpBasicStream); | 57 DISALLOW_COPY_AND_ASSIGN(HttpBasicStream); |
40 }; | 58 }; |
41 | 59 |
42 } // namespace net | 60 } // namespace net |
43 | 61 |
44 #endif // NET_HTTP_HTTP_BASIC_STREAM_H_ | 62 #endif // NET_HTTP_HTTP_BASIC_STREAM_H_ |
OLD | NEW |