| 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 |
| 66 // Whether throttling is enabled or not. | 72 // Whether throttling is enabled or not. |
| 67 void set_enforce_throttling(bool enforce); | 73 void set_enforce_throttling(bool enforce); |
| 68 bool enforce_throttling(); | 74 bool enforce_throttling(); |
| 69 | 75 |
| 70 // Sets the NetLog instance to use. | 76 // Sets the NetLog instance to use. |
| 71 void set_net_log(NetLog* net_log); | 77 void set_net_log(NetLog* net_log); |
| 72 NetLog* net_log() const; | 78 NetLog* net_log() const; |
| 73 | 79 |
| 74 // IPAddressObserver interface. | 80 // IPAddressObserver interface. |
| 75 virtual void OnIPAddressChanged() OVERRIDE; | 81 virtual void OnIPAddressChanged() OVERRIDE; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Set of hosts that have opted out. | 133 // Set of hosts that have opted out. |
| 128 OptOutHosts opt_out_hosts_; | 134 OptOutHosts opt_out_hosts_; |
| 129 | 135 |
| 130 // This keeps track of how many requests have been made. Used with | 136 // This keeps track of how many requests have been made. Used with |
| 131 // GarbageCollectEntries. | 137 // GarbageCollectEntries. |
| 132 unsigned int requests_since_last_gc_; | 138 unsigned int requests_since_last_gc_; |
| 133 | 139 |
| 134 // Valid after construction. | 140 // Valid after construction. |
| 135 GURL::Replacements url_id_replacements_; | 141 GURL::Replacements url_id_replacements_; |
| 136 | 142 |
| 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 |
| 137 // Initially false, switches to true once we have logged because of back-off | 151 // Initially false, switches to true once we have logged because of back-off |
| 138 // being disabled for localhost. | 152 // being disabled for localhost. |
| 139 bool logged_for_localhost_disabled_; | 153 bool logged_for_localhost_disabled_; |
| 140 | 154 |
| 141 // NetLog to use, if configured. | 155 // NetLog to use, if configured. |
| 142 BoundNetLog net_log_; | 156 BoundNetLog net_log_; |
| 143 | 157 |
| 144 // Valid once we've registered for network notifications. | 158 // Valid once we've registered for network notifications. |
| 145 base::PlatformThreadId registered_from_thread_; | 159 base::PlatformThreadId registered_from_thread_; |
| 146 | 160 |
| 147 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); | 161 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); |
| 148 }; | 162 }; |
| 149 | 163 |
| 150 } // namespace net | 164 } // namespace net |
| 151 | 165 |
| 152 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 166 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
| OLD | NEW |