| 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/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/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 | 143 |
| 144 void URLRequestThrottlerManager::OnIPAddressChanged() { | 144 void URLRequestThrottlerManager::OnIPAddressChanged() { |
| 145 OnNetworkChange(); | 145 OnNetworkChange(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void URLRequestThrottlerManager::OnOnlineStateChanged(bool online) { | 148 void URLRequestThrottlerManager::OnOnlineStateChanged(bool online) { |
| 149 OnNetworkChange(); | 149 OnNetworkChange(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // TODO(joi): Turn throttling on by default when appropriate. | |
| 153 URLRequestThrottlerManager::URLRequestThrottlerManager() | 152 URLRequestThrottlerManager::URLRequestThrottlerManager() |
| 154 : requests_since_last_gc_(0), | 153 : requests_since_last_gc_(0), |
| 155 enforce_throttling_(false), | 154 enforce_throttling_(true), |
| 156 enable_thread_checks_(false), | 155 enable_thread_checks_(false), |
| 157 logged_for_localhost_disabled_(false), | 156 logged_for_localhost_disabled_(false), |
| 158 registered_from_thread_(base::kInvalidThreadId) { | 157 registered_from_thread_(base::kInvalidThreadId) { |
| 159 // Construction/destruction is on main thread (because BrowserMain | 158 // Construction/destruction is on main thread (because BrowserMain |
| 160 // retrieves an instance to call InitializeOptions), but is from then on | 159 // retrieves an instance to call InitializeOptions), but is from then on |
| 161 // used on I/O thread. | 160 // used on I/O thread. |
| 162 DetachFromThread(); | 161 DetachFromThread(); |
| 163 | 162 |
| 164 url_id_replacements_.ClearPassword(); | 163 url_id_replacements_.ClearPassword(); |
| 165 url_id_replacements_.ClearUsername(); | 164 url_id_replacements_.ClearUsername(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 void URLRequestThrottlerManager::OnNetworkChange() { | 232 void URLRequestThrottlerManager::OnNetworkChange() { |
| 234 // Remove all entries. Any entries that in-flight requests have a reference | 233 // Remove all entries. Any entries that in-flight requests have a reference |
| 235 // to will live until those requests end, and these entries may be | 234 // to will live until those requests end, and these entries may be |
| 236 // inconsistent with new entries for the same URLs, but since what we | 235 // inconsistent with new entries for the same URLs, but since what we |
| 237 // want is a clean slate for the new connection state, this is OK. | 236 // want is a clean slate for the new connection state, this is OK. |
| 238 url_entries_.clear(); | 237 url_entries_.clear(); |
| 239 requests_since_last_gc_ = 0; | 238 requests_since_last_gc_ = 0; |
| 240 } | 239 } |
| 241 | 240 |
| 242 } // namespace net | 241 } // namespace net |
| OLD | NEW |