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/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 439 } |
440 | 440 |
441 if (rv == OK) { | 441 if (rv == OK) { |
442 transaction_->SetBeforeNetworkStartCallback( | 442 transaction_->SetBeforeNetworkStartCallback( |
443 base::Bind(&URLRequestHttpJob::NotifyBeforeNetworkStart, | 443 base::Bind(&URLRequestHttpJob::NotifyBeforeNetworkStart, |
444 base::Unretained(this))); | 444 base::Unretained(this))); |
445 transaction_->SetBeforeProxyHeadersSentCallback( | 445 transaction_->SetBeforeProxyHeadersSentCallback( |
446 base::Bind(&URLRequestHttpJob::NotifyBeforeSendProxyHeadersCallback, | 446 base::Bind(&URLRequestHttpJob::NotifyBeforeSendProxyHeadersCallback, |
447 base::Unretained(this))); | 447 base::Unretained(this))); |
448 | 448 |
449 if (!throttling_entry_ || | 449 if (!throttling_entry_.get() || |
450 !throttling_entry_->ShouldRejectRequest( | 450 !throttling_entry_->ShouldRejectRequest(*request_, |
451 *request_, network_delegate())) { | 451 network_delegate())) { |
452 rv = transaction_->Start( | 452 rv = transaction_->Start( |
453 &request_info_, start_callback_, request_->net_log()); | 453 &request_info_, start_callback_, request_->net_log()); |
454 start_time_ = base::TimeTicks::Now(); | 454 start_time_ = base::TimeTicks::Now(); |
455 } else { | 455 } else { |
456 // Special error code for the exponential back-off module. | 456 // Special error code for the exponential back-off module. |
457 rv = ERR_TEMPORARILY_THROTTLED; | 457 rv = ERR_TEMPORARILY_THROTTLED; |
458 } | 458 } |
459 } | 459 } |
460 } | 460 } |
461 | 461 |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 void URLRequestHttpJob::DoneReadingRedirectResponse() { | 1299 void URLRequestHttpJob::DoneReadingRedirectResponse() { |
1300 if (transaction_) { | 1300 if (transaction_) { |
1301 if (transaction_->GetResponseInfo()->headers->IsRedirect(NULL)) { | 1301 if (transaction_->GetResponseInfo()->headers->IsRedirect(NULL)) { |
1302 // If the original headers indicate a redirect, go ahead and cache the | 1302 // If the original headers indicate a redirect, go ahead and cache the |
1303 // response, even if the |override_response_headers_| are a redirect to | 1303 // response, even if the |override_response_headers_| are a redirect to |
1304 // another location. | 1304 // another location. |
1305 transaction_->DoneReading(); | 1305 transaction_->DoneReading(); |
1306 } else { | 1306 } else { |
1307 // Otherwise, |override_response_headers_| must be non-NULL and contain | 1307 // Otherwise, |override_response_headers_| must be non-NULL and contain |
1308 // bogus headers indicating a redirect. | 1308 // bogus headers indicating a redirect. |
1309 DCHECK(override_response_headers_); | 1309 DCHECK(override_response_headers_.get()); |
1310 DCHECK(override_response_headers_->IsRedirect(NULL)); | 1310 DCHECK(override_response_headers_->IsRedirect(NULL)); |
1311 transaction_->StopCaching(); | 1311 transaction_->StopCaching(); |
1312 } | 1312 } |
1313 } | 1313 } |
1314 DoneWithRequest(FINISHED); | 1314 DoneWithRequest(FINISHED); |
1315 } | 1315 } |
1316 | 1316 |
1317 HostPortPair URLRequestHttpJob::GetSocketAddress() const { | 1317 HostPortPair URLRequestHttpJob::GetSocketAddress() const { |
1318 return response_info_ ? response_info_->socket_address : HostPortPair(); | 1318 return response_info_ ? response_info_->socket_address : HostPortPair(); |
1319 } | 1319 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 return override_response_headers_.get() ? | 1522 return override_response_headers_.get() ? |
1523 override_response_headers_.get() : | 1523 override_response_headers_.get() : |
1524 transaction_->GetResponseInfo()->headers.get(); | 1524 transaction_->GetResponseInfo()->headers.get(); |
1525 } | 1525 } |
1526 | 1526 |
1527 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1527 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1528 awaiting_callback_ = false; | 1528 awaiting_callback_ = false; |
1529 } | 1529 } |
1530 | 1530 |
1531 } // namespace net | 1531 } // namespace net |
OLD | NEW |