OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/field_trial.h" | 9 #include "base/field_trial.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 response_body_length_(-1), // -1 means unspecified. | 154 response_body_length_(-1), // -1 means unspecified. |
155 response_body_read_(0), | 155 response_body_read_(0), |
156 read_buf_len_(0), | 156 read_buf_len_(0), |
157 next_state_(STATE_NONE) { | 157 next_state_(STATE_NONE) { |
158 #if defined(OS_WIN) | 158 #if defined(OS_WIN) |
159 // TODO(port): Port the SSLConfigService class to Linux and Mac OS X. | 159 // TODO(port): Port the SSLConfigService class to Linux and Mac OS X. |
160 session->ssl_config_service()->GetSSLConfig(&ssl_config_); | 160 session->ssl_config_service()->GetSSLConfig(&ssl_config_); |
161 #endif | 161 #endif |
162 } | 162 } |
163 | 163 |
164 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info, | 164 int HttpNetworkTransaction::Start(LoadLog* load_log, |
| 165 const HttpRequestInfo* request_info, |
165 CompletionCallback* callback) { | 166 CompletionCallback* callback) { |
166 UpdateConnectionTypeHistograms(CONNECTION_ANY); | 167 UpdateConnectionTypeHistograms(CONNECTION_ANY); |
167 | 168 |
| 169 load_log_ = load_log; |
168 request_ = request_info; | 170 request_ = request_info; |
169 start_time_ = base::Time::Now(); | 171 start_time_ = base::Time::Now(); |
170 | 172 |
171 next_state_ = STATE_RESOLVE_PROXY; | 173 next_state_ = STATE_RESOLVE_PROXY; |
172 int rv = DoLoop(OK); | 174 int rv = DoLoop(OK); |
173 if (rv == ERR_IO_PENDING) | 175 if (rv == ERR_IO_PENDING) |
174 user_callback_ = callback; | 176 user_callback_ = callback; |
175 return rv; | 177 return rv; |
176 } | 178 } |
177 | 179 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 DCHECK(!pac_request_); | 535 DCHECK(!pac_request_); |
534 | 536 |
535 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 537 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
536 | 538 |
537 if (request_->load_flags & LOAD_BYPASS_PROXY) { | 539 if (request_->load_flags & LOAD_BYPASS_PROXY) { |
538 proxy_info_.UseDirect(); | 540 proxy_info_.UseDirect(); |
539 return OK; | 541 return OK; |
540 } | 542 } |
541 | 543 |
542 return session_->proxy_service()->ResolveProxy( | 544 return session_->proxy_service()->ResolveProxy( |
543 request_->url, &proxy_info_, &io_callback_, &pac_request_); | 545 load_log_, request_->url, &proxy_info_, &io_callback_, &pac_request_); |
544 } | 546 } |
545 | 547 |
546 int HttpNetworkTransaction::DoResolveProxyComplete(int result) { | 548 int HttpNetworkTransaction::DoResolveProxyComplete(int result) { |
547 next_state_ = STATE_INIT_CONNECTION; | 549 next_state_ = STATE_INIT_CONNECTION; |
548 | 550 |
549 // Remove unsupported proxies from the list. | 551 // Remove unsupported proxies from the list. |
550 proxy_info_.RemoveProxiesWithoutScheme( | 552 proxy_info_.RemoveProxiesWithoutScheme( |
551 ProxyServer::SCHEME_DIRECT | ProxyServer::SCHEME_HTTP | | 553 ProxyServer::SCHEME_DIRECT | ProxyServer::SCHEME_HTTP | |
552 ProxyServer::SCHEME_SOCKS4 | ProxyServer::SCHEME_SOCKS5); | 554 ProxyServer::SCHEME_SOCKS4 | ProxyServer::SCHEME_SOCKS5); |
553 | 555 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 resolve_info.set_referrer(request_->referrer); | 622 resolve_info.set_referrer(request_->referrer); |
621 | 623 |
622 // If the user is refreshing the page, bypass the host cache. | 624 // If the user is refreshing the page, bypass the host cache. |
623 if (request_->load_flags & LOAD_BYPASS_CACHE || | 625 if (request_->load_flags & LOAD_BYPASS_CACHE || |
624 request_->load_flags & LOAD_DISABLE_CACHE) { | 626 request_->load_flags & LOAD_DISABLE_CACHE) { |
625 resolve_info.set_allow_cached_response(false); | 627 resolve_info.set_allow_cached_response(false); |
626 } | 628 } |
627 | 629 |
628 transport_socket_request_time_ = base::TimeTicks::Now(); | 630 transport_socket_request_time_ = base::TimeTicks::Now(); |
629 | 631 |
630 int rv = connection_.Init(connection_group, resolve_info, request_->priority, | 632 int rv = connection_.Init(NULL, connection_group, resolve_info, |
631 &io_callback_); | 633 request_->priority, &io_callback_); |
632 return rv; | 634 return rv; |
633 } | 635 } |
634 | 636 |
635 int HttpNetworkTransaction::DoInitConnectionComplete(int result) { | 637 int HttpNetworkTransaction::DoInitConnectionComplete(int result) { |
636 if (result < 0) | 638 if (result < 0) |
637 return ReconsiderProxyAfterError(result); | 639 return ReconsiderProxyAfterError(result); |
638 | 640 |
639 DCHECK(connection_.is_initialized()); | 641 DCHECK(connection_.is_initialized()); |
640 | 642 |
641 // Set the reused_socket_ flag to indicate that we are using a keep-alive | 643 // Set the reused_socket_ flag to indicate that we are using a keep-alive |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 break; | 1539 break; |
1538 default: | 1540 default: |
1539 return error; | 1541 return error; |
1540 } | 1542 } |
1541 | 1543 |
1542 if (request_->load_flags & LOAD_BYPASS_PROXY) { | 1544 if (request_->load_flags & LOAD_BYPASS_PROXY) { |
1543 return error; | 1545 return error; |
1544 } | 1546 } |
1545 | 1547 |
1546 int rv = session_->proxy_service()->ReconsiderProxyAfterError( | 1548 int rv = session_->proxy_service()->ReconsiderProxyAfterError( |
1547 request_->url, &proxy_info_, &io_callback_, &pac_request_); | 1549 load_log_, request_->url, &proxy_info_, &io_callback_, &pac_request_); |
1548 if (rv == OK || rv == ERR_IO_PENDING) { | 1550 if (rv == OK || rv == ERR_IO_PENDING) { |
1549 // If the error was during connection setup, there is no socket to | 1551 // If the error was during connection setup, there is no socket to |
1550 // disconnect. | 1552 // disconnect. |
1551 if (connection_.socket()) | 1553 if (connection_.socket()) |
1552 connection_.socket()->Disconnect(); | 1554 connection_.socket()->Disconnect(); |
1553 connection_.Reset(); | 1555 connection_.Reset(); |
1554 DCHECK(!request_headers_bytes_sent_); | 1556 DCHECK(!request_headers_bytes_sent_); |
1555 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 1557 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
1556 } else { | 1558 } else { |
1557 rv = error; | 1559 rv = error; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 host_and_port = proxy_info_.proxy_server().host_and_port(); | 1827 host_and_port = proxy_info_.proxy_server().host_and_port(); |
1826 } else { | 1828 } else { |
1827 DCHECK(target == HttpAuth::AUTH_SERVER); | 1829 DCHECK(target == HttpAuth::AUTH_SERVER); |
1828 host_and_port = GetHostAndPort(request_->url); | 1830 host_and_port = GetHostAndPort(request_->url); |
1829 } | 1831 } |
1830 auth_info->host_and_port = ASCIIToWide(host_and_port); | 1832 auth_info->host_and_port = ASCIIToWide(host_and_port); |
1831 response_.auth_challenge = auth_info; | 1833 response_.auth_challenge = auth_info; |
1832 } | 1834 } |
1833 | 1835 |
1834 } // namespace net | 1836 } // namespace net |
OLD | NEW |