| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
| 15 #include "base/supports_user_data.h" |
| 14 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 15 | 17 |
| 16 class FilePath; | 18 class FilePath; |
| 17 class GURL; | 19 class GURL; |
| 18 | 20 |
| 19 namespace base { | 21 namespace base { |
| 20 class MessageLoopProxy; | 22 class MessageLoopProxy; |
| 21 class TimeDelta; | 23 class TimeDelta; |
| 22 } | 24 } |
| 23 | 25 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 70 |
| 69 enum RequestType { | 71 enum RequestType { |
| 70 GET, | 72 GET, |
| 71 POST, | 73 POST, |
| 72 HEAD, | 74 HEAD, |
| 73 DELETE_REQUEST, // DELETE is already taken on Windows. | 75 DELETE_REQUEST, // DELETE is already taken on Windows. |
| 74 // <winnt.h> defines a DELETE macro. | 76 // <winnt.h> defines a DELETE macro. |
| 75 PUT, | 77 PUT, |
| 76 }; | 78 }; |
| 77 | 79 |
| 80 // Used by SetURLRequestUserData. The callback should make a fresh |
| 81 // base::SupportsUserData::Data object every time it's called. |
| 82 typedef base::Callback<base::SupportsUserData::Data*()> CreateDataCallback; |
| 83 |
| 78 virtual ~URLFetcher(); | 84 virtual ~URLFetcher(); |
| 79 | 85 |
| 80 // Sets data only needed by POSTs. All callers making POST requests should | 86 // Sets data only needed by POSTs. All callers making POST requests should |
| 81 // call this before the request is started. |upload_content_type| is the MIME | 87 // call this before the request is started. |upload_content_type| is the MIME |
| 82 // type of the content, while |upload_content| is the data to be sent (the | 88 // type of the content, while |upload_content| is the data to be sent (the |
| 83 // Content-Length header value will be set to the length of this data). | 89 // Content-Length header value will be set to the length of this data). |
| 84 virtual void SetUploadData(const std::string& upload_content_type, | 90 virtual void SetUploadData(const std::string& upload_content_type, |
| 85 const std::string& upload_content) = 0; | 91 const std::string& upload_content) = 0; |
| 86 | 92 |
| 87 // Indicates that the POST data is sent via chunked transfer encoding. | 93 // Indicates that the POST data is sent via chunked transfer encoding. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 118 virtual void AddExtraRequestHeader(const std::string& header_line) = 0; | 124 virtual void AddExtraRequestHeader(const std::string& header_line) = 0; |
| 119 | 125 |
| 120 virtual void GetExtraRequestHeaders( | 126 virtual void GetExtraRequestHeaders( |
| 121 HttpRequestHeaders* headers) const = 0; | 127 HttpRequestHeaders* headers) const = 0; |
| 122 | 128 |
| 123 // Set the URLRequestContext on the request. Must be called before the | 129 // Set the URLRequestContext on the request. Must be called before the |
| 124 // request is started. | 130 // request is started. |
| 125 virtual void SetRequestContext( | 131 virtual void SetRequestContext( |
| 126 URLRequestContextGetter* request_context_getter) = 0; | 132 URLRequestContextGetter* request_context_getter) = 0; |
| 127 | 133 |
| 134 // Set the URL that should be consulted for the third-party cookie |
| 135 // blocking policy. |
| 136 virtual void SetFirstPartyForCookies( |
| 137 const GURL& first_party_for_cookies) = 0; |
| 138 |
| 139 // Set the key and data callback that is used when setting the user |
| 140 // data on any URLRequest objects this object creates. |
| 141 virtual void SetURLRequestUserData( |
| 142 const void* key, const CreateDataCallback& create_data_callback) = 0; |
| 143 |
| 128 // If |retry| is false, 5xx responses will be propagated to the observer, | 144 // If |retry| is false, 5xx responses will be propagated to the observer, |
| 129 // if it is true URLFetcher will automatically re-execute the request, | 145 // if it is true URLFetcher will automatically re-execute the request, |
| 130 // after backoff_delay() elapses. URLFetcher has it set to true by default. | 146 // after backoff_delay() elapses. URLFetcher has it set to true by default. |
| 131 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; | 147 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; |
| 132 | 148 |
| 133 virtual void SetMaxRetries(int max_retries) = 0; | 149 virtual void SetMaxRetries(int max_retries) = 0; |
| 134 virtual int GetMaxRetries() const = 0; | 150 virtual int GetMaxRetries() const = 0; |
| 135 | 151 |
| 136 // Returns the back-off delay before the request will be retried, | 152 // Returns the back-off delay before the request will be retried, |
| 137 // when a 5xx response was received. | 153 // when a 5xx response was received. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // true, caller takes responsibility for the file, and it will not | 223 // true, caller takes responsibility for the file, and it will not |
| 208 // be removed once the URLFetcher is destroyed. User should not take | 224 // be removed once the URLFetcher is destroyed. User should not take |
| 209 // ownership more than once, or call this method after taking ownership. | 225 // ownership more than once, or call this method after taking ownership. |
| 210 virtual bool GetResponseAsFilePath(bool take_ownership, | 226 virtual bool GetResponseAsFilePath(bool take_ownership, |
| 211 FilePath* out_response_path) const = 0; | 227 FilePath* out_response_path) const = 0; |
| 212 }; | 228 }; |
| 213 | 229 |
| 214 } // namespace net | 230 } // namespace net |
| 215 | 231 |
| 216 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 232 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
| OLD | NEW |