| 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 "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/memory/ptr_util.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Delete all entries. | 54 // Delete all entries. |
| 55 url_entries_.clear(); | 55 url_entries_.clear(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 std::unique_ptr<content::ResourceThrottle> | 58 std::unique_ptr<content::ResourceThrottle> |
| 59 ExtensionThrottleManager::MaybeCreateThrottle(const net::URLRequest* request) { | 59 ExtensionThrottleManager::MaybeCreateThrottle(const net::URLRequest* request) { |
| 60 if (request->first_party_for_cookies().scheme() != | 60 if (request->first_party_for_cookies().scheme() != |
| 61 extensions::kExtensionScheme) { | 61 extensions::kExtensionScheme) { |
| 62 return nullptr; | 62 return nullptr; |
| 63 } | 63 } |
| 64 return base::WrapUnique( | 64 return base::MakeUnique<extensions::ExtensionRequestLimitingThrottle>(request, |
| 65 new extensions::ExtensionRequestLimitingThrottle(request, this)); | 65 this); |
| 66 } | 66 } |
| 67 | 67 |
| 68 scoped_refptr<ExtensionThrottleEntryInterface> | 68 scoped_refptr<ExtensionThrottleEntryInterface> |
| 69 ExtensionThrottleManager::RegisterRequestUrl(const GURL& url) { | 69 ExtensionThrottleManager::RegisterRequestUrl(const GURL& url) { |
| 70 DCHECK(!enable_thread_checks_ || CalledOnValidThread()); | 70 DCHECK(!enable_thread_checks_ || CalledOnValidThread()); |
| 71 | 71 |
| 72 // Normalize the url. | 72 // Normalize the url. |
| 73 std::string url_id = GetIdFromUrl(url); | 73 std::string url_id = GetIdFromUrl(url); |
| 74 | 74 |
| 75 // Periodically garbage collect old entries. | 75 // Periodically garbage collect old entries. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 void ExtensionThrottleManager::OnNetworkChange() { | 209 void ExtensionThrottleManager::OnNetworkChange() { |
| 210 // 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 |
| 211 // 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 |
| 212 // 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 |
| 213 // 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. |
| 214 url_entries_.clear(); | 214 url_entries_.clear(); |
| 215 requests_since_last_gc_ = 0; | 215 requests_since_last_gc_ = 0; |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace extensions | 218 } // namespace extensions |
| OLD | NEW |