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

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

Issue 809663003: net: Add SetUploadStream method to URLFetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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_CORE_H_ 5 #ifndef NET_URL_REQUEST_URL_FETCHER_CORE_H_
6 #define NET_URL_REQUEST_URL_FETCHER_CORE_H_ 6 #define NET_URL_REQUEST_URL_FETCHER_CORE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 // For POST requests, set |content_type| to the MIME type of the 62 // For POST requests, set |content_type| to the MIME type of the
63 // content and set |content| to the data to upload. 63 // content and set |content| to the data to upload.
64 void SetUploadData(const std::string& upload_content_type, 64 void SetUploadData(const std::string& upload_content_type,
65 const std::string& upload_content); 65 const std::string& upload_content);
66 void SetUploadFilePath(const std::string& upload_content_type, 66 void SetUploadFilePath(const std::string& upload_content_type,
67 const base::FilePath& file_path, 67 const base::FilePath& file_path,
68 uint64 range_offset, 68 uint64 range_offset,
69 uint64 range_length, 69 uint64 range_length,
70 scoped_refptr<base::TaskRunner> file_task_runner); 70 scoped_refptr<base::TaskRunner> file_task_runner);
71 void SetUploadStreamFactory(
72 const std::string& upload_content_type,
73 const URLFetcher::CreateUploadStreamCallback& callback);
71 void SetChunkedUpload(const std::string& upload_content_type); 74 void SetChunkedUpload(const std::string& upload_content_type);
72 // Adds a block of data to be uploaded in a POST body. This can only be 75 // Adds a block of data to be uploaded in a POST body. This can only be
73 // called after Start(). 76 // called after Start().
74 void AppendChunkToUpload(const std::string& data, bool is_last_chunk); 77 void AppendChunkToUpload(const std::string& data, bool is_last_chunk);
75 // |flags| are flags to apply to the load operation--these should be 78 // |flags| are flags to apply to the load operation--these should be
76 // one or more of the LOAD_* flags defined in net/base/load_flags.h. 79 // one or more of the LOAD_* flags defined in net/base/load_flags.h.
77 void SetLoadFlags(int load_flags); 80 void SetLoadFlags(int load_flags);
78 int GetLoadFlags() const; 81 int GetLoadFlags() const;
79 void SetReferrer(const std::string& referrer); 82 void SetReferrer(const std::string& referrer);
80 void SetReferrerPolicy(URLRequest::ReferrerPolicy referrer_policy); 83 void SetReferrerPolicy(URLRequest::ReferrerPolicy referrer_policy);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Read response bytes from the request. 199 // Read response bytes from the request.
197 void ReadResponse(); 200 void ReadResponse();
198 201
199 // Notify Delegate about the progress of upload/download. 202 // Notify Delegate about the progress of upload/download.
200 void InformDelegateUploadProgress(); 203 void InformDelegateUploadProgress();
201 void InformDelegateUploadProgressInDelegateThread(int64 current, int64 total); 204 void InformDelegateUploadProgressInDelegateThread(int64 current, int64 total);
202 void InformDelegateDownloadProgress(); 205 void InformDelegateDownloadProgress();
203 void InformDelegateDownloadProgressInDelegateThread(int64 current, 206 void InformDelegateDownloadProgressInDelegateThread(int64 current,
204 int64 total); 207 int64 total);
205 208
209 // Check if any upload data is set or not.
210 bool IsUploadDataSet() const;
211
206 URLFetcher* fetcher_; // Corresponding fetcher object 212 URLFetcher* fetcher_; // Corresponding fetcher object
207 GURL original_url_; // The URL we were asked to fetch 213 GURL original_url_; // The URL we were asked to fetch
208 GURL url_; // The URL we eventually wound up at 214 GURL url_; // The URL we eventually wound up at
209 URLFetcher::RequestType request_type_; // What type of request is this? 215 URLFetcher::RequestType request_type_; // What type of request is this?
210 URLRequestStatus status_; // Status of the request 216 URLRequestStatus status_; // Status of the request
211 URLFetcherDelegate* delegate_; // Object to notify on completion 217 URLFetcherDelegate* delegate_; // Object to notify on completion
212 // Task runner for the creating thread. Used to interact with the delegate. 218 // Task runner for the creating thread. Used to interact with the delegate.
213 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; 219 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_;
214 // Task runner for network operations. 220 // Task runner for network operations.
215 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 221 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
216 // Task runner for upload file access. 222 // Task runner for upload file access.
217 scoped_refptr<base::TaskRunner> upload_file_task_runner_; 223 scoped_refptr<base::TaskRunner> upload_file_task_runner_;
218 scoped_ptr<URLRequest> request_; // The actual request this wraps 224 scoped_ptr<URLRequest> request_; // The actual request this wraps
219 int load_flags_; // Flags for the load operation 225 int load_flags_; // Flags for the load operation
220 int response_code_; // HTTP status code for the request 226 int response_code_; // HTTP status code for the request
221 scoped_refptr<IOBuffer> buffer_; 227 scoped_refptr<IOBuffer> buffer_;
222 // Read buffer 228 // Read buffer
223 scoped_refptr<URLRequestContextGetter> request_context_getter_; 229 scoped_refptr<URLRequestContextGetter> request_context_getter_;
224 // Cookie/cache info for the request 230 // Cookie/cache info for the request
225 GURL first_party_for_cookies_; // The first party URL for the request 231 GURL first_party_for_cookies_; // The first party URL for the request
226 // The user data to add to each newly-created URLRequest. 232 // The user data to add to each newly-created URLRequest.
227 const void* url_request_data_key_; 233 const void* url_request_data_key_;
228 URLFetcher::CreateDataCallback url_request_create_data_callback_; 234 URLFetcher::CreateDataCallback url_request_create_data_callback_;
229 ResponseCookies cookies_; // Response cookies 235 ResponseCookies cookies_; // Response cookies
230 HttpRequestHeaders extra_request_headers_; 236 HttpRequestHeaders extra_request_headers_;
231 scoped_refptr<HttpResponseHeaders> response_headers_; 237 scoped_refptr<HttpResponseHeaders> response_headers_;
232 bool was_fetched_via_proxy_; 238 bool was_fetched_via_proxy_;
233 HostPortPair socket_address_; 239 HostPortPair socket_address_;
234 240
235 bool upload_content_set_; // SetUploadData has been called
236 std::string upload_content_; // HTTP POST payload 241 std::string upload_content_; // HTTP POST payload
237 base::FilePath upload_file_path_; // Path to file containing POST payload 242 base::FilePath upload_file_path_; // Path to file containing POST payload
238 uint64 upload_range_offset_; // Offset from the beginning of the file 243 uint64 upload_range_offset_; // Offset from the beginning of the file
239 // to be uploaded. 244 // to be uploaded.
240 uint64 upload_range_length_; // The length of the part of file to be 245 uint64 upload_range_length_; // The length of the part of file to be
241 // uploaded. 246 // uploaded.
247 URLFetcher::CreateUploadStreamCallback
248 upload_stream_factory_; // Callback to create HTTP POST payload.
242 std::string upload_content_type_; // MIME type of POST payload 249 std::string upload_content_type_; // MIME type of POST payload
243 std::string referrer_; // HTTP Referer header value and policy 250 std::string referrer_; // HTTP Referer header value and policy
244 URLRequest::ReferrerPolicy referrer_policy_; 251 URLRequest::ReferrerPolicy referrer_policy_;
245 bool is_chunked_upload_; // True if using chunked transfer encoding 252 bool is_chunked_upload_; // True if using chunked transfer encoding
246 253
247 // Used to determine how long to wait before making a request or doing a 254 // Used to determine how long to wait before making a request or doing a
248 // retry. 255 // retry.
249 // 256 //
250 // Both of them can only be accessed on the IO thread. 257 // Both of them can only be accessed on the IO thread.
251 // 258 //
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 base::debug::StackTrace stack_trace_; 321 base::debug::StackTrace stack_trace_;
315 322
316 static base::LazyInstance<Registry> g_registry; 323 static base::LazyInstance<Registry> g_registry;
317 324
318 DISALLOW_COPY_AND_ASSIGN(URLFetcherCore); 325 DISALLOW_COPY_AND_ASSIGN(URLFetcherCore);
319 }; 326 };
320 327
321 } // namespace net 328 } // namespace net
322 329
323 #endif // NET_URL_REQUEST_URL_FETCHER_CORE_H_ 330 #endif // NET_URL_REQUEST_URL_FETCHER_CORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698