| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ENTRY_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // collected. | 90 // collected. |
| 91 bool IsEntryOutdated() const; | 91 bool IsEntryOutdated() const; |
| 92 | 92 |
| 93 // Causes this entry to never reject requests due to back-off. | 93 // Causes this entry to never reject requests due to back-off. |
| 94 void DisableBackoffThrottling(); | 94 void DisableBackoffThrottling(); |
| 95 | 95 |
| 96 // Causes this entry to NULL its manager pointer. | 96 // Causes this entry to NULL its manager pointer. |
| 97 void DetachManager(); | 97 void DetachManager(); |
| 98 | 98 |
| 99 // Implementation of URLRequestThrottlerEntryInterface. | 99 // Implementation of URLRequestThrottlerEntryInterface. |
| 100 virtual bool IsDuringExponentialBackoff() const; | 100 virtual bool ShouldRejectRequest(int load_flags) const; |
| 101 virtual int64 ReserveSendingTimeForNextRequest( | 101 virtual int64 ReserveSendingTimeForNextRequest( |
| 102 const base::TimeTicks& earliest_time); | 102 const base::TimeTicks& earliest_time); |
| 103 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const; | 103 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const; |
| 104 virtual void UpdateWithResponse( | 104 virtual void UpdateWithResponse( |
| 105 const std::string& host, | 105 const std::string& host, |
| 106 const URLRequestThrottlerHeaderInterface* response); | 106 const URLRequestThrottlerHeaderInterface* response); |
| 107 virtual void ReceivedContentWasMalformed(int response_code); | 107 virtual void ReceivedContentWasMalformed(int response_code); |
| 108 | 108 |
| 109 protected: | 109 protected: |
| 110 virtual ~URLRequestThrottlerEntry(); | 110 virtual ~URLRequestThrottlerEntry(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 127 | 127 |
| 128 // Used internally to keep track of failure->success transitions and | 128 // Used internally to keep track of failure->success transitions and |
| 129 // generate statistics about them. | 129 // generate statistics about them. |
| 130 void HandleMetricsTracking(int response_code); | 130 void HandleMetricsTracking(int response_code); |
| 131 | 131 |
| 132 // Retrieves the back-off entry object we're using. Used to enable a | 132 // Retrieves the back-off entry object we're using. Used to enable a |
| 133 // unit testing seam for dependency injection in tests. | 133 // unit testing seam for dependency injection in tests. |
| 134 virtual const BackoffEntry* GetBackoffEntry() const; | 134 virtual const BackoffEntry* GetBackoffEntry() const; |
| 135 virtual BackoffEntry* GetBackoffEntry(); | 135 virtual BackoffEntry* GetBackoffEntry(); |
| 136 | 136 |
| 137 // Returns true if |load_flags| contains a flag that indicates an |
| 138 // explicit request by the user to load the resource. We never |
| 139 // throttle requests with such load flags. |
| 140 static bool ExplicitUserRequest(const int load_flags); |
| 141 |
| 137 // Used by tests. | 142 // Used by tests. |
| 138 base::TimeTicks sliding_window_release_time() const { | 143 base::TimeTicks sliding_window_release_time() const { |
| 139 return sliding_window_release_time_; | 144 return sliding_window_release_time_; |
| 140 } | 145 } |
| 141 | 146 |
| 142 // Used by tests. | 147 // Used by tests. |
| 143 void set_sliding_window_release_time(const base::TimeTicks& release_time) { | 148 void set_sliding_window_release_time(const base::TimeTicks& release_time) { |
| 144 sliding_window_release_time_ = release_time; | 149 sliding_window_release_time_ = release_time; |
| 145 } | 150 } |
| 146 | 151 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 std::string url_id_; | 187 std::string url_id_; |
| 183 | 188 |
| 184 BoundNetLog net_log_; | 189 BoundNetLog net_log_; |
| 185 | 190 |
| 186 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); | 191 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); |
| 187 }; | 192 }; |
| 188 | 193 |
| 189 } // namespace net | 194 } // namespace net |
| 190 | 195 |
| 191 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ | 196 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ |
| OLD | NEW |