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

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

Issue 1909773002: Convert //extensions/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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 unified diff | Download patch
OLDNEW
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 "extensions/browser/extension_throttle_manager.h" 5 #include "extensions/browser/extension_throttle_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "extensions/browser/extension_request_limiting_throttle.h" 14 #include "extensions/browser/extension_request_limiting_throttle.h"
14 #include "extensions/common/constants.h" 15 #include "extensions/common/constants.h"
15 #include "net/base/url_util.h" 16 #include "net/base/url_util.h"
16 #include "net/log/net_log.h" 17 #include "net/log/net_log.h"
17 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
18 19
19 namespace extensions { 20 namespace extensions {
(...skipping 27 matching lines...) Expand all
47 if (i->second.get() != NULL) { 48 if (i->second.get() != NULL) {
48 i->second->DetachManager(); 49 i->second->DetachManager();
49 } 50 }
50 ++i; 51 ++i;
51 } 52 }
52 53
53 // Delete all entries. 54 // Delete all entries.
54 url_entries_.clear(); 55 url_entries_.clear();
55 } 56 }
56 57
57 scoped_ptr<content::ResourceThrottle> 58 std::unique_ptr<content::ResourceThrottle>
58 ExtensionThrottleManager::MaybeCreateThrottle(const net::URLRequest* request) { 59 ExtensionThrottleManager::MaybeCreateThrottle(const net::URLRequest* request) {
59 if (request->first_party_for_cookies().scheme() != 60 if (request->first_party_for_cookies().scheme() !=
60 extensions::kExtensionScheme) { 61 extensions::kExtensionScheme) {
61 return nullptr; 62 return nullptr;
62 } 63 }
63 return make_scoped_ptr( 64 return base::WrapUnique(
64 new extensions::ExtensionRequestLimitingThrottle(request, this)); 65 new extensions::ExtensionRequestLimitingThrottle(request, this));
65 } 66 }
66 67
67 scoped_refptr<ExtensionThrottleEntryInterface> 68 scoped_refptr<ExtensionThrottleEntryInterface>
68 ExtensionThrottleManager::RegisterRequestUrl(const GURL& url) { 69 ExtensionThrottleManager::RegisterRequestUrl(const GURL& url) {
69 DCHECK(!enable_thread_checks_ || CalledOnValidThread()); 70 DCHECK(!enable_thread_checks_ || CalledOnValidThread());
70 71
71 // Normalize the url. 72 // Normalize the url.
72 std::string url_id = GetIdFromUrl(url); 73 std::string url_id = GetIdFromUrl(url);
73 74
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // we can simply return a dummy implementation of 112 // we can simply return a dummy implementation of
112 // ExtensionThrottleEntryInterface here that never blocks anything. 113 // ExtensionThrottleEntryInterface here that never blocks anything.
113 entry->DisableBackoffThrottling(); 114 entry->DisableBackoffThrottling();
114 } 115 }
115 } 116 }
116 117
117 return entry; 118 return entry;
118 } 119 }
119 120
120 void ExtensionThrottleManager::SetBackoffPolicyForTests( 121 void ExtensionThrottleManager::SetBackoffPolicyForTests(
121 scoped_ptr<net::BackoffEntry::Policy> policy) { 122 std::unique_ptr<net::BackoffEntry::Policy> policy) {
122 backoff_policy_for_tests_ = std::move(policy); 123 backoff_policy_for_tests_ = std::move(policy);
123 } 124 }
124 125
125 void ExtensionThrottleManager::OverrideEntryForTests( 126 void ExtensionThrottleManager::OverrideEntryForTests(
126 const GURL& url, 127 const GURL& url,
127 ExtensionThrottleEntry* entry) { 128 ExtensionThrottleEntry* entry) {
128 // Normalize the url. 129 // Normalize the url.
129 std::string url_id = GetIdFromUrl(url); 130 std::string url_id = GetIdFromUrl(url);
130 131
131 // Periodically garbage collect old entries. 132 // Periodically garbage collect old entries.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 void ExtensionThrottleManager::OnNetworkChange() { 209 void ExtensionThrottleManager::OnNetworkChange() {
209 // Remove all entries. Any entries that in-flight requests have a reference 210 // Remove all entries. Any entries that in-flight requests have a reference
210 // to will live until those requests end, and these entries may be 211 // to will live until those requests end, and these entries may be
211 // inconsistent with new entries for the same URLs, but since what we 212 // inconsistent with new entries for the same URLs, but since what we
212 // want is a clean slate for the new connection type, this is OK. 213 // want is a clean slate for the new connection type, this is OK.
213 url_entries_.clear(); 214 url_entries_.clear();
214 requests_since_last_gc_ = 0; 215 requests_since_last_gc_ = 0;
215 } 216 }
216 217
217 } // namespace extensions 218 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_throttle_manager.h ('k') | extensions/browser/extension_throttle_simulation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698