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

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

Issue 26230003: net: Allow URLFetcher users to inject custom URLFetcherResponseWriter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
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_FETCHER_H_ 5 #ifndef NET_URL_REQUEST_URL_FETCHER_H_
6 #define NET_URL_REQUEST_URL_FETCHER_H_ 6 #define NET_URL_REQUEST_URL_FETCHER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/supports_user_data.h" 14 #include "base/supports_user_data.h"
14 #include "base/task_runner.h" 15 #include "base/task_runner.h"
15 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
16 17
17 class GURL; 18 class GURL;
18 19
19 namespace base { 20 namespace base {
20 class FilePath; 21 class FilePath;
21 class MessageLoopProxy; 22 class MessageLoopProxy;
22 class TimeDelta; 23 class TimeDelta;
23 } 24 }
24 25
25 namespace net { 26 namespace net {
26 class HostPortPair; 27 class HostPortPair;
27 class HttpRequestHeaders; 28 class HttpRequestHeaders;
28 class HttpResponseHeaders; 29 class HttpResponseHeaders;
29 class URLFetcherDelegate; 30 class URLFetcherDelegate;
31 class URLFetcherResponseWriter;
30 class URLRequestContextGetter; 32 class URLRequestContextGetter;
31 class URLRequestStatus; 33 class URLRequestStatus;
32 typedef std::vector<std::string> ResponseCookies; 34 typedef std::vector<std::string> ResponseCookies;
33 35
34 // To use this class, create an instance with the desired URL and a pointer to 36 // To use this class, create an instance with the desired URL and a pointer to
35 // the object to be notified when the URL has been loaded: 37 // the object to be notified when the URL has been loaded:
36 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com", 38 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com",
37 // URLFetcher::GET, this); 39 // URLFetcher::GET, this);
38 // 40 //
39 // You must also set a request context getter: 41 // You must also set a request context getter:
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 scoped_refptr<base::TaskRunner> file_task_runner) = 0; 234 scoped_refptr<base::TaskRunner> file_task_runner) = 0;
233 235
234 // By default, the response is saved in a string. Call this method to save the 236 // By default, the response is saved in a string. Call this method to save the
235 // response to a temporary file instead. Must be called before Start(). 237 // response to a temporary file instead. Must be called before Start().
236 // |file_task_runner| will be used for all file operations. 238 // |file_task_runner| will be used for all file operations.
237 // The created file is removed when the URLFetcher is deleted unless you 239 // The created file is removed when the URLFetcher is deleted unless you
238 // take ownership by calling GetResponseAsFilePath(). 240 // take ownership by calling GetResponseAsFilePath().
239 virtual void SaveResponseToTemporaryFile( 241 virtual void SaveResponseToTemporaryFile(
240 scoped_refptr<base::TaskRunner> file_task_runner) = 0; 242 scoped_refptr<base::TaskRunner> file_task_runner) = 0;
241 243
244 // By default, the response is saved in a string. Call this method to use the
245 // specified writer to save the response. Must be called before Start().
246 virtual void SaveResponseWithWriter(
247 scoped_ptr<URLFetcherResponseWriter> response_writer) = 0;
wtc 2013/10/14 19:57:23 Why don't you remove the SaveResponseToFileAtPath
hashimoto 2013/10/15 01:00:35 I thought it might be OK to leave SaveResponseToFi
248
242 // Retrieve the response headers from the request. Must only be called after 249 // Retrieve the response headers from the request. Must only be called after
243 // the OnURLFetchComplete callback has run. 250 // the OnURLFetchComplete callback has run.
244 virtual HttpResponseHeaders* GetResponseHeaders() const = 0; 251 virtual HttpResponseHeaders* GetResponseHeaders() const = 0;
245 252
246 // Retrieve the remote socket address from the request. Must only 253 // Retrieve the remote socket address from the request. Must only
247 // be called after the OnURLFetchComplete callback has run and if 254 // be called after the OnURLFetchComplete callback has run and if
248 // the request has not failed. 255 // the request has not failed.
249 virtual HostPortPair GetSocketAddress() const = 0; 256 virtual HostPortPair GetSocketAddress() const = 0;
250 257
251 // Returns true if the request was delivered through a proxy. Must only 258 // Returns true if the request was delivered through a proxy. Must only
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // be removed once the URLFetcher is destroyed. User should not take 293 // be removed once the URLFetcher is destroyed. User should not take
287 // ownership more than once, or call this method after taking ownership. 294 // ownership more than once, or call this method after taking ownership.
288 virtual bool GetResponseAsFilePath( 295 virtual bool GetResponseAsFilePath(
289 bool take_ownership, 296 bool take_ownership,
290 base::FilePath* out_response_path) const = 0; 297 base::FilePath* out_response_path) const = 0;
291 }; 298 };
292 299
293 } // namespace net 300 } // namespace net
294 301
295 #endif // NET_URL_REQUEST_URL_FETCHER_H_ 302 #endif // NET_URL_REQUEST_URL_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698