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