| 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 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // any) for the URL. The service will hold a reference to the entry. | 56 // any) for the URL. The service will hold a reference to the entry. |
| 57 // It is only used by unit tests. | 57 // It is only used by unit tests. |
| 58 void OverrideEntryForTests(const GURL& url, URLRequestThrottlerEntry* entry); | 58 void OverrideEntryForTests(const GURL& url, URLRequestThrottlerEntry* entry); |
| 59 | 59 |
| 60 // Explicitly erases an entry. | 60 // Explicitly erases an entry. |
| 61 // This is useful to remove those entries which have got infinite lifetime and | 61 // This is useful to remove those entries which have got infinite lifetime and |
| 62 // thus won't be garbage collected. | 62 // thus won't be garbage collected. |
| 63 // It is only used by unit tests. | 63 // It is only used by unit tests. |
| 64 void EraseEntryForTests(const GURL& url); | 64 void EraseEntryForTests(const GURL& url); |
| 65 | 65 |
| 66 // Turns threading model verification on or off. Any code that correctly | |
| 67 // uses the network stack should preferably call this function to enable | |
| 68 // verification of correct adherence to the network stack threading model. | |
| 69 void set_enable_thread_checks(bool enable); | |
| 70 bool enable_thread_checks() const; | |
| 71 | |
| 72 // Whether throttling is enabled or not. | 66 // Whether throttling is enabled or not. |
| 73 void set_enforce_throttling(bool enforce); | 67 void set_enforce_throttling(bool enforce); |
| 74 bool enforce_throttling(); | 68 bool enforce_throttling(); |
| 75 | 69 |
| 76 // Sets the NetLog instance to use. | 70 // Sets the NetLog instance to use. |
| 77 void set_net_log(NetLog* net_log); | 71 void set_net_log(NetLog* net_log); |
| 78 NetLog* net_log() const; | 72 NetLog* net_log() const; |
| 79 | 73 |
| 80 // IPAddressObserver interface. | 74 // IPAddressObserver interface. |
| 81 virtual void OnIPAddressChanged() OVERRIDE; | 75 virtual void OnIPAddressChanged() OVERRIDE; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Set of hosts that have opted out. | 127 // Set of hosts that have opted out. |
| 134 OptOutHosts opt_out_hosts_; | 128 OptOutHosts opt_out_hosts_; |
| 135 | 129 |
| 136 // This keeps track of how many requests have been made. Used with | 130 // This keeps track of how many requests have been made. Used with |
| 137 // GarbageCollectEntries. | 131 // GarbageCollectEntries. |
| 138 unsigned int requests_since_last_gc_; | 132 unsigned int requests_since_last_gc_; |
| 139 | 133 |
| 140 // Valid after construction. | 134 // Valid after construction. |
| 141 GURL::Replacements url_id_replacements_; | 135 GURL::Replacements url_id_replacements_; |
| 142 | 136 |
| 143 // Certain tests do not obey the net component's threading policy, so we | |
| 144 // keep track of whether we're being used by tests, and turn off certain | |
| 145 // checks. | |
| 146 // | |
| 147 // TODO(joi): See if we can fix the offending unit tests and remove this | |
| 148 // workaround. | |
| 149 bool enable_thread_checks_; | |
| 150 | |
| 151 // Initially false, switches to true once we have logged because of back-off | 137 // Initially false, switches to true once we have logged because of back-off |
| 152 // being disabled for localhost. | 138 // being disabled for localhost. |
| 153 bool logged_for_localhost_disabled_; | 139 bool logged_for_localhost_disabled_; |
| 154 | 140 |
| 155 // NetLog to use, if configured. | 141 // NetLog to use, if configured. |
| 156 BoundNetLog net_log_; | 142 BoundNetLog net_log_; |
| 157 | 143 |
| 158 // Valid once we've registered for network notifications. | 144 // Valid once we've registered for network notifications. |
| 159 base::PlatformThreadId registered_from_thread_; | 145 base::PlatformThreadId registered_from_thread_; |
| 160 | 146 |
| 161 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); | 147 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); |
| 162 }; | 148 }; |
| 163 | 149 |
| 164 } // namespace net | 150 } // namespace net |
| 165 | 151 |
| 166 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 152 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
| OLD | NEW |