| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // infinite. | 61 // infinite. |
| 62 // It is only used by unit tests. | 62 // It is only used by unit tests. |
| 63 URLRequestThrottlerEntry(int sliding_window_period_ms, | 63 URLRequestThrottlerEntry(int sliding_window_period_ms, |
| 64 int max_send_threshold, | 64 int max_send_threshold, |
| 65 int initial_backoff_ms, | 65 int initial_backoff_ms, |
| 66 int additional_constant_ms, | 66 int additional_constant_ms, |
| 67 double multiply_factor, | 67 double multiply_factor, |
| 68 double jitter_factor, | 68 double jitter_factor, |
| 69 int maximum_backoff_ms); | 69 int maximum_backoff_ms); |
| 70 | 70 |
| 71 // Used by the manager, returns true if the entry needs to be garbage |
| 72 // collected. |
| 73 bool IsEntryOutdated() const; |
| 74 |
| 71 // Implementation of URLRequestThrottlerEntryInterface. | 75 // Implementation of URLRequestThrottlerEntryInterface. |
| 72 virtual bool IsDuringExponentialBackoff() const; | 76 virtual bool IsDuringExponentialBackoff() const; |
| 73 virtual int64 ReserveSendingTimeForNextRequest( | 77 virtual int64 ReserveSendingTimeForNextRequest( |
| 74 const base::TimeTicks& earliest_time); | 78 const base::TimeTicks& earliest_time); |
| 75 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const; | 79 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const; |
| 76 virtual void UpdateWithResponse( | 80 virtual void UpdateWithResponse( |
| 77 const URLRequestThrottlerHeaderInterface* response); | 81 const URLRequestThrottlerHeaderInterface* response); |
| 78 virtual void ReceivedContentWasMalformed(); | 82 virtual void ReceivedContentWasMalformed(); |
| 79 | 83 |
| 80 // Used by the manager, returns true if the entry needs to be garbage | |
| 81 // collected. | |
| 82 bool IsEntryOutdated() const; | |
| 83 | |
| 84 protected: | 84 protected: |
| 85 virtual ~URLRequestThrottlerEntry(); | 85 virtual ~URLRequestThrottlerEntry(); |
| 86 | 86 |
| 87 void Initialize(); | 87 void Initialize(); |
| 88 | 88 |
| 89 // Calculates the release time for exponential back-off. | 89 // Calculates the release time for exponential back-off. |
| 90 base::TimeTicks CalculateExponentialBackoffReleaseTime(); | 90 base::TimeTicks CalculateExponentialBackoffReleaseTime(); |
| 91 | 91 |
| 92 // Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose. | 92 // Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose. |
| 93 virtual base::TimeTicks GetTimeNow() const; | 93 virtual base::TimeTicks GetTimeNow() const; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 const int maximum_backoff_ms_; | 148 const int maximum_backoff_ms_; |
| 149 // Set to -1 if the entry never expires. | 149 // Set to -1 if the entry never expires. |
| 150 const int entry_lifetime_ms_; | 150 const int entry_lifetime_ms_; |
| 151 | 151 |
| 152 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); | 152 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 } // namespace net | 155 } // namespace net |
| 156 | 156 |
| 157 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ | 157 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ |
| OLD | NEW |