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

Side by Side Diff: content/common/net/url_fetcher.h

Issue 7282032: Move backoff_delay_ to the inner Core class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: set_backoff_delay has been renamed. Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « content/common/net/OWNERS ('k') | content/common/net/url_fetcher.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) 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 // This file contains URLFetcher, a wrapper around net::URLRequest that handles 5 // This file contains URLFetcher, a wrapper around net::URLRequest that handles
6 // low-level details like thread safety, ref counting, and incremental buffer 6 // low-level details like thread safety, ref counting, and incremental buffer
7 // reading. This is useful for callers who simply want to get the data from a 7 // reading. This is useful for callers who simply want to get the data from a
8 // URL and don't care about all the nitty-gritty details. 8 // URL and don't care about all the nitty-gritty details.
9 // 9 //
10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a 10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a
(...skipping 29 matching lines...) Expand all
40 typedef std::vector<std::string> ResponseCookies; 40 typedef std::vector<std::string> ResponseCookies;
41 } // namespace net 41 } // namespace net
42 42
43 // To use this class, create an instance with the desired URL and a pointer to 43 // To use this class, create an instance with the desired URL and a pointer to
44 // the object to be notified when the URL has been loaded: 44 // the object to be notified when the URL has been loaded:
45 // URLFetcher* fetcher = new URLFetcher("http://www.google.com", 45 // URLFetcher* fetcher = new URLFetcher("http://www.google.com",
46 // URLFetcher::GET, this); 46 // URLFetcher::GET, this);
47 // 47 //
48 // Then, optionally set properties on this object, like the request context or 48 // Then, optionally set properties on this object, like the request context or
49 // extra headers: 49 // extra headers:
50 // fetcher->SetExtraRequestHeaders("X-Foo: bar"); 50 // fetcher->set_extra_request_headers("X-Foo: bar");
51 // 51 //
52 // Finally, start the request: 52 // Finally, start the request:
53 // fetcher->Start(); 53 // fetcher->Start();
54 // 54 //
55 // 55 //
56 // The object you supply as a delegate must inherit from URLFetcher::Delegate; 56 // The object you supply as a delegate must inherit from URLFetcher::Delegate;
57 // when the fetch is completed, OnURLFetchComplete() will be called with a 57 // when the fetch is completed, OnURLFetchComplete() will be called with a
58 // pointer to the URLFetcher. From that point until the original URLFetcher 58 // pointer to the URLFetcher. From that point until the original URLFetcher
59 // instance is destroyed, you may use accessor methods to see the result of 59 // instance is destroyed, you may use accessor methods to see the result of
60 // the fetch. You should copy these objects if you need them to live longer 60 // the fetch. You should copy these objects if you need them to live longer
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // if it is true URLFetcher will automatically re-execute the request, 177 // if it is true URLFetcher will automatically re-execute the request,
178 // after backoff_delay() elapses. URLFetcher has it set to true by default. 178 // after backoff_delay() elapses. URLFetcher has it set to true by default.
179 void set_automatically_retry_on_5xx(bool retry); 179 void set_automatically_retry_on_5xx(bool retry);
180 180
181 int max_retries() const; 181 int max_retries() const;
182 182
183 void set_max_retries(int max_retries); 183 void set_max_retries(int max_retries);
184 184
185 // Returns the back-off delay before the request will be retried, 185 // Returns the back-off delay before the request will be retried,
186 // when a 5xx response was received. 186 // when a 5xx response was received.
187 base::TimeDelta backoff_delay() const { return backoff_delay_; } 187 base::TimeDelta backoff_delay() const;
188 188
189 // Sets the back-off delay, allowing to mock 5xx requests in unit-tests. 189 // Sets the back-off delay, allowing to mock 5xx requests in unit-tests.
190 void set_backoff_delay_for_testing(base::TimeDelta backoff_delay) { 190 void set_backoff_delay_for_testing(base::TimeDelta backoff_delay);
191 backoff_delay_ = backoff_delay;
192 }
193 191
194 // By default, the response is saved in a string. Call this method to save the 192 // By default, the response is saved in a string. Call this method to save the
195 // response to a temporary file instead. Must be called before Start(). 193 // response to a temporary file instead. Must be called before Start().
196 // |file_message_loop_proxy| will be used for all file operations. 194 // |file_message_loop_proxy| will be used for all file operations.
197 void SaveResponseToTemporaryFile( 195 void SaveResponseToTemporaryFile(
198 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); 196 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy);
199 197
200 // Retrieve the response headers from the request. Must only be called after 198 // Retrieve the response headers from the request. Must only be called after
201 // the OnURLFetchComplete callback has run. 199 // the OnURLFetchComplete callback has run.
202 virtual net::HttpResponseHeaders* response_headers() const; 200 virtual net::HttpResponseHeaders* response_headers() const;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // NOTE: for safety, this should only be used through ScopedURLFetcherFactory! 306 // NOTE: for safety, this should only be used through ScopedURLFetcherFactory!
309 static void set_factory(Factory* factory) { 307 static void set_factory(Factory* factory) {
310 factory_ = factory; 308 factory_ = factory;
311 } 309 }
312 310
313 class Core; 311 class Core;
314 scoped_refptr<Core> core_; 312 scoped_refptr<Core> core_;
315 313
316 static Factory* factory_; 314 static Factory* factory_;
317 315
318 // Back-off time delay. 0 by default.
319 base::TimeDelta backoff_delay_;
320
321 static bool g_interception_enabled; 316 static bool g_interception_enabled;
322 317
323 DISALLOW_COPY_AND_ASSIGN(URLFetcher); 318 DISALLOW_COPY_AND_ASSIGN(URLFetcher);
324 }; 319 };
325 320
326 #endif // CONTENT_COMMON_NET_URL_FETCHER_H_ 321 #endif // CONTENT_COMMON_NET_URL_FETCHER_H_
OLDNEW
« no previous file with comments | « content/common/net/OWNERS ('k') | content/common/net/url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698