• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 int ReadResponseBody(IOBuffer* buf,
50                                int buf_len,
51                                const CompletionCallback& callback) OVERRIDE;
52 
53   virtual void Close(bool not_reusable) OVERRIDE;
54 
55   virtual HttpStream* RenewStreamForAuth() OVERRIDE;
56 
57   virtual bool IsResponseBodyComplete() const OVERRIDE;
58 
59   virtual bool CanFindEndOfResponse() const OVERRIDE;
60 
61   virtual bool IsConnectionReused() const OVERRIDE;
62 
63   virtual void SetConnectionReused() OVERRIDE;
64 
65   virtual bool IsConnectionReusable() const OVERRIDE;
66 
67   virtual int64 GetTotalReceivedBytes() const OVERRIDE;
68 
69   virtual bool GetLoadTimingInfo(
70       LoadTimingInfo* load_timing_info) const OVERRIDE;
71 
72   virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
73 
74   virtual void GetSSLCertRequestInfo(
75       SSLCertRequestInfo* cert_request_info) OVERRIDE;
76 
77   virtual bool IsSpdyHttpStream() const OVERRIDE;
78 
79   virtual void Drain(HttpNetworkSession* session) OVERRIDE;
80 
81   virtual void SetPriority(RequestPriority priority) OVERRIDE;
82 
83  private:
parser()84   HttpStreamParser* parser() const { return state_.parser(); }
85 
86   HttpBasicState state_;
87 
88   DISALLOW_COPY_AND_ASSIGN(HttpBasicStream);
89 };
90 
91 }  // namespace net
92 
93 #endif  // NET_HTTP_HTTP_BASIC_STREAM_H_
94