OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BACKOFF_MANAGER_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_BACKOFF_MANAGER_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_BACKOFF_MANAGER_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_BACKOFF_MANAGER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <string> | 11 #include <string> |
10 | 12 |
11 #include "base/basictypes.h" | 13 #include "base/macros.h" |
12 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
13 #include "base/time/time.h" | 15 #include "base/time/time.h" |
14 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
15 #include "net/base/network_change_notifier.h" | 17 #include "net/base/network_change_notifier.h" |
16 #include "url/gurl.h" | 18 #include "url/gurl.h" |
17 | 19 |
18 namespace net { | 20 namespace net { |
19 | 21 |
20 class HttpResponseHeaders; | 22 class HttpResponseHeaders; |
21 | 23 |
(...skipping 11 matching lines...) Expand all Loading... |
33 // | 35 // |
34 // Note that the class does not implement logic to retry a request at random | 36 // Note that the class does not implement logic to retry a request at random |
35 // with uniform distribution. | 37 // with uniform distribution. |
36 // TODO(xunjieli): Expose release time so that the caller can retry accordingly. | 38 // TODO(xunjieli): Expose release time so that the caller can retry accordingly. |
37 class NET_EXPORT URLRequestBackoffManager | 39 class NET_EXPORT URLRequestBackoffManager |
38 : NON_EXPORTED_BASE(public base::NonThreadSafe), | 40 : NON_EXPORTED_BASE(public base::NonThreadSafe), |
39 public NetworkChangeNotifier::IPAddressObserver, | 41 public NetworkChangeNotifier::IPAddressObserver, |
40 public NetworkChangeNotifier::ConnectionTypeObserver { | 42 public NetworkChangeNotifier::ConnectionTypeObserver { |
41 public: | 43 public: |
42 // Minimum number of seconds that a Backoff header can specify. | 44 // Minimum number of seconds that a Backoff header can specify. |
43 static const uint16 kMinimumBackoffInSeconds; | 45 static const uint16_t kMinimumBackoffInSeconds; |
44 // Maximum number of seconds that a Backoff header can specify. | 46 // Maximum number of seconds that a Backoff header can specify. |
45 static const uint16 kMaximumBackoffInSeconds; | 47 static const uint16_t kMaximumBackoffInSeconds; |
46 // Number of throttled requests that will be made between garbage collection. | 48 // Number of throttled requests that will be made between garbage collection. |
47 static const uint16 kNewEntriesBetweenCollecting; | 49 static const uint16_t kNewEntriesBetweenCollecting; |
48 | 50 |
49 URLRequestBackoffManager(); | 51 URLRequestBackoffManager(); |
50 ~URLRequestBackoffManager() override; | 52 ~URLRequestBackoffManager() override; |
51 | 53 |
52 // Updates internal states with a response. | 54 // Updates internal states with a response. |
53 void UpdateWithResponse(const GURL& url, | 55 void UpdateWithResponse(const GURL& url, |
54 HttpResponseHeaders* headers, | 56 HttpResponseHeaders* headers, |
55 const base::Time& response_time); | 57 const base::Time& response_time); |
56 | 58 |
57 // Returns whether the request should be rejected because of a Backoff header. | 59 // Returns whether the request should be rejected because of a Backoff header. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 129 |
128 // Valid after construction. | 130 // Valid after construction. |
129 GURL::Replacements url_id_replacements_; | 131 GURL::Replacements url_id_replacements_; |
130 | 132 |
131 DISALLOW_COPY_AND_ASSIGN(URLRequestBackoffManager); | 133 DISALLOW_COPY_AND_ASSIGN(URLRequestBackoffManager); |
132 }; | 134 }; |
133 | 135 |
134 } // namespace net | 136 } // namespace net |
135 | 137 |
136 #endif // NET_URL_REQUEST_URL_REQUEST_BACKOFF_MANAGER_H_ | 138 #endif // NET_URL_REQUEST_URL_REQUEST_BACKOFF_MANAGER_H_ |
OLD | NEW |