| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 // This file implements backoff in the suggest system so that we don't | 5 // This file implements backoff in the suggest system so that we don't |
| 6 // DOS the Suggest servers when using URLFetcher. | 6 // DOS the Suggest servers when using URLFetcher. |
| 7 | 7 |
| 8 #ifndef CHROME_COMMON_NET_URL_FETCHER_PROTECT_H_ | 8 #ifndef CHROME_COMMON_NET_URL_FETCHER_PROTECT_H_ |
| 9 #define CHROME_COMMON_NET_URL_FETCHER_PROTECT_H_ | 9 #define CHROME_COMMON_NET_URL_FETCHER_PROTECT_H_ |
| 10 #pragma once | 10 #pragma once |
| 11 | 11 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // the timeout period. It returns the backoff time, in milliseconds, that | 54 // the timeout period. It returns the backoff time, in milliseconds, that |
| 55 // indicates to the sender how long should it wait before sending the request. | 55 // indicates to the sender how long should it wait before sending the request. |
| 56 // If the request is allowed to be sent immediately, the backoff time is 0. | 56 // If the request is allowed to be sent immediately, the backoff time is 0. |
| 57 int64 UpdateBackoff(EventType event_type); | 57 int64 UpdateBackoff(EventType event_type); |
| 58 | 58 |
| 59 // Returns the max retries allowed. | 59 // Returns the max retries allowed. |
| 60 int max_retries() const { | 60 int max_retries() const { |
| 61 return max_retries_; | 61 return max_retries_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Sets the max retries. |
| 65 void SetMaxRetries(int max_retries) { |
| 66 max_retries_ = max_retries; |
| 67 } |
| 68 |
| 64 private: | 69 private: |
| 65 // When a request comes, calculate the release time for it. | 70 // When a request comes, calculate the release time for it. |
| 66 // Returns the backoff time before sending. | 71 // Returns the backoff time before sending. |
| 67 base::TimeDelta AntiOverload(); | 72 base::TimeDelta AntiOverload(); |
| 68 // Resets backoff when service is ok. | 73 // Resets backoff when service is ok. |
| 69 // Returns the backoff time before sending. | 74 // Returns the backoff time before sending. |
| 70 base::TimeDelta ResetBackoff(); | 75 base::TimeDelta ResetBackoff(); |
| 71 // Calculates new backoff when encountering a failure. | 76 // Calculates new backoff when encountering a failure. |
| 72 // Returns the backoff time before sending. | 77 // Returns the backoff time before sending. |
| 73 base::TimeDelta IncreaseBackoff(); | 78 base::TimeDelta IncreaseBackoff(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 typedef std::map<const std::string, URLFetcherProtectEntry*> ProtectService; | 143 typedef std::map<const std::string, URLFetcherProtectEntry*> ProtectService; |
| 139 | 144 |
| 140 static Lock lock_; | 145 static Lock lock_; |
| 141 static scoped_ptr<URLFetcherProtectManager> protect_manager_; | 146 static scoped_ptr<URLFetcherProtectManager> protect_manager_; |
| 142 ProtectService services_; | 147 ProtectService services_; |
| 143 | 148 |
| 144 DISALLOW_COPY_AND_ASSIGN(URLFetcherProtectManager); | 149 DISALLOW_COPY_AND_ASSIGN(URLFetcherProtectManager); |
| 145 }; | 150 }; |
| 146 | 151 |
| 147 #endif // CHROME_COMMON_NET_URL_FETCHER_PROTECT_H_ | 152 #endif // CHROME_COMMON_NET_URL_FETCHER_PROTECT_H_ |
| OLD | NEW |