1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_HTTP_HTTP_PIPELINED_STREAM_H_ 6 #define NET_HTTP_HTTP_PIPELINED_STREAM_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "net/base/net_log.h" 12 #include "net/http/http_stream.h" 13 #include "net/socket/ssl_client_socket.h" 14 15 namespace net { 16 17 class BoundNetLog; 18 class HttpPipelinedConnectionImpl; 19 class HttpResponseInfo; 20 class HttpRequestHeaders; 21 struct HttpRequestInfo; 22 class IOBuffer; 23 class ProxyInfo; 24 struct SSLConfig; 25 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 { 34 public: 35 HttpPipelinedStream(HttpPipelinedConnectionImpl* pipeline, 36 int pipeline_id); 37 virtual ~HttpPipelinedStream(); 38 39 // HttpStream methods: 40 virtual int InitializeStream(const HttpRequestInfo* request_info, 41 RequestPriority priority, 42 const BoundNetLog& net_log, 43 const CompletionCallback& callback) OVERRIDE; 44 45 virtual int SendRequest(const HttpRequestHeaders& headers, 46 HttpResponseInfo* response, 47 const CompletionCallback& callback) OVERRIDE; 48 49 virtual UploadProgress GetUploadProgress() const OVERRIDE; 50 51 virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE; 52 53 virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE; 54 55 virtual int ReadResponseBody(IOBuffer* buf, int buf_len, 56 const CompletionCallback& callback) OVERRIDE; 57 58 virtual void Close(bool not_reusable) OVERRIDE; 59 60 virtual HttpStream* RenewStreamForAuth() OVERRIDE; 61 62 virtual bool IsResponseBodyComplete() const OVERRIDE; 63 64 virtual bool CanFindEndOfResponse() const OVERRIDE; 65 66 virtual bool IsConnectionReused() const OVERRIDE; 67 68 virtual void SetConnectionReused() OVERRIDE; 69 70 virtual bool IsConnectionReusable() const OVERRIDE; 71 72 virtual int64 GetTotalReceivedBytes() const OVERRIDE; 73 74 virtual bool GetLoadTimingInfo( 75 LoadTimingInfo* load_timing_info) const OVERRIDE; 76 77 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; 78 79 virtual void GetSSLCertRequestInfo( 80 SSLCertRequestInfo* cert_request_info) OVERRIDE; 81 82 virtual bool IsSpdyHttpStream() const OVERRIDE; 83 84 virtual void Drain(HttpNetworkSession* session) OVERRIDE; 85 86 virtual void SetPriority(RequestPriority priority) 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 BoundNetLog of this stream's pipelined connection. 95 const BoundNetLog& net_log() const; 96 97 // True if this stream's pipeline was NPN negotiated. 98 bool was_npn_negotiated() const; 99 100 // Protocol negotiated with the server. 101 NextProto protocol_negotiated() const; 102 103 private: 104 HttpPipelinedConnectionImpl* pipeline_; 105 106 int pipeline_id_; 107 108 const HttpRequestInfo* request_info_; 109 110 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedStream); 111 }; 112 113 } // namespace net 114 115 #endif // NET_HTTP_HTTP_PIPELINED_STREAM_H_ 116