| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 void ExtensionThrottleManager::OnConnectionTypeChanged( | 168 void ExtensionThrottleManager::OnConnectionTypeChanged( |
| 169 net::NetworkChangeNotifier::ConnectionType type) { | 169 net::NetworkChangeNotifier::ConnectionType type) { |
| 170 OnNetworkChange(); | 170 OnNetworkChange(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 std::string ExtensionThrottleManager::GetIdFromUrl(const GURL& url) const { | 173 std::string ExtensionThrottleManager::GetIdFromUrl(const GURL& url) const { |
| 174 if (!url.is_valid()) | 174 if (!url.is_valid()) |
| 175 return url.possibly_invalid_spec(); | 175 return url.possibly_invalid_spec(); |
| 176 | 176 |
| 177 GURL id = url.ReplaceComponents(url_id_replacements_); | 177 GURL id = url.ReplaceComponents(url_id_replacements_); |
| 178 return base::StringToLowerASCII(id.spec()).c_str(); | 178 return base::ToLowerASCII(id.spec()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void ExtensionThrottleManager::GarbageCollectEntriesIfNecessary() { | 181 void ExtensionThrottleManager::GarbageCollectEntriesIfNecessary() { |
| 182 requests_since_last_gc_++; | 182 requests_since_last_gc_++; |
| 183 if (requests_since_last_gc_ < kRequestsBetweenCollecting) | 183 if (requests_since_last_gc_ < kRequestsBetweenCollecting) |
| 184 return; | 184 return; |
| 185 requests_since_last_gc_ = 0; | 185 requests_since_last_gc_ = 0; |
| 186 | 186 |
| 187 GarbageCollectEntries(); | 187 GarbageCollectEntries(); |
| 188 } | 188 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 206 void ExtensionThrottleManager::OnNetworkChange() { | 206 void ExtensionThrottleManager::OnNetworkChange() { |
| 207 // Remove all entries. Any entries that in-flight requests have a reference | 207 // Remove all entries. Any entries that in-flight requests have a reference |
| 208 // to will live until those requests end, and these entries may be | 208 // to will live until those requests end, and these entries may be |
| 209 // inconsistent with new entries for the same URLs, but since what we | 209 // inconsistent with new entries for the same URLs, but since what we |
| 210 // want is a clean slate for the new connection type, this is OK. | 210 // want is a clean slate for the new connection type, this is OK. |
| 211 url_entries_.clear(); | 211 url_entries_.clear(); |
| 212 requests_since_last_gc_ = 0; | 212 requests_since_last_gc_ = 0; |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace extensions | 215 } // namespace extensions |
| OLD | NEW |