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_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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "net/base/backoff_entry.h" | 13 #include "net/base/backoff_entry.h" |
14 #include "net/base/net_log.h" | 14 #include "net/base/net_log.h" |
15 #include "net/url_request/url_request_throttler_entry_interface.h" | 15 #include "net/url_request/url_request_throttler_entry_interface.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
| 19 class NetworkDelegate; |
19 class URLRequestThrottlerManager; | 20 class URLRequestThrottlerManager; |
20 | 21 |
21 // URLRequestThrottlerEntry represents an entry of URLRequestThrottlerManager. | 22 // URLRequestThrottlerEntry represents an entry of URLRequestThrottlerManager. |
22 // It analyzes requests of a specific URL over some period of time, in order to | 23 // It analyzes requests of a specific URL over some period of time, in order to |
23 // deduce the back-off time for every request. | 24 // deduce the back-off time for every request. |
24 // The back-off algorithm consists of two parts. Firstly, exponential back-off | 25 // The back-off algorithm consists of two parts. Firstly, exponential back-off |
25 // is used when receiving 5XX server errors or malformed response bodies. | 26 // is used when receiving 5XX server errors or malformed response bodies. |
26 // The exponential back-off rule is enforced by URLRequestHttpJob. Any | 27 // The exponential back-off rule is enforced by URLRequestHttpJob. Any |
27 // request sent during the back-off period will be cancelled. | 28 // request sent during the back-off period will be cancelled. |
28 // Secondly, a sliding window is used to count recent requests to a given | 29 // Secondly, a sliding window is used to count recent requests to a given |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // collected. | 86 // collected. |
86 bool IsEntryOutdated() const; | 87 bool IsEntryOutdated() const; |
87 | 88 |
88 // Causes this entry to never reject requests due to back-off. | 89 // Causes this entry to never reject requests due to back-off. |
89 void DisableBackoffThrottling(); | 90 void DisableBackoffThrottling(); |
90 | 91 |
91 // Causes this entry to NULL its manager pointer. | 92 // Causes this entry to NULL its manager pointer. |
92 void DetachManager(); | 93 void DetachManager(); |
93 | 94 |
94 // Implementation of URLRequestThrottlerEntryInterface. | 95 // Implementation of URLRequestThrottlerEntryInterface. |
95 virtual bool ShouldRejectRequest(const URLRequest& request) const OVERRIDE; | 96 virtual bool ShouldRejectRequest( |
| 97 const URLRequest& request, |
| 98 NetworkDelegate* network_delegate) const OVERRIDE; |
96 virtual int64 ReserveSendingTimeForNextRequest( | 99 virtual int64 ReserveSendingTimeForNextRequest( |
97 const base::TimeTicks& earliest_time) OVERRIDE; | 100 const base::TimeTicks& earliest_time) OVERRIDE; |
98 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const OVERRIDE; | 101 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const OVERRIDE; |
99 virtual void UpdateWithResponse( | 102 virtual void UpdateWithResponse( |
100 const std::string& host, | 103 const std::string& host, |
101 const URLRequestThrottlerHeaderInterface* response) OVERRIDE; | 104 const URLRequestThrottlerHeaderInterface* response) OVERRIDE; |
102 virtual void ReceivedContentWasMalformed(int response_code) OVERRIDE; | 105 virtual void ReceivedContentWasMalformed(int response_code) OVERRIDE; |
103 | 106 |
104 protected: | 107 protected: |
105 virtual ~URLRequestThrottlerEntry(); | 108 virtual ~URLRequestThrottlerEntry(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 std::string url_id_; | 169 std::string url_id_; |
167 | 170 |
168 BoundNetLog net_log_; | 171 BoundNetLog net_log_; |
169 | 172 |
170 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); | 173 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); |
171 }; | 174 }; |
172 | 175 |
173 } // namespace net | 176 } // namespace net |
174 | 177 |
175 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ | 178 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ |
OLD | NEW |