| 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_BASE_BACKOFF_ENTRY_H_ | 5 #ifndef NET_BASE_BACKOFF_ENTRY_H_ |
| 6 #define NET_BASE_BACKOFF_ENTRY_H_ | 6 #define NET_BASE_BACKOFF_ENTRY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // just as well start with a fresh BackoffEntry object), and hasn't | 101 // just as well start with a fresh BackoffEntry object), and hasn't |
| 102 // had for Policy::entry_lifetime_ms. | 102 // had for Policy::entry_lifetime_ms. |
| 103 bool CanDiscard() const; | 103 bool CanDiscard() const; |
| 104 | 104 |
| 105 // Resets this entry to a fresh (as if just constructed) state. | 105 // Resets this entry to a fresh (as if just constructed) state. |
| 106 void Reset(); | 106 void Reset(); |
| 107 | 107 |
| 108 // Returns the failure count for this entry. | 108 // Returns the failure count for this entry. |
| 109 int failure_count() const { return failure_count_; } | 109 int failure_count() const { return failure_count_; } |
| 110 | 110 |
| 111 // Returns the TickClock passed in to the constructor. May be NULL. | 111 // Equivalent to TimeTicks::Now(), using clock_ if provided. |
| 112 base::TickClock* tick_clock() const { return clock_; } | 112 base::TimeTicks GetTimeTicksNow() const; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 // Calculates when requests should again be allowed through. | 115 // Calculates when requests should again be allowed through. |
| 116 base::TimeTicks CalculateReleaseTime() const; | 116 base::TimeTicks CalculateReleaseTime() const; |
| 117 | 117 |
| 118 // Equivalent to TimeTicks::Now(), using clock_ if provided. | |
| 119 base::TimeTicks GetTimeTicksNow() const; | |
| 120 | |
| 121 // Timestamp calculated by the exponential back-off algorithm at which we are | 118 // Timestamp calculated by the exponential back-off algorithm at which we are |
| 122 // allowed to start sending requests again. | 119 // allowed to start sending requests again. |
| 123 base::TimeTicks exponential_backoff_release_time_; | 120 base::TimeTicks exponential_backoff_release_time_; |
| 124 | 121 |
| 125 // Counts request errors; decremented on success. | 122 // Counts request errors; decremented on success. |
| 126 int failure_count_; | 123 int failure_count_; |
| 127 | 124 |
| 128 const Policy* const policy_; // Not owned. | 125 const Policy* const policy_; // Not owned. |
| 129 | 126 |
| 130 base::TickClock* const clock_; // Not owned. | 127 base::TickClock* const clock_; // Not owned. |
| 131 | 128 |
| 132 DISALLOW_COPY_AND_ASSIGN(BackoffEntry); | 129 DISALLOW_COPY_AND_ASSIGN(BackoffEntry); |
| 133 }; | 130 }; |
| 134 | 131 |
| 135 } // namespace net | 132 } // namespace net |
| 136 | 133 |
| 137 #endif // NET_BASE_BACKOFF_ENTRY_H_ | 134 #endif // NET_BASE_BACKOFF_ENTRY_H_ |
| OLD | NEW |