Chromium Code Reviews| Index: net/url_request/url_request_http_job.cc |
| =================================================================== |
| --- net/url_request/url_request_http_job.cc (revision 66188) |
| +++ net/url_request/url_request_http_job.cc (working copy) |
| @@ -29,6 +29,8 @@ |
| #include "net/http/http_transaction_factory.h" |
| #include "net/http/http_util.h" |
| #include "net/url_request/https_prober.h" |
| +#include "net/url_request/request_throttler_header_adapter.h" |
| +#include "net/url_request/request_throttler_manager.h" |
| #include "net/url_request/url_request.h" |
| #include "net/url_request/url_request_context.h" |
| #include "net/url_request/url_request_error_job.h" |
| @@ -92,6 +94,8 @@ |
| this, &URLRequestHttpJob::OnReadCompleted)), |
| read_in_progress_(false), |
| transaction_(NULL), |
| + throttling_entry_(RequestThrottlerManager::GetInstance()-> |
| + RegisterRequestUrl(request->url())), |
| sdch_dictionary_advertised_(false), |
| sdch_test_activated_(false), |
| sdch_test_control_(false), |
| @@ -570,6 +574,11 @@ |
| // also need this info. |
| is_cached_content_ = response_info_->was_cached; |
| + if (!is_cached_content_) { |
| + RequestThrottlerHeaderAdapter response_adapter(response_info_->headers); |
| + throttling_entry_->UpdateWithResponse(&response_adapter); |
| + } |
| + |
| ProcessStrictTransportSecurityHeader(); |
| if (SdchManager::Global() && |
| @@ -617,30 +626,37 @@ |
| // If we already have a transaction, then we should restart the transaction |
| // with auth provided by username_ and password_. |
| - int rv; |
| + int return_value; |
|
willchan no longer on Chromium
2010/11/24 10:14:50
rv is sufficiently common in the network stack tha
yzshen
2010/11/24 19:09:30
Done.
|
| + |
| if (transaction_.get()) { |
| - rv = transaction_->RestartWithAuth(username_, password_, &start_callback_); |
| + return_value = transaction_->RestartWithAuth(username_, |
| + password_, &start_callback_); |
| username_.clear(); |
| password_.clear(); |
| } else { |
| DCHECK(request_->context()); |
| DCHECK(request_->context()->http_transaction_factory()); |
| - rv = request_->context()->http_transaction_factory()->CreateTransaction( |
| - &transaction_); |
| - if (rv == net::OK) { |
| - rv = transaction_->Start( |
| - &request_info_, &start_callback_, request_->net_log()); |
| + return_value = request_->context()->http_transaction_factory()-> |
| + CreateTransaction(&transaction_); |
| + if (return_value == net::OK) { |
| + if (!throttling_entry_->IsDuringExponentialBackoff()) { |
| + return_value = transaction_->Start( |
| + &request_info_, &start_callback_, request_->net_log()); |
| + } else { |
| + // Special error code for the exponential back-off module. |
| + return_value = net::ERR_TEMPORARILY_THROTTLED_BY_DDOS; |
| + } |
| } |
| } |
| - if (rv == net::ERR_IO_PENDING) |
| + if (return_value == net::ERR_IO_PENDING) |
| return; |
| // The transaction started synchronously, but we need to notify the |
| // URLRequest delegate via the message loop. |
| MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
| - this, &URLRequestHttpJob::OnStartCompleted, rv)); |
| + this, &URLRequestHttpJob::OnStartCompleted, return_value)); |
| } |
| void URLRequestHttpJob::AddExtraHeaders() { |