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

Side by Side Diff: extensions/browser/extension_request_limiting_throttle.cc

Issue 2535723005: Stop using ResourceController in ResourceThrottle (Closed)
Patch Set: Addressed #62 Created 4 years 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
« no previous file with comments | « content/public/browser/resource_throttle.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "extensions/browser/extension_request_limiting_throttle.h" 5 #include "extensions/browser/extension_request_limiting_throttle.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/public/browser/resource_controller.h"
9 #include "extensions/browser/extension_throttle_entry.h" 8 #include "extensions/browser/extension_throttle_entry.h"
10 #include "extensions/browser/extension_throttle_manager.h" 9 #include "extensions/browser/extension_throttle_manager.h"
11 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
12 #include "net/url_request/redirect_info.h" 11 #include "net/url_request/redirect_info.h"
13 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
14 13
15 namespace extensions { 14 namespace extensions {
16 15
17 ExtensionRequestLimitingThrottle::ExtensionRequestLimitingThrottle( 16 ExtensionRequestLimitingThrottle::ExtensionRequestLimitingThrottle(
18 const net::URLRequest* request, 17 const net::URLRequest* request,
19 ExtensionThrottleManager* manager) 18 ExtensionThrottleManager* manager)
20 : request_(request), manager_(manager) { 19 : request_(request), manager_(manager) {
21 DCHECK(manager_); 20 DCHECK(manager_);
22 } 21 }
23 22
24 ExtensionRequestLimitingThrottle::~ExtensionRequestLimitingThrottle() { 23 ExtensionRequestLimitingThrottle::~ExtensionRequestLimitingThrottle() {
25 } 24 }
26 25
27 void ExtensionRequestLimitingThrottle::WillStartRequest(bool* defer) { 26 void ExtensionRequestLimitingThrottle::WillStartRequest(bool* defer) {
28 throttling_entry_ = manager_->RegisterRequestUrl(request_->url()); 27 throttling_entry_ = manager_->RegisterRequestUrl(request_->url());
29 if (throttling_entry_->ShouldRejectRequest(*request_)) 28 if (throttling_entry_->ShouldRejectRequest(*request_))
30 controller()->CancelWithError(net::ERR_TEMPORARILY_THROTTLED); 29 CancelWithError(net::ERR_TEMPORARILY_THROTTLED);
31 } 30 }
32 31
33 void ExtensionRequestLimitingThrottle::WillRedirectRequest( 32 void ExtensionRequestLimitingThrottle::WillRedirectRequest(
34 const net::RedirectInfo& redirect_info, 33 const net::RedirectInfo& redirect_info,
35 bool* defer) { 34 bool* defer) {
36 DCHECK_EQ(manager_->GetIdFromUrl(request_->url()), 35 DCHECK_EQ(manager_->GetIdFromUrl(request_->url()),
37 throttling_entry_->GetURLIdForDebugging()); 36 throttling_entry_->GetURLIdForDebugging());
38 37
39 throttling_entry_->UpdateWithResponse(redirect_info.status_code); 38 throttling_entry_->UpdateWithResponse(redirect_info.status_code);
40 39
41 throttling_entry_ = manager_->RegisterRequestUrl(redirect_info.new_url); 40 throttling_entry_ = manager_->RegisterRequestUrl(redirect_info.new_url);
42 if (throttling_entry_->ShouldRejectRequest(*request_)) 41 if (throttling_entry_->ShouldRejectRequest(*request_))
43 controller()->CancelWithError(net::ERR_TEMPORARILY_THROTTLED); 42 CancelWithError(net::ERR_TEMPORARILY_THROTTLED);
44 } 43 }
45 44
46 void ExtensionRequestLimitingThrottle::WillProcessResponse(bool* defer) { 45 void ExtensionRequestLimitingThrottle::WillProcessResponse(bool* defer) {
47 DCHECK_EQ(manager_->GetIdFromUrl(request_->url()), 46 DCHECK_EQ(manager_->GetIdFromUrl(request_->url()),
48 throttling_entry_->GetURLIdForDebugging()); 47 throttling_entry_->GetURLIdForDebugging());
49 48
50 if (!request_->was_cached()) 49 if (!request_->was_cached())
51 throttling_entry_->UpdateWithResponse(request_->GetResponseCode()); 50 throttling_entry_->UpdateWithResponse(request_->GetResponseCode());
52 } 51 }
53 52
54 const char* ExtensionRequestLimitingThrottle::GetNameForLogging() const { 53 const char* ExtensionRequestLimitingThrottle::GetNameForLogging() const {
55 return "ExtensionRequestLimitingThrottle"; 54 return "ExtensionRequestLimitingThrottle";
56 } 55 }
57 56
58 } // namespace extensions 57 } // namespace extensions
OLDNEW
« no previous file with comments | « content/public/browser/resource_throttle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698