OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_BROWSER_URL_FETCHER_PROTECT_H__ | 8 #ifndef CHROME_BROWSER_URL_FETCHER_PROTECT_H__ |
9 #define CHROME_BROWSER_URL_FETCHER_PROTECT_H__ | 9 #define CHROME_BROWSER_URL_FETCHER_PROTECT_H__ |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 double multiplier, int constant_factor, | 46 double multiplier, int constant_factor, |
47 int maximum_timeout); | 47 int maximum_timeout); |
48 | 48 |
49 | 49 |
50 virtual ~URLFetcherProtectEntry() { } | 50 virtual ~URLFetcherProtectEntry() { } |
51 | 51 |
52 // When a connection event happens, log it to the queue, and recalculate | 52 // When a connection event happens, log it to the queue, and recalculate |
53 // the timeout period. It returns the backoff time, in milliseconds, that | 53 // the timeout period. It returns the backoff time, in milliseconds, that |
54 // indicates to the sender how long should it wait before sending the request. | 54 // indicates to the sender how long should it wait before sending the request. |
55 // If the request is allowed to be sent immediately, the backoff time is 0. | 55 // If the request is allowed to be sent immediately, the backoff time is 0. |
56 int UpdateBackoff(EventType event_type); | 56 int64 UpdateBackoff(EventType event_type); |
57 | 57 |
58 // Returns the max retries allowed. | 58 // Returns the max retries allowed. |
59 int max_retries() const { | 59 int max_retries() const { |
60 return max_retries_; | 60 return max_retries_; |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 // When a request comes, calculate the release time for it. | 64 // When a request comes, calculate the release time for it. |
65 // Returns the backoff time before sending. | 65 // Returns the backoff time before sending. |
66 base::TimeDelta AntiOverload(); | 66 base::TimeDelta AntiOverload(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 typedef std::map<const std::string, URLFetcherProtectEntry*> ProtectService; | 135 typedef std::map<const std::string, URLFetcherProtectEntry*> ProtectService; |
136 | 136 |
137 static Lock lock_; | 137 static Lock lock_; |
138 static scoped_ptr<URLFetcherProtectManager> protect_manager_; | 138 static scoped_ptr<URLFetcherProtectManager> protect_manager_; |
139 ProtectService services_; | 139 ProtectService services_; |
140 | 140 |
141 DISALLOW_COPY_AND_ASSIGN(URLFetcherProtectManager); | 141 DISALLOW_COPY_AND_ASSIGN(URLFetcherProtectManager); |
142 }; | 142 }; |
143 | 143 |
144 #endif // CHROME_BROWSER_URL_FETCHER_PROTECT_H__ | 144 #endif // CHROME_BROWSER_URL_FETCHER_PROTECT_H__ |
OLD | NEW |