Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_pipelined_connection_impl.h" | 5 #include "net/http/http_pipelined_connection_impl.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/http/http_pipelined_stream.h" | 10 #include "net/http/http_pipelined_stream.h" |
| 11 #include "net/http/http_request_info.h" | 11 #include "net/http/http_request_info.h" |
| 12 #include "net/http/http_response_body_drainer.h" | |
| 13 #include "net/http/http_response_headers.h" | |
| 12 #include "net/http/http_stream_parser.h" | 14 #include "net/http/http_stream_parser.h" |
| 13 #include "net/socket/client_socket_handle.h" | 15 #include "net/socket/client_socket_handle.h" |
| 14 | 16 |
| 15 namespace net { | 17 namespace net { |
| 16 | 18 |
| 17 HttpPipelinedConnectionImpl::HttpPipelinedConnectionImpl( | 19 HttpPipelinedConnectionImpl::HttpPipelinedConnectionImpl( |
| 18 ClientSocketHandle* connection, | 20 ClientSocketHandle* connection, |
| 19 HttpPipelinedConnection::Delegate* delegate, | 21 HttpPipelinedConnection::Delegate* delegate, |
| 20 const SSLConfig& used_ssl_config, | 22 const SSLConfig& used_ssl_config, |
| 21 const ProxyInfo& used_proxy_info, | 23 const ProxyInfo& used_proxy_info, |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 | 601 |
| 600 void HttpPipelinedConnectionImpl::GetSSLCertRequestInfo( | 602 void HttpPipelinedConnectionImpl::GetSSLCertRequestInfo( |
| 601 int pipeline_id, | 603 int pipeline_id, |
| 602 SSLCertRequestInfo* cert_request_info) { | 604 SSLCertRequestInfo* cert_request_info) { |
| 603 CHECK(ContainsKey(stream_info_map_, pipeline_id)); | 605 CHECK(ContainsKey(stream_info_map_, pipeline_id)); |
| 604 CHECK(stream_info_map_[pipeline_id].parser.get()); | 606 CHECK(stream_info_map_[pipeline_id].parser.get()); |
| 605 return stream_info_map_[pipeline_id].parser->GetSSLCertRequestInfo( | 607 return stream_info_map_[pipeline_id].parser->GetSSLCertRequestInfo( |
| 606 cert_request_info); | 608 cert_request_info); |
| 607 } | 609 } |
| 608 | 610 |
| 611 void HttpPipelinedConnectionImpl::Drain(HttpPipelinedStream* stream, | |
| 612 HttpNetworkSession* session) { | |
| 613 HttpResponseHeaders* headers = stream->GetResponseInfo()->headers; | |
| 614 if (!stream->CanFindEndOfResponse() || headers->IsChunkEncoded()) { | |
|
mmenke
2011/11/30 00:52:59
One more comment. Feel free to worry about it lat
James Simonsen
2011/11/30 19:39:14
Done.
| |
| 615 // TODO(simonjam): Drain chunk-encoded responses if they're relatively | |
| 616 // common. | |
| 617 stream->Close(true); | |
| 618 delete stream; | |
| 619 return; | |
| 620 } | |
| 621 HttpResponseBodyDrainer* drainer = new HttpResponseBodyDrainer(stream); | |
| 622 drainer->StartWithSize(session, headers->GetContentLength()); | |
| 623 // |drainer| will delete itself when done. | |
| 624 } | |
| 625 | |
| 609 void HttpPipelinedConnectionImpl::QueueUserCallback( | 626 void HttpPipelinedConnectionImpl::QueueUserCallback( |
| 610 int pipeline_id, | 627 int pipeline_id, |
| 611 OldCompletionCallback* callback, | 628 OldCompletionCallback* callback, |
| 612 int rv, | 629 int rv, |
| 613 const tracked_objects::Location& from_here) { | 630 const tracked_objects::Location& from_here) { |
| 614 CHECK(!stream_info_map_[pipeline_id].pending_user_callback); | 631 CHECK(!stream_info_map_[pipeline_id].pending_user_callback); |
| 615 stream_info_map_[pipeline_id].pending_user_callback = callback; | 632 stream_info_map_[pipeline_id].pending_user_callback = callback; |
| 616 MessageLoop::current()->PostTask( | 633 MessageLoop::current()->PostTask( |
| 617 from_here, | 634 from_here, |
| 618 method_factory_.NewRunnableMethod( | 635 method_factory_.NewRunnableMethod( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 HttpPipelinedConnectionImpl::StreamInfo::StreamInfo() | 686 HttpPipelinedConnectionImpl::StreamInfo::StreamInfo() |
| 670 : read_headers_callback(NULL), | 687 : read_headers_callback(NULL), |
| 671 pending_user_callback(NULL), | 688 pending_user_callback(NULL), |
| 672 state(STREAM_CREATED) { | 689 state(STREAM_CREATED) { |
| 673 } | 690 } |
| 674 | 691 |
| 675 HttpPipelinedConnectionImpl::StreamInfo::~StreamInfo() { | 692 HttpPipelinedConnectionImpl::StreamInfo::~StreamInfo() { |
| 676 } | 693 } |
| 677 | 694 |
| 678 } // namespace net | 695 } // namespace net |
| OLD | NEW |