OLD | NEW |
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 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 DELETE_REQUEST, // DELETE is already taken on Windows. | 85 DELETE_REQUEST, // DELETE is already taken on Windows. |
86 // <winnt.h> defines a DELETE macro. | 86 // <winnt.h> defines a DELETE macro. |
87 PUT, | 87 PUT, |
88 PATCH, | 88 PATCH, |
89 }; | 89 }; |
90 | 90 |
91 // Used by SetURLRequestUserData. The callback should make a fresh | 91 // Used by SetURLRequestUserData. The callback should make a fresh |
92 // base::SupportsUserData::Data object every time it's called. | 92 // base::SupportsUserData::Data object every time it's called. |
93 typedef base::Callback<base::SupportsUserData::Data*()> CreateDataCallback; | 93 typedef base::Callback<base::SupportsUserData::Data*()> CreateDataCallback; |
94 | 94 |
| 95 // Used by SetUploadStreamFactory. The callback should assign a fresh upload |
| 96 // data stream every time it's called. |
| 97 typedef base::Callback<scoped_ptr<UploadDataStream>()> |
| 98 CreateUploadStreamCallback; |
| 99 |
95 virtual ~URLFetcher(); | 100 virtual ~URLFetcher(); |
96 | 101 |
97 // |url| is the URL to send the request to. | 102 // |url| is the URL to send the request to. |
98 // |request_type| is the type of request to make. | 103 // |request_type| is the type of request to make. |
99 // |d| the object that will receive the callback on fetch completion. | 104 // |d| the object that will receive the callback on fetch completion. |
100 // Caller is responsible for destroying the returned URLFetcher. | 105 // Caller is responsible for destroying the returned URLFetcher. |
101 static URLFetcher* Create(const GURL& url, | 106 static URLFetcher* Create(const GURL& url, |
102 URLFetcher::RequestType request_type, | 107 URLFetcher::RequestType request_type, |
103 URLFetcherDelegate* d); | 108 URLFetcherDelegate* d); |
104 | 109 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // |range_offset| and |range_length| specify the range of the part | 147 // |range_offset| and |range_length| specify the range of the part |
143 // to be uploaded. To upload the whole file, (0, kuint64max) can be used. | 148 // to be uploaded. To upload the whole file, (0, kuint64max) can be used. |
144 // |file_task_runner| will be used for all file operations. | 149 // |file_task_runner| will be used for all file operations. |
145 virtual void SetUploadFilePath( | 150 virtual void SetUploadFilePath( |
146 const std::string& upload_content_type, | 151 const std::string& upload_content_type, |
147 const base::FilePath& file_path, | 152 const base::FilePath& file_path, |
148 uint64 range_offset, | 153 uint64 range_offset, |
149 uint64 range_length, | 154 uint64 range_length, |
150 scoped_refptr<base::TaskRunner> file_task_runner) = 0; | 155 scoped_refptr<base::TaskRunner> file_task_runner) = 0; |
151 | 156 |
| 157 // Sets data only needed by POSTs. All callers making POST requests should |
| 158 // call one of the SetUpload* methods before the request is started. |
| 159 // |upload_content_type| is the MIME type of the content, while |callback| is |
| 160 // the callback to create the upload data stream (the Content-Length header |
| 161 // value will be set to the length of this data). |callback| may be called |
| 162 // mutliple times if the request is retried. |
| 163 virtual void SetUploadStreamFactory( |
| 164 const std::string& upload_content_type, |
| 165 const CreateUploadStreamCallback& callback) = 0; |
| 166 |
152 // Indicates that the POST data is sent via chunked transfer encoding. | 167 // Indicates that the POST data is sent via chunked transfer encoding. |
153 // This may only be called before calling Start(). | 168 // This may only be called before calling Start(). |
154 // Use AppendChunkToUpload() to give the data chunks after calling Start(). | 169 // Use AppendChunkToUpload() to give the data chunks after calling Start(). |
155 virtual void SetChunkedUpload(const std::string& upload_content_type) = 0; | 170 virtual void SetChunkedUpload(const std::string& upload_content_type) = 0; |
156 | 171 |
157 // Adds the given bytes to a request's POST data transmitted using chunked | 172 // Adds the given bytes to a request's POST data transmitted using chunked |
158 // transfer encoding. | 173 // transfer encoding. |
159 // This method should be called ONLY after calling Start(). | 174 // This method should be called ONLY after calling Start(). |
160 virtual void AppendChunkToUpload(const std::string& data, | 175 virtual void AppendChunkToUpload(const std::string& data, |
161 bool is_last_chunk) = 0; | 176 bool is_last_chunk) = 0; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // be removed once the URLFetcher is destroyed. User should not take | 316 // be removed once the URLFetcher is destroyed. User should not take |
302 // ownership more than once, or call this method after taking ownership. | 317 // ownership more than once, or call this method after taking ownership. |
303 virtual bool GetResponseAsFilePath( | 318 virtual bool GetResponseAsFilePath( |
304 bool take_ownership, | 319 bool take_ownership, |
305 base::FilePath* out_response_path) const = 0; | 320 base::FilePath* out_response_path) const = 0; |
306 }; | 321 }; |
307 | 322 |
308 } // namespace net | 323 } // namespace net |
309 | 324 |
310 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 325 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
OLD | NEW |