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

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

Issue 1148603003: Remove X-Chrome-Exponential-Throttling header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 years, 7 months 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
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | net/url_request/url_request_throttler_entry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_
6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Fuzzing percentage. ex: 10% will spread requests randomly 51 // Fuzzing percentage. ex: 10% will spread requests randomly
52 // between 90%-100% of the calculated time. 52 // between 90%-100% of the calculated time.
53 static const double kDefaultJitterFactor; 53 static const double kDefaultJitterFactor;
54 54
55 // Maximum amount of time we are willing to delay our request. 55 // Maximum amount of time we are willing to delay our request.
56 static const int kDefaultMaximumBackoffMs; 56 static const int kDefaultMaximumBackoffMs;
57 57
58 // Time after which the entry is considered outdated. 58 // Time after which the entry is considered outdated.
59 static const int kDefaultEntryLifetimeMs; 59 static const int kDefaultEntryLifetimeMs;
60 60
61 // Name of the header that sites can use to opt out of exponential back-off
62 // throttling.
63 static const char kExponentialThrottlingHeader[];
64
65 // Value for exponential throttling header that can be used to opt out of
66 // exponential back-off throttling.
67 static const char kExponentialThrottlingDisableValue[];
68
69 // The manager object's lifetime must enclose the lifetime of this object. 61 // The manager object's lifetime must enclose the lifetime of this object.
70 URLRequestThrottlerEntry(URLRequestThrottlerManager* manager, 62 URLRequestThrottlerEntry(URLRequestThrottlerManager* manager,
71 const std::string& url_id); 63 const std::string& url_id);
72 64
73 // The life span of instances created with this constructor is set to 65 // The life span of instances created with this constructor is set to
74 // infinite, and the number of initial errors to ignore is set to 0. 66 // infinite, and the number of initial errors to ignore is set to 0.
75 // It is only used by unit tests. 67 // It is only used by unit tests.
76 URLRequestThrottlerEntry(URLRequestThrottlerManager* manager, 68 URLRequestThrottlerEntry(URLRequestThrottlerManager* manager,
77 const std::string& url_id, 69 const std::string& url_id,
78 int sliding_window_period_ms, 70 int sliding_window_period_ms,
(...skipping 12 matching lines...) Expand all
91 83
92 // Causes this entry to NULL its manager pointer. 84 // Causes this entry to NULL its manager pointer.
93 void DetachManager(); 85 void DetachManager();
94 86
95 // Implementation of URLRequestThrottlerEntryInterface. 87 // Implementation of URLRequestThrottlerEntryInterface.
96 bool ShouldRejectRequest(const URLRequest& request, 88 bool ShouldRejectRequest(const URLRequest& request,
97 NetworkDelegate* network_delegate) const override; 89 NetworkDelegate* network_delegate) const override;
98 int64 ReserveSendingTimeForNextRequest( 90 int64 ReserveSendingTimeForNextRequest(
99 const base::TimeTicks& earliest_time) override; 91 const base::TimeTicks& earliest_time) override;
100 base::TimeTicks GetExponentialBackoffReleaseTime() const override; 92 base::TimeTicks GetExponentialBackoffReleaseTime() const override;
101 void UpdateWithResponse( 93 void UpdateWithResponse(int status_code) override;
102 const std::string& host,
103 const URLRequestThrottlerHeaderInterface* response) override;
104 void ReceivedContentWasMalformed(int response_code) override; 94 void ReceivedContentWasMalformed(int response_code) override;
105 95
106 protected: 96 protected:
107 ~URLRequestThrottlerEntry() override; 97 ~URLRequestThrottlerEntry() override;
108 98
109 void Initialize(); 99 void Initialize();
110 100
111 // Returns true if the given response code is considered an error for 101 // Returns true if the given response code is considered a success for
112 // throttling purposes. 102 // throttling purposes.
113 bool IsConsideredError(int response_code); 103 bool IsConsideredSuccess(int response_code);
114 104
115 // Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose. 105 // Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose.
116 virtual base::TimeTicks ImplGetTimeNow() const; 106 virtual base::TimeTicks ImplGetTimeNow() const;
117 107
118 // Used internally to handle the opt-out header.
119 void HandleThrottlingHeader(const std::string& header_value,
120 const std::string& host);
121
122 // Retrieves the back-off entry object we're using. Used to enable a 108 // Retrieves the back-off entry object we're using. Used to enable a
123 // unit testing seam for dependency injection in tests. 109 // unit testing seam for dependency injection in tests.
124 virtual const BackoffEntry* GetBackoffEntry() const; 110 virtual const BackoffEntry* GetBackoffEntry() const;
125 virtual BackoffEntry* GetBackoffEntry(); 111 virtual BackoffEntry* GetBackoffEntry();
126 112
127 // Returns true if |load_flags| contains a flag that indicates an 113 // Returns true if |load_flags| contains a flag that indicates an
128 // explicit request by the user to load the resource. We never 114 // explicit request by the user to load the resource. We never
129 // throttle requests with such load flags. 115 // throttle requests with such load flags.
130 static bool ExplicitUserRequest(const int load_flags); 116 static bool ExplicitUserRequest(const int load_flags);
131 117
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 std::string url_id_; 154 std::string url_id_;
169 155
170 BoundNetLog net_log_; 156 BoundNetLog net_log_;
171 157
172 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); 158 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry);
173 }; 159 };
174 160
175 } // namespace net 161 } // namespace net
176 162
177 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_ 163 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_ENTRY_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | net/url_request/url_request_throttler_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698