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

Side by Side Diff: content/common/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: Created 9 years, 5 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 | « no previous file | content/common/url_fetcher.cc » ('j') | content/common/url_fetcher.cc » ('J')
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 28 matching lines...) Expand all
39 typedef std::vector<std::string> ResponseCookies; 39 typedef std::vector<std::string> ResponseCookies;
40 } // namespace net 40 } // namespace net
41 41
42 // To use this class, create an instance with the desired URL and a pointer to 42 // To use this class, create an instance with the desired URL and a pointer to
43 // the object to be notified when the URL has been loaded: 43 // the object to be notified when the URL has been loaded:
44 // URLFetcher* fetcher = new URLFetcher("http://www.google.com", 44 // URLFetcher* fetcher = new URLFetcher("http://www.google.com",
45 // URLFetcher::GET, this); 45 // URLFetcher::GET, this);
46 // 46 //
47 // Then, optionally set properties on this object, like the request context or 47 // Then, optionally set properties on this object, like the request context or
48 // extra headers: 48 // extra headers:
49 // fetcher->SetExtraRequestHeaders("X-Foo: bar"); 49 // fetcher->set_extra_request_headers("X-Foo: bar");
50 // 50 //
51 // Finally, start the request: 51 // Finally, start the request:
52 // fetcher->Start(); 52 // fetcher->Start();
53 // 53 //
54 // 54 //
55 // The object you supply as a delegate must inherit from URLFetcher::Delegate; 55 // The object you supply as a delegate must inherit from URLFetcher::Delegate;
56 // when the fetch is completed, OnURLFetchComplete() will be called with a 56 // when the fetch is completed, OnURLFetchComplete() will be called with a
57 // pointer to the URLFetcher. From that point until the original URLFetcher 57 // pointer to the URLFetcher. From that point until the original URLFetcher
58 // instance is destroyed, you may use accessor methods to see the result of 58 // instance is destroyed, you may use accessor methods to see the result of
59 // the fetch. You should copy these objects if you need them to live longer 59 // the fetch. You should copy these objects if you need them to live longer
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // if it is true URLFetcher will automatically re-execute the request, 186 // if it is true URLFetcher will automatically re-execute the request,
187 // after backoff_delay() elapses. URLFetcher has it set to true by default. 187 // after backoff_delay() elapses. URLFetcher has it set to true by default.
188 void set_automatically_retry_on_5xx(bool retry); 188 void set_automatically_retry_on_5xx(bool retry);
189 189
190 int max_retries() const; 190 int max_retries() const;
191 191
192 void set_max_retries(int max_retries); 192 void set_max_retries(int max_retries);
193 193
194 // Returns the back-off delay before the request will be retried, 194 // Returns the back-off delay before the request will be retried,
195 // when a 5xx response was received. 195 // when a 5xx response was received.
196 base::TimeDelta backoff_delay() const { return backoff_delay_; } 196 base::TimeDelta backoff_delay() const;
197 197
198 // Sets the back-off delay, allowing to mock 5xx requests in unit-tests. 198 // Sets the back-off delay, allowing to mock 5xx requests in unit-tests.
199 #if defined(UNIT_TEST) 199 // Intended for testing.
200 void set_backoff_delay(base::TimeDelta backoff_delay) { 200 void set_backoff_delay(base::TimeDelta backoff_delay);
willchan no longer on Chromium 2011/06/30 15:50:24 joi@, Who's still using this? It looks a bit usele
wtc 2011/06/30 21:36:02 set_backoff_delay() is only used by chrome/browser
201 backoff_delay_ = backoff_delay;
202 }
203 #endif // defined(UNIT_TEST)
204 201
205 // By default, the response is saved in a string. Call this method to save the 202 // By default, the response is saved in a string. Call this method to save the
206 // response to a temporary file instead. Must be called before Start(). 203 // response to a temporary file instead. Must be called before Start().
207 // |file_message_loop_proxy| will be used for all file operations. 204 // |file_message_loop_proxy| will be used for all file operations.
208 void SaveResponseToTemporaryFile( 205 void SaveResponseToTemporaryFile(
209 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); 206 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy);
210 207
211 // Retrieve the response headers from the request. Must only be called after 208 // Retrieve the response headers from the request. Must only be called after
212 // the OnURLFetchComplete callback has run. 209 // the OnURLFetchComplete callback has run.
213 virtual net::HttpResponseHeaders* response_headers() const; 210 virtual net::HttpResponseHeaders* response_headers() const;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 296
300 // Only used by URLFetcherTest, returns the number of URLFetcher::Core objects 297 // Only used by URLFetcherTest, returns the number of URLFetcher::Core objects
301 // actively running. 298 // actively running.
302 static int GetNumFetcherCores(); 299 static int GetNumFetcherCores();
303 300
304 class Core; 301 class Core;
305 scoped_refptr<Core> core_; 302 scoped_refptr<Core> core_;
306 303
307 static Factory* factory_; 304 static Factory* factory_;
308 305
309 // Back-off time delay. 0 by default.
310 base::TimeDelta backoff_delay_;
311
312 static bool g_interception_enabled; 306 static bool g_interception_enabled;
313 307
314 DISALLOW_COPY_AND_ASSIGN(URLFetcher); 308 DISALLOW_COPY_AND_ASSIGN(URLFetcher);
315 }; 309 };
316 310
317 #endif // CONTENT_COMMON_NET_URL_FETCHER_H_ 311 #endif // CONTENT_COMMON_NET_URL_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/url_fetcher.cc » ('j') | content/common/url_fetcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698