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

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

Issue 18390: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months 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
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_transaction.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/trace_event.h" 10 #include "base/trace_event.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 using_proxy_(false), 45 using_proxy_(false),
46 using_tunnel_(false), 46 using_tunnel_(false),
47 establishing_tunnel_(false), 47 establishing_tunnel_(false),
48 request_headers_bytes_sent_(0), 48 request_headers_bytes_sent_(0),
49 header_buf_capacity_(0), 49 header_buf_capacity_(0),
50 header_buf_len_(0), 50 header_buf_len_(0),
51 header_buf_body_offset_(-1), 51 header_buf_body_offset_(-1),
52 header_buf_http_offset_(-1), 52 header_buf_http_offset_(-1),
53 content_length_(-1), // -1 means unspecified. 53 content_length_(-1), // -1 means unspecified.
54 content_read_(0), 54 content_read_(0),
55 read_buf_(NULL),
56 read_buf_len_(0), 55 read_buf_len_(0),
57 next_state_(STATE_NONE) { 56 next_state_(STATE_NONE) {
58 #if defined(OS_WIN) 57 #if defined(OS_WIN)
59 // TODO(port): Port the SSLConfigService class to Linux and Mac OS X. 58 // TODO(port): Port the SSLConfigService class to Linux and Mac OS X.
60 session->ssl_config_service()->GetSSLConfig(&ssl_config_); 59 session->ssl_config_service()->GetSSLConfig(&ssl_config_);
61 #endif 60 #endif
62 } 61 }
63 62
64 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info, 63 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info,
65 CompletionCallback* callback) { 64 CompletionCallback* callback) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 AuthPath(target)); 126 AuthPath(target));
128 127
129 next_state_ = STATE_INIT_CONNECTION; 128 next_state_ = STATE_INIT_CONNECTION;
130 connection_.set_socket(NULL); 129 connection_.set_socket(NULL);
131 connection_.Reset(); 130 connection_.Reset();
132 131
133 // Reset the other member variables. 132 // Reset the other member variables.
134 ResetStateForRestart(); 133 ResetStateForRestart();
135 } 134 }
136 135
137 int HttpNetworkTransaction::Read(char* buf, int buf_len, 136 int HttpNetworkTransaction::Read(IOBuffer* buf, int buf_len,
138 CompletionCallback* callback) { 137 CompletionCallback* callback) {
139 DCHECK(response_.headers); 138 DCHECK(response_.headers);
140 DCHECK(buf); 139 DCHECK(buf);
141 DCHECK(buf_len > 0); 140 DCHECK(buf_len > 0);
142 141
143 if (!connection_.is_initialized()) 142 if (!connection_.is_initialized())
144 return 0; // connection_ has been reset. Treat like EOF. 143 return 0; // connection_ has been reset. Treat like EOF.
145 144
146 read_buf_ = buf; 145 read_buf_ = buf;
147 read_buf_len_ = buf_len; 146 read_buf_len_ = buf_len;
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 718
720 next_state_ = STATE_READ_BODY_COMPLETE; 719 next_state_ = STATE_READ_BODY_COMPLETE;
721 720
722 // We may have already consumed the indicated content length. 721 // We may have already consumed the indicated content length.
723 if (content_length_ != -1 && content_read_ >= content_length_) 722 if (content_length_ != -1 && content_read_ >= content_length_)
724 return 0; 723 return 0;
725 724
726 // We may have some data remaining in the header buffer. 725 // We may have some data remaining in the header buffer.
727 if (header_buf_.get() && header_buf_body_offset_ < header_buf_len_) { 726 if (header_buf_.get() && header_buf_body_offset_ < header_buf_len_) {
728 int n = std::min(read_buf_len_, header_buf_len_ - header_buf_body_offset_); 727 int n = std::min(read_buf_len_, header_buf_len_ - header_buf_body_offset_);
729 memcpy(read_buf_, header_buf_.get() + header_buf_body_offset_, n); 728 memcpy(read_buf_->data(), header_buf_.get() + header_buf_body_offset_, n);
730 header_buf_body_offset_ += n; 729 header_buf_body_offset_ += n;
731 if (header_buf_body_offset_ == header_buf_len_) { 730 if (header_buf_body_offset_ == header_buf_len_) {
732 header_buf_.reset(); 731 header_buf_.reset();
733 header_buf_capacity_ = 0; 732 header_buf_capacity_ = 0;
734 header_buf_len_ = 0; 733 header_buf_len_ = 0;
735 header_buf_body_offset_ = -1; 734 header_buf_body_offset_ = -1;
736 } 735 }
737 return n; 736 return n;
738 } 737 }
739 738
740 return connection_.socket()->Read(read_buf_, read_buf_len_, &io_callback_); 739 return connection_.socket()->Read(read_buf_->data(), read_buf_len_,
740 &io_callback_);
741 } 741 }
742 742
743 int HttpNetworkTransaction::DoReadBodyComplete(int result) { 743 int HttpNetworkTransaction::DoReadBodyComplete(int result) {
744 // We are done with the Read call. 744 // We are done with the Read call.
745 745
746 bool unfiltered_eof = (result == 0); 746 bool unfiltered_eof = (result == 0);
747 747
748 // Filter incoming data if appropriate. FilterBuf may return an error. 748 // Filter incoming data if appropriate. FilterBuf may return an error.
749 if (result > 0 && chunked_decoder_.get()) { 749 if (result > 0 && chunked_decoder_.get()) {
750 result = chunked_decoder_->FilterBuf(read_buf_, result); 750 result = chunked_decoder_->FilterBuf(read_buf_->data(), result);
751 if (result == 0 && !chunked_decoder_->reached_eof()) { 751 if (result == 0 && !chunked_decoder_->reached_eof()) {
752 // Don't signal completion of the Read call yet or else it'll look like 752 // Don't signal completion of the Read call yet or else it'll look like
753 // we received end-of-file. Wait for more data. 753 // we received end-of-file. Wait for more data.
754 next_state_ = STATE_READ_BODY; 754 next_state_ = STATE_READ_BODY;
755 return OK; 755 return OK;
756 } 756 }
757 } 757 }
758 758
759 bool done = false, keep_alive = false; 759 bool done = false, keep_alive = false;
760 if (result < 0) { 760 if (result < 0) {
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 if (target == HttpAuth::AUTH_PROXY) { 1263 if (target == HttpAuth::AUTH_PROXY) {
1264 auth_info->host = ASCIIToWide(proxy_info_.proxy_server()); 1264 auth_info->host = ASCIIToWide(proxy_info_.proxy_server());
1265 } else { 1265 } else {
1266 DCHECK(target == HttpAuth::AUTH_SERVER); 1266 DCHECK(target == HttpAuth::AUTH_SERVER);
1267 auth_info->host = ASCIIToWide(request_->url.host()); 1267 auth_info->host = ASCIIToWide(request_->url.host());
1268 } 1268 }
1269 response_.auth_challenge = auth_info; 1269 response_.auth_challenge = auth_info;
1270 } 1270 }
1271 1271
1272 } // namespace net 1272 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698