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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 static void SetIgnoreCertificateRequests(bool ignored); | 132 static void SetIgnoreCertificateRequests(bool ignored); |
133 | 133 |
134 // Sets data only needed by POSTs. All callers making POST requests should | 134 // Sets data only needed by POSTs. All callers making POST requests should |
135 // call one of the SetUpload* methods before the request is started. | 135 // call one of the SetUpload* methods before the request is started. |
136 // |upload_content_type| is the MIME type of the content, while | 136 // |upload_content_type| is the MIME type of the content, while |
137 // |upload_content| is the data to be sent (the Content-Length header value | 137 // |upload_content| is the data to be sent (the Content-Length header value |
138 // will be set to the length of this data). | 138 // will be set to the length of this data). |
139 virtual void SetUploadData(const std::string& upload_content_type, | 139 virtual void SetUploadData(const std::string& upload_content_type, |
140 const std::string& upload_content) = 0; | 140 const std::string& upload_content) = 0; |
141 | 141 |
142 // When a service uses URLFetcher to exchange some information, after | |
143 // completing the fetch procedure, it can call this function by passing its | |
144 // name, so its usage will be recorded in according histograms. (It is | |
145 // necessary to make proper histogram in histograms.xml file before calling | |
146 // this function. | |
147 void ReportYourUsage(const std::string& service) const; | |
bengr
2015/08/07 18:00:01
How about this?
void ReportUsageUMA(const std::str
amohammadkhan
2015/08/11 22:04:36
Done.
| |
148 | |
142 // Sets data only needed by POSTs. All callers making POST requests should | 149 // Sets data only needed by POSTs. All callers making POST requests should |
143 // call one of the SetUpload* methods before the request is started. | 150 // call one of the SetUpload* methods before the request is started. |
144 // |upload_content_type| is the MIME type of the content, while | 151 // |upload_content_type| is the MIME type of the content, while |
145 // |file_path| is the path to the file containing the data to be sent (the | 152 // |file_path| is the path to the file containing the data to be sent (the |
146 // Content-Length header value will be set to the length of this file). | 153 // Content-Length header value will be set to the length of this file). |
147 // |range_offset| and |range_length| specify the range of the part | 154 // |range_offset| and |range_length| specify the range of the part |
148 // to be uploaded. To upload the whole file, (0, kuint64max) can be used. | 155 // to be uploaded. To upload the whole file, (0, kuint64max) can be used. |
149 // |file_task_runner| will be used for all file operations. | 156 // |file_task_runner| will be used for all file operations. |
150 virtual void SetUploadFilePath( | 157 virtual void SetUploadFilePath( |
151 const std::string& upload_content_type, | 158 const std::string& upload_content_type, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 // Return the URL that this fetcher is processing. | 312 // Return the URL that this fetcher is processing. |
306 virtual const GURL& GetURL() const = 0; | 313 virtual const GURL& GetURL() const = 0; |
307 | 314 |
308 // The status of the URL fetch. | 315 // The status of the URL fetch. |
309 virtual const URLRequestStatus& GetStatus() const = 0; | 316 virtual const URLRequestStatus& GetStatus() const = 0; |
310 | 317 |
311 // The http response code received. Will return RESPONSE_CODE_INVALID | 318 // The http response code received. Will return RESPONSE_CODE_INVALID |
312 // if an error prevented any response from being received. | 319 // if an error prevented any response from being received. |
313 virtual int GetResponseCode() const = 0; | 320 virtual int GetResponseCode() const = 0; |
314 | 321 |
322 // Total number of bytes received, including the headers and before | |
323 // uncompressing | |
bengr
2015/08/07 18:00:01
Add a period.
amohammadkhan
2015/08/11 22:04:36
Done.
| |
324 virtual int64 GetBytesReceivedSize() const = 0; | |
325 | |
326 // Total number of bytes sent including the header size and POST body. But | |
327 // this value is before compression, so it may not be a good representative of | |
bengr
2015/08/07 18:00:01
Why report it then?
amohammadkhan
2015/08/11 22:04:36
Done.
| |
328 // number of received bytes on the wire. | |
329 virtual int64 GetBytesSentSize() const = 0; | |
330 | |
315 // Cookies received. | 331 // Cookies received. |
316 virtual const ResponseCookies& GetCookies() const = 0; | 332 virtual const ResponseCookies& GetCookies() const = 0; |
317 | 333 |
318 // Reports that the received content was malformed. | 334 // Reports that the received content was malformed. |
319 virtual void ReceivedContentWasMalformed() = 0; | 335 virtual void ReceivedContentWasMalformed() = 0; |
320 | 336 |
321 // Get the response as a string. Return false if the fetcher was not | 337 // Get the response as a string. Return false if the fetcher was not |
322 // set to store the response as a string. | 338 // set to store the response as a string. |
323 virtual bool GetResponseAsString(std::string* out_response_string) const = 0; | 339 virtual bool GetResponseAsString(std::string* out_response_string) const = 0; |
324 | 340 |
325 // Get the path to the file containing the response body. Returns false | 341 // Get the path to the file containing the response body. Returns false |
326 // if the response body was not saved to a file. If take_ownership is | 342 // if the response body was not saved to a file. If take_ownership is |
327 // true, caller takes responsibility for the file, and it will not | 343 // true, caller takes responsibility for the file, and it will not |
328 // be removed once the URLFetcher is destroyed. User should not take | 344 // be removed once the URLFetcher is destroyed. User should not take |
329 // ownership more than once, or call this method after taking ownership. | 345 // ownership more than once, or call this method after taking ownership. |
330 virtual bool GetResponseAsFilePath( | 346 virtual bool GetResponseAsFilePath( |
331 bool take_ownership, | 347 bool take_ownership, |
332 base::FilePath* out_response_path) const = 0; | 348 base::FilePath* out_response_path) const = 0; |
333 }; | 349 }; |
334 | 350 |
335 } // namespace net | 351 } // namespace net |
336 | 352 |
337 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 353 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
OLD | NEW |