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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
| 14 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
| 15 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
| 16 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 17 | 18 |
| 18 class FilePath; | 19 class FilePath; |
| 19 class GURL; | 20 class GURL; |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class MessageLoopProxy; | 23 class MessageLoopProxy; |
| 23 class TimeDelta; | 24 class TimeDelta; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace net { | 27 namespace net { |
| 27 class HostPortPair; | 28 class HostPortPair; |
| 28 class HttpRequestHeaders; | 29 class HttpRequestHeaders; |
| 29 class HttpResponseHeaders; | 30 class HttpResponseHeaders; |
| 31 class UploadDataStream; | |
| 30 class URLFetcherDelegate; | 32 class URLFetcherDelegate; |
| 31 class URLRequestContextGetter; | 33 class URLRequestContextGetter; |
| 32 class URLRequestStatus; | 34 class URLRequestStatus; |
| 33 typedef std::vector<std::string> ResponseCookies; | 35 typedef std::vector<std::string> ResponseCookies; |
| 34 | 36 |
| 35 // To use this class, create an instance with the desired URL and a pointer to | 37 // To use this class, create an instance with the desired URL and a pointer to |
| 36 // the object to be notified when the URL has been loaded: | 38 // the object to be notified when the URL has been loaded: |
| 37 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com", | 39 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com", |
| 38 // URLFetcher::GET, this); | 40 // URLFetcher::GET, this); |
| 39 // | 41 // |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO | 111 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO |
| 110 // thread though, even though the task won't ever run. | 112 // thread though, even though the task won't ever run. |
| 111 static void CancelAll(); | 113 static void CancelAll(); |
| 112 | 114 |
| 113 // Normally interception is disabled for URLFetcher, but you can use this | 115 // Normally interception is disabled for URLFetcher, but you can use this |
| 114 // to enable it for tests. Also see ScopedURLFetcherFactory for another way | 116 // to enable it for tests. Also see ScopedURLFetcherFactory for another way |
| 115 // of testing code that uses an URLFetcher. | 117 // of testing code that uses an URLFetcher. |
| 116 static void SetEnableInterceptionForTests(bool enabled); | 118 static void SetEnableInterceptionForTests(bool enabled); |
| 117 | 119 |
| 118 // Sets data only needed by POSTs. All callers making POST requests should | 120 // Sets data only needed by POSTs. All callers making POST requests should |
| 119 // call this before the request is started. |upload_content_type| is the MIME | 121 // call one of the SetUploadData* methods before the request is started. |
| 120 // type of the content, while |upload_content| is the data to be sent (the | 122 // |upload_content_type| is the MIME type of the content, while |
| 121 // Content-Length header value will be set to the length of this data). | 123 // |upload_content| is the data to be sent. |
| 124 virtual void SetUploadDataStream( | |
| 125 const std::string& upload_content_type, | |
| 126 scoped_ptr<UploadDataStream> upload_content) = 0; | |
|
hashimoto
2013/01/11 06:07:38
nit: blank line here?
mattm
2013/01/11 21:42:02
Done.
| |
| 127 // Convenience method for setting upload data from a string. | |
| 128 // (the Content-Length header value will be set to the length of this data). | |
| 122 virtual void SetUploadData(const std::string& upload_content_type, | 129 virtual void SetUploadData(const std::string& upload_content_type, |
| 123 const std::string& upload_content) = 0; | 130 const std::string& upload_content) = 0; |
| 124 | 131 |
| 132 | |
|
hashimoto
2013/01/11 06:07:38
nit: No need to have a blank line here.
mattm
2013/01/11 21:42:02
Done.
| |
| 125 // Indicates that the POST data is sent via chunked transfer encoding. | 133 // Indicates that the POST data is sent via chunked transfer encoding. |
| 126 // This may only be called before calling Start(). | 134 // This may only be called before calling Start(). |
| 127 // Use AppendChunkToUpload() to give the data chunks after calling Start(). | 135 // Use AppendChunkToUpload() to give the data chunks after calling Start(). |
| 128 virtual void SetChunkedUpload(const std::string& upload_content_type) = 0; | 136 virtual void SetChunkedUpload(const std::string& upload_content_type) = 0; |
| 129 | 137 |
| 130 // Adds the given bytes to a request's POST data transmitted using chunked | 138 // Adds the given bytes to a request's POST data transmitted using chunked |
| 131 // transfer encoding. | 139 // transfer encoding. |
| 132 // This method should be called ONLY after calling Start(). | 140 // This method should be called ONLY after calling Start(). |
| 133 virtual void AppendChunkToUpload(const std::string& data, | 141 virtual void AppendChunkToUpload(const std::string& data, |
| 134 bool is_last_chunk) = 0; | 142 bool is_last_chunk) = 0; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 // true, caller takes responsibility for the file, and it will not | 279 // true, caller takes responsibility for the file, and it will not |
| 272 // be removed once the URLFetcher is destroyed. User should not take | 280 // be removed once the URLFetcher is destroyed. User should not take |
| 273 // ownership more than once, or call this method after taking ownership. | 281 // ownership more than once, or call this method after taking ownership. |
| 274 virtual bool GetResponseAsFilePath(bool take_ownership, | 282 virtual bool GetResponseAsFilePath(bool take_ownership, |
| 275 FilePath* out_response_path) const = 0; | 283 FilePath* out_response_path) const = 0; |
| 276 }; | 284 }; |
| 277 | 285 |
| 278 } // namespace net | 286 } // namespace net |
| 279 | 287 |
| 280 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 288 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
| OLD | NEW |