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.
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.
9 #ifndef NET_HTTP_HTTP_BASIC_STREAM_H_
10 #define NET_HTTP_HTTP_BASIC_STREAM_H_
16 #include "base/basictypes.h"
17 #include "net/http/http_basic_state.h"
18 #include "net/http/http_stream.h"
23 class ClientSocketHandle
;
24 class HttpResponseInfo
;
25 struct HttpRequestInfo
;
26 class HttpRequestHeaders
;
27 class HttpStreamParser
;
30 class HttpBasicStream
: public HttpStream
{
32 // Constructs a new HttpBasicStream. InitializeStream must be called to
33 // initialize it correctly.
34 HttpBasicStream(ClientSocketHandle
* connection
, bool using_proxy
);
35 ~HttpBasicStream() override
;
37 // HttpStream methods:
38 int InitializeStream(const HttpRequestInfo
* request_info
,
39 RequestPriority priority
,
40 const BoundNetLog
& net_log
,
41 const CompletionCallback
& callback
) override
;
43 int SendRequest(const HttpRequestHeaders
& headers
,
44 HttpResponseInfo
* response
,
45 const CompletionCallback
& callback
) override
;
47 UploadProgress
GetUploadProgress() const override
;
49 int ReadResponseHeaders(const CompletionCallback
& callback
) override
;
51 int ReadResponseBody(IOBuffer
* buf
,
53 const CompletionCallback
& callback
) override
;
55 void Close(bool not_reusable
) override
;
57 HttpStream
* RenewStreamForAuth() override
;
59 bool IsResponseBodyComplete() const override
;
61 bool IsConnectionReused() const override
;
63 void SetConnectionReused() override
;
65 bool CanReuseConnection() const override
;
67 int64
GetTotalReceivedBytes() const override
;
69 int64_t GetTotalSentBytes() const override
;
71 bool GetLoadTimingInfo(LoadTimingInfo
* load_timing_info
) const override
;
73 void GetSSLInfo(SSLInfo
* ssl_info
) override
;
75 void GetSSLCertRequestInfo(SSLCertRequestInfo
* cert_request_info
) override
;
77 void Drain(HttpNetworkSession
* session
) override
;
79 void SetPriority(RequestPriority priority
) override
;
82 HttpStreamParser
* parser() const { return state_
.parser(); }
84 HttpBasicState state_
;
86 DISALLOW_COPY_AND_ASSIGN(HttpBasicStream
);
91 #endif // NET_HTTP_HTTP_BASIC_STREAM_H_