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

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

Issue 7065008: Move response_container_ into the URLFetcher::Core. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/net/test_url_fetcher_factory.cc ('k') | chrome/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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 // Cancels all existing URLFetchers. Will notify the URLFetcher::Delegates. 257 // Cancels all existing URLFetchers. Will notify the URLFetcher::Delegates.
258 // Note that any new URLFetchers created while this is running will not be 258 // Note that any new URLFetchers created while this is running will not be
259 // cancelled. Typically, one would call this in the CleanUp() method of an IO 259 // cancelled. Typically, one would call this in the CleanUp() method of an IO
260 // thread, so that no new URLRequests would be able to start on the IO thread 260 // thread, so that no new URLRequests would be able to start on the IO thread
261 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO 261 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO
262 // thread though, even though the task won't ever run. 262 // thread though, even though the task won't ever run.
263 static void CancelAll(); 263 static void CancelAll();
264 264
265 protected: 265 protected:
266 // How should the response be stored?
267 enum ResponseDestinationType {
268 STRING, // Default: In a std::string
269 TEMP_FILE // Write to a temp file
270 };
271
266 // Returns the delegate. 272 // Returns the delegate.
267 Delegate* delegate() const; 273 Delegate* delegate() const;
268 274
269 // Used by tests. 275 // Used by tests.
270 const std::string& upload_data() const; 276 const std::string& upload_data() const;
271 277
272 // Return a reference to the string data fetched. Response type must 278 // Return a reference to the string data fetched. Response type must
273 // be STRING, or this will CHECK. This method exists to support the 279 // be STRING, or this will CHECK. This method exists to support the
274 // old signiture to OnURLFetchComplete(), and will be removed as part 280 // old signiture to OnURLFetchComplete(), and will be removed as part
275 // of crbug.com/83592 . 281 // of crbug.com/83592 .
276 const std::string& GetResponseStringRef() const; 282 const std::string& GetResponseStringRef() const;
277 283
284 void SetResponseDestinationForTesting(ResponseDestinationType);
285 ResponseDestinationType GetResponseDestinationForTesting() const;
286
278 private: 287 private:
279 friend class URLFetcherTest; 288 friend class URLFetcherTest;
280 friend class TestURLFetcher; 289 friend class TestURLFetcher;
281 290
282 // How should the response be stored?
283 enum ResponseDestinationType {
284 STRING, // Default: In a std::string
285 TEMP_FILE // Write to a temp file
286 };
287
288 // Only used by URLFetcherTest, returns the number of URLFetcher::Core objects 291 // Only used by URLFetcherTest, returns the number of URLFetcher::Core objects
289 // actively running. 292 // actively running.
290 static int GetNumFetcherCores(); 293 static int GetNumFetcherCores();
291 294
292 class Core; 295 class Core;
293 scoped_refptr<Core> core_; 296 scoped_refptr<Core> core_;
294 297
295 static Factory* factory_; 298 static Factory* factory_;
296 299
297 // If |automatically_retry_on_5xx_| is false, 5xx responses will be 300 // If |automatically_retry_on_5xx_| is false, 5xx responses will be
298 // propagated to the observer, if it is true URLFetcher will automatically 301 // propagated to the observer, if it is true URLFetcher will automatically
299 // re-execute the request, after the back-off delay has expired. 302 // re-execute the request, after the back-off delay has expired.
300 // true by default. 303 // true by default.
301 bool automatically_retry_on_5xx_; 304 bool automatically_retry_on_5xx_;
302 // Back-off time delay. 0 by default. 305 // Back-off time delay. 0 by default.
303 base::TimeDelta backoff_delay_; 306 base::TimeDelta backoff_delay_;
304 // Maximum retries allowed. 307 // Maximum retries allowed.
305 int max_retries_; 308 int max_retries_;
306 309
307 // Where should responses be saved?
308 ResponseDestinationType response_destination_;
309
310 static bool g_interception_enabled; 310 static bool g_interception_enabled;
311 311
312 DISALLOW_COPY_AND_ASSIGN(URLFetcher); 312 DISALLOW_COPY_AND_ASSIGN(URLFetcher);
313 }; 313 };
314 314
315 #endif // CHROME_COMMON_NET_URL_FETCHER_H_ 315 #endif // CHROME_COMMON_NET_URL_FETCHER_H_
OLDNEW
« no previous file with comments | « chrome/common/net/test_url_fetcher_factory.cc ('k') | chrome/common/net/url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698