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

Unified Diff: net/url_request/url_request_http_job.cc

Issue 10203002: Make URLRequestThrottlerManager a member of URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_throttler_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_http_job.cc
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 8e6626afe9874b3ec963197955fb8cf2fc4ac710..4e31963fef995da495be1fc3206f45a31d0b4b70 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -176,8 +176,7 @@ URLRequestHttpJob::URLRequestHttpJob(URLRequest* request)
base::Unretained(this)))),
read_in_progress_(false),
transaction_(NULL),
- throttling_entry_(URLRequestThrottlerManager::GetInstance()->
- RegisterRequestUrl(request->url())),
+ throttling_entry_(NULL),
sdch_dictionary_advertised_(false),
sdch_test_activated_(false),
sdch_test_control_(false),
@@ -195,6 +194,10 @@ URLRequestHttpJob::URLRequestHttpJob(URLRequest* request)
base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback,
base::Unretained(this)))),
awaiting_callback_(false) {
+ URLRequestThrottlerManager* manager = request->context()->throttler_manager();
+ if (manager)
+ throttling_entry_ = manager->RegisterRequestUrl(request->url());
+
ResetTimer();
}
@@ -207,7 +210,7 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
// also need this info.
is_cached_content_ = response_info_->was_cached;
- if (!is_cached_content_) {
+ if (!is_cached_content_ && throttling_entry_) {
URLRequestThrottlerHeaderAdapter response_adapter(GetResponseHeaders());
throttling_entry_->UpdateWithResponse(request_info_.url.host(),
&response_adapter);
@@ -325,7 +328,11 @@ void URLRequestHttpJob::StartTransactionInternal() {
// change (to throttle only requests originating from
// extensions) gets into M19. Right after the M19 branch point,
// I will sort this out in a more architecturally-sound way.
- if (!URLRequestThrottlerManager::GetInstance()->enforce_throttling() ||
+ URLRequestThrottlerManager* manager =
+ request_->context()->throttler_manager();
+ DCHECK(!manager || throttling_entry_);
+ if (!manager ||
+ !manager->enforce_throttling() ||
request_->first_party_for_cookies().scheme() != "chrome-extension" ||
!throttling_entry_->ShouldRejectRequest(request_info_.load_flags)) {
rv = transaction_->Start(
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_throttler_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698