| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_basic_stream.h" | 5 #include "net/http/http_basic_stream.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "net/http/http_request_info.h" | 8 #include "net/http/http_request_info.h" |
| 9 #include "net/http/http_response_body_drainer.h" | 9 #include "net/http/http_response_body_drainer.h" |
| 10 #include "net/http/http_stream_parser.h" | 10 #include "net/http/http_stream_parser.h" |
| 11 #include "net/socket/client_socket_handle.h" | 11 #include "net/socket/client_socket_handle.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection, | 15 HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection, |
| 16 bool using_proxy) | 16 bool using_proxy) |
| 17 : state_(connection, using_proxy) {} | 17 : state_(connection, using_proxy) { |
| 18 } |
| 18 | 19 |
| 19 HttpBasicStream::~HttpBasicStream() {} | 20 HttpBasicStream::~HttpBasicStream() { |
| 21 } |
| 20 | 22 |
| 21 int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info, | 23 int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info, |
| 22 RequestPriority priority, | 24 RequestPriority priority, |
| 23 const BoundNetLog& net_log, | 25 const BoundNetLog& net_log, |
| 24 const CompletionCallback& callback) { | 26 const CompletionCallback& callback) { |
| 25 state_.Initialize(request_info, priority, net_log, callback); | 27 state_.Initialize(request_info, priority, net_log, callback); |
| 26 return OK; | 28 return OK; |
| 27 } | 29 } |
| 28 | 30 |
| 29 int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers, | 31 int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 74 } |
| 73 | 75 |
| 74 bool HttpBasicStream::CanFindEndOfResponse() const { | 76 bool HttpBasicStream::CanFindEndOfResponse() const { |
| 75 return parser()->CanFindEndOfResponse(); | 77 return parser()->CanFindEndOfResponse(); |
| 76 } | 78 } |
| 77 | 79 |
| 78 bool HttpBasicStream::IsConnectionReused() const { | 80 bool HttpBasicStream::IsConnectionReused() const { |
| 79 return parser()->IsConnectionReused(); | 81 return parser()->IsConnectionReused(); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void HttpBasicStream::SetConnectionReused() { parser()->SetConnectionReused(); } | 84 void HttpBasicStream::SetConnectionReused() { |
| 85 parser()->SetConnectionReused(); |
| 86 } |
| 83 | 87 |
| 84 bool HttpBasicStream::IsConnectionReusable() const { | 88 bool HttpBasicStream::IsConnectionReusable() const { |
| 85 return parser()->IsConnectionReusable(); | 89 return parser()->IsConnectionReusable(); |
| 86 } | 90 } |
| 87 | 91 |
| 88 int64 HttpBasicStream::GetTotalReceivedBytes() const { | 92 int64 HttpBasicStream::GetTotalReceivedBytes() const { |
| 89 if (parser()) | 93 if (parser()) |
| 90 return parser()->received_bytes(); | 94 return parser()->received_bytes(); |
| 91 return 0; | 95 return 0; |
| 92 } | 96 } |
| 93 | 97 |
| 94 bool HttpBasicStream::GetLoadTimingInfo( | 98 bool HttpBasicStream::GetLoadTimingInfo( |
| 95 LoadTimingInfo* load_timing_info) const { | 99 LoadTimingInfo* load_timing_info) const { |
| 96 return state_.connection()->GetLoadTimingInfo(IsConnectionReused(), | 100 return state_.connection()->GetLoadTimingInfo(IsConnectionReused(), |
| 97 load_timing_info); | 101 load_timing_info); |
| 98 } | 102 } |
| 99 | 103 |
| 100 void HttpBasicStream::GetSSLInfo(SSLInfo* ssl_info) { | 104 void HttpBasicStream::GetSSLInfo(SSLInfo* ssl_info) { |
| 101 parser()->GetSSLInfo(ssl_info); | 105 parser()->GetSSLInfo(ssl_info); |
| 102 } | 106 } |
| 103 | 107 |
| 104 void HttpBasicStream::GetSSLCertRequestInfo( | 108 void HttpBasicStream::GetSSLCertRequestInfo( |
| 105 SSLCertRequestInfo* cert_request_info) { | 109 SSLCertRequestInfo* cert_request_info) { |
| 106 parser()->GetSSLCertRequestInfo(cert_request_info); | 110 parser()->GetSSLCertRequestInfo(cert_request_info); |
| 107 } | 111 } |
| 108 | 112 |
| 109 bool HttpBasicStream::IsSpdyHttpStream() const { return false; } | 113 bool HttpBasicStream::IsSpdyHttpStream() const { |
| 114 return false; |
| 115 } |
| 110 | 116 |
| 111 void HttpBasicStream::Drain(HttpNetworkSession* session) { | 117 void HttpBasicStream::Drain(HttpNetworkSession* session) { |
| 112 HttpResponseBodyDrainer* drainer = new HttpResponseBodyDrainer(this); | 118 HttpResponseBodyDrainer* drainer = new HttpResponseBodyDrainer(this); |
| 113 drainer->Start(session); | 119 drainer->Start(session); |
| 114 // |drainer| will delete itself. | 120 // |drainer| will delete itself. |
| 115 } | 121 } |
| 116 | 122 |
| 117 void HttpBasicStream::SetPriority(RequestPriority priority) { | 123 void HttpBasicStream::SetPriority(RequestPriority priority) { |
| 118 // TODO(akalin): Plumb this through to |connection_|. | 124 // TODO(akalin): Plumb this through to |connection_|. |
| 119 } | 125 } |
| 120 | 126 |
| 121 } // namespace net | 127 } // namespace net |
| OLD | NEW |