Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: net/http/http_pipelined_connection_impl.cc

Issue 8591037: Implement Drain() on HttpPipelinedStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Skip on unusable Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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() ||
615 !usable_) {
616 // TODO(simonjam): Drain chunk-encoded responses if they're relatively
617 // common.
618 stream->Close(true);
619 delete stream;
620 return;
621 }
622 HttpResponseBodyDrainer* drainer = new HttpResponseBodyDrainer(stream);
623 drainer->StartWithSize(session, headers->GetContentLength());
624 // |drainer| will delete itself when done.
625 }
626
609 void HttpPipelinedConnectionImpl::QueueUserCallback( 627 void HttpPipelinedConnectionImpl::QueueUserCallback(
610 int pipeline_id, 628 int pipeline_id,
611 OldCompletionCallback* callback, 629 OldCompletionCallback* callback,
612 int rv, 630 int rv,
613 const tracked_objects::Location& from_here) { 631 const tracked_objects::Location& from_here) {
614 CHECK(!stream_info_map_[pipeline_id].pending_user_callback); 632 CHECK(!stream_info_map_[pipeline_id].pending_user_callback);
615 stream_info_map_[pipeline_id].pending_user_callback = callback; 633 stream_info_map_[pipeline_id].pending_user_callback = callback;
616 MessageLoop::current()->PostTask( 634 MessageLoop::current()->PostTask(
617 from_here, 635 from_here,
618 method_factory_.NewRunnableMethod( 636 method_factory_.NewRunnableMethod(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 HttpPipelinedConnectionImpl::StreamInfo::StreamInfo() 687 HttpPipelinedConnectionImpl::StreamInfo::StreamInfo()
670 : read_headers_callback(NULL), 688 : read_headers_callback(NULL),
671 pending_user_callback(NULL), 689 pending_user_callback(NULL),
672 state(STREAM_CREATED) { 690 state(STREAM_CREATED) {
673 } 691 }
674 692
675 HttpPipelinedConnectionImpl::StreamInfo::~StreamInfo() { 693 HttpPipelinedConnectionImpl::StreamInfo::~StreamInfo() {
676 } 694 }
677 695
678 } // namespace net 696 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_pipelined_connection_impl.h ('k') | net/http/http_pipelined_connection_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698