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

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

Issue 11843003: Add SetUploadDataStream method to URLFetcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 | « net/url_request/test_url_fetcher_factory.cc ('k') | net/url_request/url_fetcher_core.h » ('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_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/platform_file.h" 14 #include "base/platform_file.h"
14 #include "base/supports_user_data.h" 15 #include "base/supports_user_data.h"
15 #include "base/task_runner.h" 16 #include "base/task_runner.h"
16 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
17 18
18 class FilePath; 19 class FilePath;
19 class GURL; 20 class GURL;
20 21
21 namespace base { 22 namespace base {
22 class MessageLoopProxy; 23 class MessageLoopProxy;
23 class TimeDelta; 24 class TimeDelta;
24 } 25 }
25 26
26 namespace net { 27 namespace net {
27 class HostPortPair; 28 class HostPortPair;
28 class HttpRequestHeaders; 29 class HttpRequestHeaders;
29 class HttpResponseHeaders; 30 class HttpResponseHeaders;
31 class UploadDataStream;
30 class URLFetcherDelegate; 32 class URLFetcherDelegate;
31 class URLRequestContextGetter; 33 class URLRequestContextGetter;
32 class URLRequestStatus; 34 class URLRequestStatus;
33 typedef std::vector<std::string> ResponseCookies; 35 typedef std::vector<std::string> ResponseCookies;
34 36
35 // To use this class, create an instance with the desired URL and a pointer to 37 // To use this class, create an instance with the desired URL and a pointer to
36 // the object to be notified when the URL has been loaded: 38 // the object to be notified when the URL has been loaded:
37 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com", 39 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com",
38 // URLFetcher::GET, this); 40 // URLFetcher::GET, this);
39 // 41 //
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO 111 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO
110 // thread though, even though the task won't ever run. 112 // thread though, even though the task won't ever run.
111 static void CancelAll(); 113 static void CancelAll();
112 114
113 // Normally interception is disabled for URLFetcher, but you can use this 115 // Normally interception is disabled for URLFetcher, but you can use this
114 // to enable it for tests. Also see ScopedURLFetcherFactory for another way 116 // to enable it for tests. Also see ScopedURLFetcherFactory for another way
115 // of testing code that uses an URLFetcher. 117 // of testing code that uses an URLFetcher.
116 static void SetEnableInterceptionForTests(bool enabled); 118 static void SetEnableInterceptionForTests(bool enabled);
117 119
118 // Sets data only needed by POSTs. All callers making POST requests should 120 // Sets data only needed by POSTs. All callers making POST requests should
119 // call this before the request is started. |upload_content_type| is the MIME 121 // call one of the SetUploadData* methods before the request is started.
120 // type of the content, while |upload_content| is the data to be sent (the 122 // |upload_content_type| is the MIME type of the content, while
121 // Content-Length header value will be set to the length of this data). 123 // |upload_content| is the data to be sent.
124 virtual void SetUploadDataStream(
125 const std::string& upload_content_type,
126 scoped_ptr<UploadDataStream> upload_content) = 0;
127
128 // Convenience method for setting upload data from a string.
129 // (the Content-Length header value will be set to the length of this data).
122 virtual void SetUploadData(const std::string& upload_content_type, 130 virtual void SetUploadData(const std::string& upload_content_type,
123 const std::string& upload_content) = 0; 131 const std::string& upload_content) = 0;
124 132
125 // Indicates that the POST data is sent via chunked transfer encoding. 133 // Indicates that the POST data is sent via chunked transfer encoding.
126 // This may only be called before calling Start(). 134 // This may only be called before calling Start().
127 // Use AppendChunkToUpload() to give the data chunks after calling Start(). 135 // Use AppendChunkToUpload() to give the data chunks after calling Start().
128 virtual void SetChunkedUpload(const std::string& upload_content_type) = 0; 136 virtual void SetChunkedUpload(const std::string& upload_content_type) = 0;
129 137
130 // Adds the given bytes to a request's POST data transmitted using chunked 138 // Adds the given bytes to a request's POST data transmitted using chunked
131 // transfer encoding. 139 // transfer encoding.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // true, caller takes responsibility for the file, and it will not 276 // true, caller takes responsibility for the file, and it will not
269 // be removed once the URLFetcher is destroyed. User should not take 277 // be removed once the URLFetcher is destroyed. User should not take
270 // ownership more than once, or call this method after taking ownership. 278 // ownership more than once, or call this method after taking ownership.
271 virtual bool GetResponseAsFilePath(bool take_ownership, 279 virtual bool GetResponseAsFilePath(bool take_ownership,
272 FilePath* out_response_path) const = 0; 280 FilePath* out_response_path) const = 0;
273 }; 281 };
274 282
275 } // namespace net 283 } // namespace net
276 284
277 #endif // NET_URL_REQUEST_URL_FETCHER_H_ 285 #endif // NET_URL_REQUEST_URL_FETCHER_H_
OLDNEW
« no previous file with comments | « net/url_request/test_url_fetcher_factory.cc ('k') | net/url_request/url_fetcher_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698