Chromium Code Reviews| 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 // Data* object every time it's called. | |
|
wtc
2012/05/21 22:16:48
Nit: perhaps remove the '*' after "Data"? "Data*"
akalin
2012/05/21 22:28:37
Done.
| |
| 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 virtual void SetFirstPartyForCookies( | |
|
wtc
2012/05/21 22:16:48
Can you copy the comment (or add it) for this meth
akalin
2012/05/21 22:28:37
Done. Also updated URLFetcherCore docs.
| |
| 135 const GURL& first_party_for_cookies) = 0; | |
| 136 | |
| 137 // Whenever a URLRequest object is created, SetUserData() will be | |
|
wtc
2012/05/21 22:16:48
Is SetUserData a typo? This method is named SetUR
akalin
2012/05/21 22:28:37
This *is* supposed to be the one-sentence descript
| |
| 138 // called on it with the given key and the result of the given | |
| 139 // callback. | |
| 140 virtual void SetURLRequestUserData( | |
| 141 const void* key, const CreateDataCallback& create_data_callback) = 0; | |
| 142 | |
| 128 // If |retry| is false, 5xx responses will be propagated to the observer, | 143 // If |retry| is false, 5xx responses will be propagated to the observer, |
| 129 // if it is true URLFetcher will automatically re-execute the request, | 144 // if it is true URLFetcher will automatically re-execute the request, |
| 130 // after backoff_delay() elapses. URLFetcher has it set to true by default. | 145 // after backoff_delay() elapses. URLFetcher has it set to true by default. |
| 131 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; | 146 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; |
| 132 | 147 |
| 133 virtual void SetMaxRetries(int max_retries) = 0; | 148 virtual void SetMaxRetries(int max_retries) = 0; |
| 134 virtual int GetMaxRetries() const = 0; | 149 virtual int GetMaxRetries() const = 0; |
| 135 | 150 |
| 136 // Returns the back-off delay before the request will be retried, | 151 // Returns the back-off delay before the request will be retried, |
| 137 // when a 5xx response was received. | 152 // 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 | 222 // true, caller takes responsibility for the file, and it will not |
| 208 // be removed once the URLFetcher is destroyed. User should not take | 223 // be removed once the URLFetcher is destroyed. User should not take |
| 209 // ownership more than once, or call this method after taking ownership. | 224 // ownership more than once, or call this method after taking ownership. |
| 210 virtual bool GetResponseAsFilePath(bool take_ownership, | 225 virtual bool GetResponseAsFilePath(bool take_ownership, |
| 211 FilePath* out_response_path) const = 0; | 226 FilePath* out_response_path) const = 0; |
| 212 }; | 227 }; |
| 213 | 228 |
| 214 } // namespace net | 229 } // namespace net |
| 215 | 230 |
| 216 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 231 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
| OLD | NEW |