OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // | |
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 | |
7 // writes directly to the Http Stream. | |
8 | 4 |
9 #ifndef NET_HTTP_HTTP_BASIC_STREAM_H_ | 5 #ifndef NET_HTTP_HTTP_PIPELINED_STREAM_H_ |
10 #define NET_HTTP_HTTP_BASIC_STREAM_H_ | 6 #define NET_HTTP_HTTP_PIPELINED_STREAM_H_ |
11 #pragma once | 7 #pragma once |
12 | 8 |
13 #include <string> | 9 #include <string> |
14 | 10 |
15 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
16 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
17 #include "net/http/http_stream.h" | 13 #include "net/http/http_stream.h" |
18 | 14 |
19 namespace net { | 15 namespace net { |
20 | 16 |
21 class BoundNetLog; | 17 class BoundNetLog; |
22 class ClientSocketHandle; | 18 class HttpPipelinedConnectionImpl; |
23 class GrowableIOBuffer; | |
24 class HttpResponseInfo; | 19 class HttpResponseInfo; |
| 20 class HttpRequestHeaders; |
25 struct HttpRequestInfo; | 21 struct HttpRequestInfo; |
26 class HttpRequestHeaders; | |
27 class HttpStreamParser; | 22 class HttpStreamParser; |
28 class IOBuffer; | 23 class IOBuffer; |
29 class UploadDataStream; | 24 class UploadDataStream; |
30 | 25 |
31 class HttpBasicStream : public HttpStream { | 26 // HttpPipelinedStream is the pipelined implementation of HttpStream. It has |
| 27 // very little code in it. Instead, it serves as the client's interface to the |
| 28 // pipelined connection, where all the work happens. |
| 29 // |
| 30 // In the case of pipelining failures, these functions may return |
| 31 // ERR_PIPELINE_EVICTION. In that case, the client should retry the HTTP |
| 32 // request without pipelining. |
| 33 class HttpPipelinedStream : public HttpStream { |
32 public: | 34 public: |
33 // Constructs a new HttpBasicStream. If |parser| is NULL, then | 35 HttpPipelinedStream(HttpPipelinedConnectionImpl* pipeline, |
34 // InitializeStream should be called to initialize it correctly. If | 36 int pipeline_id); |
35 // |parser| is non-null, then InitializeStream should not be called, | 37 virtual ~HttpPipelinedStream(); |
36 // as the stream is already initialized. | |
37 HttpBasicStream(ClientSocketHandle* connection, | |
38 HttpStreamParser* parser, | |
39 bool using_proxy); | |
40 virtual ~HttpBasicStream(); | |
41 | 38 |
42 // HttpStream methods: | 39 // HttpStream methods: |
43 virtual int InitializeStream(const HttpRequestInfo* request_info, | 40 virtual int InitializeStream(const HttpRequestInfo* request_info, |
44 const BoundNetLog& net_log, | 41 const BoundNetLog& net_log, |
45 CompletionCallback* callback) OVERRIDE; | 42 CompletionCallback* callback) OVERRIDE; |
46 | 43 |
47 virtual int SendRequest(const HttpRequestHeaders& headers, | 44 virtual int SendRequest(const HttpRequestHeaders& headers, |
48 UploadDataStream* request_body, | 45 UploadDataStream* request_body, |
49 HttpResponseInfo* response, | 46 HttpResponseInfo* response, |
50 CompletionCallback* callback) OVERRIDE; | 47 CompletionCallback* callback) OVERRIDE; |
(...skipping 25 matching lines...) Expand all Loading... |
76 | 73 |
77 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; | 74 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; |
78 | 75 |
79 virtual void GetSSLCertRequestInfo( | 76 virtual void GetSSLCertRequestInfo( |
80 SSLCertRequestInfo* cert_request_info) OVERRIDE; | 77 SSLCertRequestInfo* cert_request_info) OVERRIDE; |
81 | 78 |
82 virtual bool IsSpdyHttpStream() const OVERRIDE; | 79 virtual bool IsSpdyHttpStream() const OVERRIDE; |
83 | 80 |
84 virtual void LogNumRttVsBytesMetrics() const OVERRIDE; | 81 virtual void LogNumRttVsBytesMetrics() const OVERRIDE; |
85 | 82 |
| 83 virtual void Drain(HttpNetworkSession* session) OVERRIDE; |
| 84 |
86 private: | 85 private: |
87 scoped_refptr<GrowableIOBuffer> read_buf_; | 86 HttpPipelinedConnectionImpl* pipeline_; |
88 | 87 |
89 scoped_ptr<HttpStreamParser> parser_; | 88 int pipeline_id_; |
90 | |
91 scoped_ptr<ClientSocketHandle> connection_; | |
92 | |
93 bool using_proxy_; | |
94 | |
95 std::string request_line_; | |
96 | 89 |
97 const HttpRequestInfo* request_info_; | 90 const HttpRequestInfo* request_info_; |
98 | 91 |
99 const HttpResponseInfo* response_; | 92 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedStream); |
100 | |
101 int64 bytes_read_offset_; | |
102 | |
103 DISALLOW_COPY_AND_ASSIGN(HttpBasicStream); | |
104 }; | 93 }; |
105 | 94 |
106 } // namespace net | 95 } // namespace net |
107 | 96 |
108 #endif // NET_HTTP_HTTP_BASIC_STREAM_H_ | 97 #endif // NET_HTTP_HTTP_PIPELINED_STREAM_H_ |
OLD | NEW |