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 // 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 
      9 #ifndef NET_HTTP_HTTP_BASIC_STREAM_H_
     10 #define NET_HTTP_HTTP_BASIC_STREAM_H_
     11 
     12 #include <string>
     13 
     14 #include "base/basictypes.h"
     15 #include "net/http/http_basic_state.h"
     16 #include "net/http/http_stream.h"
     17 
     18 namespace net {
     19 
     20 class BoundNetLog;
     21 class ClientSocketHandle;
     22 class HttpResponseInfo;
     23 struct HttpRequestInfo;
     24 class HttpRequestHeaders;
     25 class HttpStreamParser;
     26 class IOBuffer;
     27 
     28 class HttpBasicStream : public HttpStream {
     29  public:
     30   // Constructs a new HttpBasicStream. InitializeStream must be called to
     31   // initialize it correctly.
     32   HttpBasicStream(ClientSocketHandle* connection, bool using_proxy);
     33   virtual ~HttpBasicStream();
     34 
     35   // HttpStream methods:
     36   virtual int InitializeStream(const HttpRequestInfo* request_info,
     37                                RequestPriority priority,
     38                                const BoundNetLog& net_log,
     39                                const CompletionCallback& callback) OVERRIDE;
     40 
     41   virtual int SendRequest(const HttpRequestHeaders& headers,
     42                           HttpResponseInfo* response,
     43                           const CompletionCallback& callback) OVERRIDE;
     44 
     45   virtual UploadProgress GetUploadProgress() const OVERRIDE;
     46 
     47   virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE;
     48 
     49   virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE;
     50 
     51   virtual int ReadResponseBody(IOBuffer* buf,
     52                                int buf_len,
     53                                const CompletionCallback& callback) OVERRIDE;
     54 
     55   virtual void Close(bool not_reusable) OVERRIDE;
     56 
     57   virtual HttpStream* RenewStreamForAuth() OVERRIDE;
     58 
     59   virtual bool IsResponseBodyComplete() const OVERRIDE;
     60 
     61   virtual bool CanFindEndOfResponse() const OVERRIDE;
     62 
     63   virtual bool IsConnectionReused() const OVERRIDE;
     64 
     65   virtual void SetConnectionReused() OVERRIDE;
     66 
     67   virtual bool IsConnectionReusable() const OVERRIDE;
     68 
     69   virtual int64 GetTotalReceivedBytes() const OVERRIDE;
     70 
     71   virtual bool GetLoadTimingInfo(
     72       LoadTimingInfo* load_timing_info) const OVERRIDE;
     73 
     74   virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
     75 
     76   virtual void GetSSLCertRequestInfo(
     77       SSLCertRequestInfo* cert_request_info) OVERRIDE;
     78 
     79   virtual bool IsSpdyHttpStream() const OVERRIDE;
     80 
     81   virtual void Drain(HttpNetworkSession* session) OVERRIDE;
     82 
     83   virtual void SetPriority(RequestPriority priority) OVERRIDE;
     84 
     85  private:
     86   HttpStreamParser* parser() const { return state_.parser(); }
     87 
     88   HttpBasicState state_;
     89 
     90   DISALLOW_COPY_AND_ASSIGN(HttpBasicStream);
     91 };
     92 
     93 }  // namespace net
     94 
     95 #endif  // NET_HTTP_HTTP_BASIC_STREAM_H_
     96