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_INTERFACE_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
13 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
14 | 16 |
15 namespace net { | 17 namespace net { |
16 | 18 |
17 class NetworkDelegate; | 19 class NetworkDelegate; |
18 class URLRequest; | 20 class URLRequest; |
19 class URLRequestThrottlerHeaderInterface; | 21 class URLRequestThrottlerHeaderInterface; |
20 | 22 |
(...skipping 13 matching lines...) Expand all Loading... |
34 | 36 |
35 // Calculates a recommended sending time for the next request and reserves it. | 37 // Calculates a recommended sending time for the next request and reserves it. |
36 // The sending time is not earlier than the current exponential back-off | 38 // The sending time is not earlier than the current exponential back-off |
37 // release time or |earliest_time|. Moreover, the previous results of | 39 // release time or |earliest_time|. Moreover, the previous results of |
38 // the method are taken into account, in order to make sure they are spread | 40 // the method are taken into account, in order to make sure they are spread |
39 // properly over time. | 41 // properly over time. |
40 // Returns the recommended delay before sending the next request, in | 42 // Returns the recommended delay before sending the next request, in |
41 // milliseconds. The return value is always positive or 0. | 43 // milliseconds. The return value is always positive or 0. |
42 // Although it is not mandatory, respecting the value returned by this method | 44 // Although it is not mandatory, respecting the value returned by this method |
43 // is helpful to avoid traffic overload. | 45 // is helpful to avoid traffic overload. |
44 virtual int64 ReserveSendingTimeForNextRequest( | 46 virtual int64_t ReserveSendingTimeForNextRequest( |
45 const base::TimeTicks& earliest_time) = 0; | 47 const base::TimeTicks& earliest_time) = 0; |
46 | 48 |
47 // Returns the time after which requests are allowed. | 49 // Returns the time after which requests are allowed. |
48 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const = 0; | 50 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const = 0; |
49 | 51 |
50 // This method needs to be called each time a response is received. | 52 // This method needs to be called each time a response is received. |
51 virtual void UpdateWithResponse(int status_code) = 0; | 53 virtual void UpdateWithResponse(int status_code) = 0; |
52 | 54 |
53 // Lets higher-level modules, that know how to parse particular response | 55 // Lets higher-level modules, that know how to parse particular response |
54 // bodies, notify of receiving malformed content for the given URL. This will | 56 // bodies, notify of receiving malformed content for the given URL. This will |
55 // be handled by the throttler as if an HTTP 503 response had been received to | 57 // be handled by the throttler as if an HTTP 503 response had been received to |
56 // the request, i.e. it will count as a failure, unless the HTTP response code | 58 // the request, i.e. it will count as a failure, unless the HTTP response code |
57 // indicated is already one of those that will be counted as an error. | 59 // indicated is already one of those that will be counted as an error. |
58 virtual void ReceivedContentWasMalformed(int response_code) = 0; | 60 virtual void ReceivedContentWasMalformed(int response_code) = 0; |
59 | 61 |
60 protected: | 62 protected: |
61 friend class base::RefCountedThreadSafe<URLRequestThrottlerEntryInterface>; | 63 friend class base::RefCountedThreadSafe<URLRequestThrottlerEntryInterface>; |
62 virtual ~URLRequestThrottlerEntryInterface() {} | 64 virtual ~URLRequestThrottlerEntryInterface() {} |
63 | 65 |
64 private: | 66 private: |
65 friend class base::RefCounted<URLRequestThrottlerEntryInterface>; | 67 friend class base::RefCounted<URLRequestThrottlerEntryInterface>; |
66 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntryInterface); | 68 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntryInterface); |
67 }; | 69 }; |
68 | 70 |
69 } // namespace net | 71 } // namespace net |
70 | 72 |
71 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ | 73 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ |
OLD | NEW |