Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: net/url_request/url_request_throttler_entry_interface.h

Issue 5276007: Implement exponential back-off mechanism. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pull latest to merge Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_
6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_
7
8 #include "base/basictypes.h"
9 #include "base/ref_counted.h"
10 #include "base/time.h"
11
12 namespace net {
13
14 class URLRequestThrottlerHeaderInterface;
15
16 // Interface provided on entries of the URL request throttler manager.
17 class URLRequestThrottlerEntryInterface
18 : public base::RefCounted<URLRequestThrottlerEntryInterface> {
19 public:
20 URLRequestThrottlerEntryInterface() {}
21
22 // Returns true when we have encountered server errors and are doing
23 // exponential back-off.
24 // URLRequestHttpJob checks this method prior to every request; it cancels
25 // requests if this method returns true.
26 virtual bool IsDuringExponentialBackoff() const = 0;
27
28 // Calculates a recommended sending time for the next request and reserves it.
29 // The sending time is not earlier than the current exponential back-off
30 // release time or |earliest_time|. Moreover, the previous results of
31 // the method are taken into account, in order to make sure they are spread
32 // properly over time.
33 // Returns the recommended delay before sending the next request, in
34 // milliseconds. The return value is always positive or 0.
35 // Although it is not mandatory, respecting the value returned by this method
36 // is helpful to avoid traffic overload.
37 virtual int64 ReserveSendingTimeForNextRequest(
38 const base::TimeTicks& earliest_time) = 0;
39
40 // Returns the time after which requests are allowed.
41 virtual base::TimeTicks GetExponentialBackoffReleaseTime() const = 0;
42
43 // This method needs to be called each time a response is received.
44 virtual void UpdateWithResponse(
45 const URLRequestThrottlerHeaderInterface* response) = 0;
46
47 // Lets higher-level modules, that know how to parse particular response
48 // bodies, notify of receiving malformed content for the given URL. This will
49 // be handled by the throttler as if an HTTP 5xx response had been received to
50 // the request, i.e. it will count as a failure.
51 virtual void ReceivedContentWasMalformed() = 0;
52
53 protected:
54 virtual ~URLRequestThrottlerEntryInterface() {}
55
56 private:
57 friend class base::RefCounted<URLRequestThrottlerEntryInterface>;
58 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntryInterface);
59 };
60
61 } // namespace net
62
63 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_INTERFACE_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_throttler_entry.cc ('k') | net/url_request/url_request_throttler_header_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698