| 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 "net/url_request/url_request_throttler_manager.h" | 5 #include "net/url_request/url_request_throttler_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
| 10 #include "net/log/net_log.h" | 10 #include "net/log/net_log.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void URLRequestThrottlerManager::OnConnectionTypeChanged( | 135 void URLRequestThrottlerManager::OnConnectionTypeChanged( |
| 136 NetworkChangeNotifier::ConnectionType type) { | 136 NetworkChangeNotifier::ConnectionType type) { |
| 137 OnNetworkChange(); | 137 OnNetworkChange(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 std::string URLRequestThrottlerManager::GetIdFromUrl(const GURL& url) const { | 140 std::string URLRequestThrottlerManager::GetIdFromUrl(const GURL& url) const { |
| 141 if (!url.is_valid()) | 141 if (!url.is_valid()) |
| 142 return url.possibly_invalid_spec(); | 142 return url.possibly_invalid_spec(); |
| 143 | 143 |
| 144 GURL id = url.ReplaceComponents(url_id_replacements_); | 144 GURL id = url.ReplaceComponents(url_id_replacements_); |
| 145 return base::StringToLowerASCII(id.spec()).c_str(); | 145 return base::ToLowerASCII(id.spec()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void URLRequestThrottlerManager::GarbageCollectEntriesIfNecessary() { | 148 void URLRequestThrottlerManager::GarbageCollectEntriesIfNecessary() { |
| 149 requests_since_last_gc_++; | 149 requests_since_last_gc_++; |
| 150 if (requests_since_last_gc_ < kRequestsBetweenCollecting) | 150 if (requests_since_last_gc_ < kRequestsBetweenCollecting) |
| 151 return; | 151 return; |
| 152 requests_since_last_gc_ = 0; | 152 requests_since_last_gc_ = 0; |
| 153 | 153 |
| 154 GarbageCollectEntries(); | 154 GarbageCollectEntries(); |
| 155 } | 155 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 173 void URLRequestThrottlerManager::OnNetworkChange() { | 173 void URLRequestThrottlerManager::OnNetworkChange() { |
| 174 // Remove all entries. Any entries that in-flight requests have a reference | 174 // Remove all entries. Any entries that in-flight requests have a reference |
| 175 // to will live until those requests end, and these entries may be | 175 // to will live until those requests end, and these entries may be |
| 176 // inconsistent with new entries for the same URLs, but since what we | 176 // inconsistent with new entries for the same URLs, but since what we |
| 177 // want is a clean slate for the new connection type, this is OK. | 177 // want is a clean slate for the new connection type, this is OK. |
| 178 url_entries_.clear(); | 178 url_entries_.clear(); |
| 179 requests_since_last_gc_ = 0; | 179 requests_since_last_gc_ = 0; |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace net | 182 } // namespace net |
| OLD | NEW |