| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_URL_REQUEST_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ |
| 6 #define NET_URL_REQUEST_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/ref_counted.h" |
| 10 #include "base/time.h" |
| 11 |
| 12 class RequestThrottlerHeaderInterface; |
| 13 |
| 14 // Interface provided on entries of the request throttler manager. |
| 15 class RequestThrottlerEntryInterface |
| 16 : public base::RefCounted<RequestThrottlerEntryInterface> { |
| 17 public: |
| 18 RequestThrottlerEntryInterface() {} |
| 19 |
| 20 // Returns true when we have encountered server errors and are doing |
| 21 // exponential back-off. |
| 22 // URLRequestHttpJob checks this method prior to every request; it cancels |
| 23 // requests if this method returns true. |
| 24 virtual bool IsDuringExponentialBackoff() const = 0; |
| 25 |
| 26 // Calculates a recommended sending time for the next request and reserves it. |
| 27 // The sending time is not earlier than the current exponential back-off |
| 28 // release time or |earliest_time|. Moreover, the previous results of |
| 29 // the method are taken into account, in order to make sure they are spread |
| 30 // properly over time. |
| 31 // Returns the recommended delay before sending the next request, in |
| 32 // milliseconds. The return value is always positive or 0. |
| 33 // Although it is not mandatory, respecting the value returned by this method |
| 34 // is helpful to avoid traffic overload. |
| 35 virtual int64 ReserveSendingTimeForNextRequest( |
| 36 const base::TimeTicks& earliest_time) = 0; |
| 37 |
| 38 // Returns the time after which requests are allowed. |
| 39 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const = 0; |
| 40 |
| 41 // This method needs to be called each time a response is received. |
| 42 virtual void UpdateWithResponse( |
| 43 const RequestThrottlerHeaderInterface* response) = 0; |
| 44 |
| 45 // Lets higher-level modules, that know how to parse particular response |
| 46 // bodies, notify of receiving malformed content for the given URL. This will |
| 47 // be handled by the throttler as if an HTTP 5xx response had been received to |
| 48 // the request, i.e. it will count as a failure. |
| 49 virtual void ReceivedContentWasMalformed() = 0; |
| 50 |
| 51 protected: |
| 52 virtual ~RequestThrottlerEntryInterface() {} |
| 53 |
| 54 private: |
| 55 friend class base::RefCounted<RequestThrottlerEntryInterface>; |
| 56 DISALLOW_COPY_AND_ASSIGN(RequestThrottlerEntryInterface); |
| 57 }; |
| 58 |
| 59 #endif // NET_URL_REQUEST_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ |
| OLD | NEW |