Home | History | Annotate | Download | only in http
      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 bool GetLoadTimingInfo(
     73       LoadTimingInfo* load_timing_info) const OVERRIDE;
     74 
     75   virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
     76 
     77   virtual void GetSSLCertRequestInfo(
     78       SSLCertRequestInfo* cert_request_info) OVERRIDE;
     79 
     80   virtual bool IsSpdyHttpStream() const OVERRIDE;
     81 
     82   virtual void Drain(HttpNetworkSession* session) OVERRIDE;
     83 
     84   // The SSLConfig used to establish this stream's pipeline.
     85   const SSLConfig& used_ssl_config() const;
     86 
     87   // The ProxyInfo used to establish this this stream's pipeline.
     88   const ProxyInfo& used_proxy_info() const;
     89 
     90   // The BoundNetLog of this stream's pipelined connection.
     91   const BoundNetLog& net_log() const;
     92 
     93   // True if this stream's pipeline was NPN negotiated.
     94   bool was_npn_negotiated() const;
     95 
     96   // Protocol negotiated with the server.
     97   NextProto protocol_negotiated() const;
     98 
     99  private:
    100   HttpPipelinedConnectionImpl* pipeline_;
    101 
    102   int pipeline_id_;
    103 
    104   const HttpRequestInfo* request_info_;
    105 
    106   DISALLOW_COPY_AND_ASSIGN(HttpPipelinedStream);
    107 };
    108 
    109 }  // namespace net
    110 
    111 #endif  // NET_HTTP_HTTP_PIPELINED_STREAM_H_
    112