Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "net/base/net_api.h" | 14 #include "net/base/net_api.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 class URLRequestThrottlerHeaderInterface; | 18 class URLRequestThrottlerHeaderInterface; |
| 19 | 19 |
| 20 // Interface provided on entries of the URL request throttler manager. | 20 // Interface provided on entries of the URL request throttler manager. |
| 21 class NET_API URLRequestThrottlerEntryInterface | 21 class NET_API URLRequestThrottlerEntryInterface |
| 22 : public base::RefCountedThreadSafe<URLRequestThrottlerEntryInterface> { | 22 : public base::RefCountedThreadSafe<URLRequestThrottlerEntryInterface> { |
| 23 public: | 23 public: |
| 24 URLRequestThrottlerEntryInterface() {} | 24 URLRequestThrottlerEntryInterface() {} |
| 25 | 25 |
| 26 // Returns true when we have encountered server errors and are doing | 26 // Returns true when we have encountered server errors and are doing |
| 27 // exponential back-off. | 27 // exponential back-off, unless the request has |load_flags| (from |
| 28 // net/base/load_flags.h) that mean it is definitely user-initiated. | |
|
yzshen1
2011/08/05 21:50:41
nit: now that the flag is 'MAYBE', 'definitely' ma
Jói
2011/08/08 17:09:45
Thanks, that part of the comment is now like this:
| |
| 29 // | |
| 28 // URLRequestHttpJob checks this method prior to every request; it | 30 // URLRequestHttpJob checks this method prior to every request; it |
| 29 // cancels requests if this method returns true. | 31 // cancels requests if this method returns true. |
| 30 virtual bool IsDuringExponentialBackoff() const = 0; | 32 virtual bool ShouldRejectRequest(int load_flags) const = 0; |
| 31 | 33 |
| 32 // Calculates a recommended sending time for the next request and reserves it. | 34 // Calculates a recommended sending time for the next request and reserves it. |
| 33 // The sending time is not earlier than the current exponential back-off | 35 // The sending time is not earlier than the current exponential back-off |
| 34 // release time or |earliest_time|. Moreover, the previous results of | 36 // release time or |earliest_time|. Moreover, the previous results of |
| 35 // the method are taken into account, in order to make sure they are spread | 37 // the method are taken into account, in order to make sure they are spread |
| 36 // properly over time. | 38 // properly over time. |
| 37 // Returns the recommended delay before sending the next request, in | 39 // Returns the recommended delay before sending the next request, in |
| 38 // milliseconds. The return value is always positive or 0. | 40 // milliseconds. The return value is always positive or 0. |
| 39 // Although it is not mandatory, respecting the value returned by this method | 41 // Although it is not mandatory, respecting the value returned by this method |
| 40 // is helpful to avoid traffic overload. | 42 // is helpful to avoid traffic overload. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 61 virtual ~URLRequestThrottlerEntryInterface() {} | 63 virtual ~URLRequestThrottlerEntryInterface() {} |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 friend class base::RefCounted<URLRequestThrottlerEntryInterface>; | 66 friend class base::RefCounted<URLRequestThrottlerEntryInterface>; |
| 65 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntryInterface); | 67 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntryInterface); |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 } // namespace net | 70 } // namespace net |
| 69 | 71 |
| 70 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ | 72 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_ |
| OLD | NEW |