| 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <queue> | 12 #include <queue> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/lock.h" | 15 #include "base/lock.h" |
| 16 #include "base/logging.h" | |
| 17 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 18 #include "base/time.h" | 17 #include "base/time.h" |
| 19 | 18 |
| 20 | 19 |
| 21 // This class is used to manage one service's rate protection. It maintains | 20 // This class is used to manage one service's rate protection. It maintains |
| 22 // a queue of connection successes and failures and analyzes the requests | 21 // a queue of connection successes and failures and analyzes the requests |
| 23 // over some period of time, in order to deduce the backoff time of every | 22 // over some period of time, in order to deduce the backoff time of every |
| 24 // request. | 23 // request. |
| 25 // The backoff algorithm consists of two parts. Firstly, avoid too many | 24 // The backoff algorithm consists of two parts. Firstly, avoid too many |
| 26 // send events in a sliding window. That will prevent traffic overload. | 25 // send events in a sliding window. That will prevent traffic overload. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 typedef std::map<const std::string, URLFetcherProtectEntry*> ProtectService; | 135 typedef std::map<const std::string, URLFetcherProtectEntry*> ProtectService; |
| 137 | 136 |
| 138 static Lock lock_; | 137 static Lock lock_; |
| 139 static scoped_ptr<URLFetcherProtectManager> protect_manager_; | 138 static scoped_ptr<URLFetcherProtectManager> protect_manager_; |
| 140 ProtectService services_; | 139 ProtectService services_; |
| 141 | 140 |
| 142 DISALLOW_COPY_AND_ASSIGN(URLFetcherProtectManager); | 141 DISALLOW_COPY_AND_ASSIGN(URLFetcherProtectManager); |
| 143 }; | 142 }; |
| 144 | 143 |
| 145 #endif // CHROME_BROWSER_URL_FETCHER_PROTECT_H__ | 144 #endif // CHROME_BROWSER_URL_FETCHER_PROTECT_H__ |
| OLD | NEW |