| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // Fuzzing percentage. ex: 10% will spread requests randomly | 51 // Fuzzing percentage. ex: 10% will spread requests randomly |
| 52 // between 90%-100% of the calculated time. | 52 // between 90%-100% of the calculated time. |
| 53 static const double kDefaultJitterFactor; | 53 static const double kDefaultJitterFactor; |
| 54 | 54 |
| 55 // Maximum amount of time we are willing to delay our request. | 55 // Maximum amount of time we are willing to delay our request. |
| 56 static const int kDefaultMaximumBackoffMs; | 56 static const int kDefaultMaximumBackoffMs; |
| 57 | 57 |
| 58 // Time after which the entry is considered outdated. | 58 // Time after which the entry is considered outdated. |
| 59 static const int kDefaultEntryLifetimeMs; | 59 static const int kDefaultEntryLifetimeMs; |
| 60 | 60 |
| 61 // Name of the header that servers can use to ask clients to delay their | |
| 62 // next request. | |
| 63 static const char kRetryHeaderName[]; | |
| 64 | |
| 65 // Name of the header that sites can use to opt out of exponential back-off | 61 // Name of the header that sites can use to opt out of exponential back-off |
| 66 // throttling. | 62 // throttling. |
| 67 static const char kExponentialThrottlingHeader[]; | 63 static const char kExponentialThrottlingHeader[]; |
| 68 | 64 |
| 69 // Value for exponential throttling header that can be used to opt out of | 65 // Value for exponential throttling header that can be used to opt out of |
| 70 // exponential back-off throttling. | 66 // exponential back-off throttling. |
| 71 static const char kExponentialThrottlingDisableValue[]; | 67 static const char kExponentialThrottlingDisableValue[]; |
| 72 | 68 |
| 73 // The manager object's lifetime must enclose the lifetime of this object. | 69 // The manager object's lifetime must enclose the lifetime of this object. |
| 74 URLRequestThrottlerEntry(URLRequestThrottlerManager* manager, | 70 URLRequestThrottlerEntry(URLRequestThrottlerManager* manager, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 107 |
| 112 void Initialize(); | 108 void Initialize(); |
| 113 | 109 |
| 114 // Returns true if the given response code is considered an error for | 110 // Returns true if the given response code is considered an error for |
| 115 // throttling purposes. | 111 // throttling purposes. |
| 116 bool IsConsideredError(int response_code); | 112 bool IsConsideredError(int response_code); |
| 117 | 113 |
| 118 // Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose. | 114 // Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose. |
| 119 virtual base::TimeTicks ImplGetTimeNow() const; | 115 virtual base::TimeTicks ImplGetTimeNow() const; |
| 120 | 116 |
| 121 // Used internally to increase release time following a retry-after header. | |
| 122 void HandleCustomRetryAfter(const std::string& header_value); | |
| 123 | |
| 124 // Used internally to handle the opt-out header. | 117 // Used internally to handle the opt-out header. |
| 125 void HandleThrottlingHeader(const std::string& header_value, | 118 void HandleThrottlingHeader(const std::string& header_value, |
| 126 const std::string& host); | 119 const std::string& host); |
| 127 | 120 |
| 128 // Used internally to keep track of failure->success transitions and | 121 // Used internally to keep track of failure->success transitions and |
| 129 // generate statistics about them. | 122 // generate statistics about them. |
| 130 void HandleMetricsTracking(int response_code); | 123 void HandleMetricsTracking(int response_code); |
| 131 | 124 |
| 132 // Retrieves the back-off entry object we're using. Used to enable a | 125 // Retrieves the back-off entry object we're using. Used to enable a |
| 133 // unit testing seam for dependency injection in tests. | 126 // unit testing seam for dependency injection in tests. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 std::string url_id_; | 180 std::string url_id_; |
| 188 | 181 |
| 189 BoundNetLog net_log_; | 182 BoundNetLog net_log_; |
| 190 | 183 |
| 191 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); | 184 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); |
| 192 }; | 185 }; |
| 193 | 186 |
| 194 } // namespace net | 187 } // namespace net |
| 195 | 188 |
| 196 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ | 189 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ |
| OLD | NEW |