| 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" | |
| 14 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 15 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 16 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
| 17 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 18 | 17 |
| 19 class GURL; | 18 class GURL; |
| 20 | 19 |
| 21 namespace base { | 20 namespace base { |
| 22 class FilePath; | 21 class FilePath; |
| 23 class MessageLoopProxy; | 22 class MessageLoopProxy; |
| 24 class TimeDelta; | 23 class TimeDelta; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace net { | 26 namespace net { |
| 28 class HostPortPair; | 27 class HostPortPair; |
| 29 class HttpRequestHeaders; | 28 class HttpRequestHeaders; |
| 30 class HttpResponseHeaders; | 29 class HttpResponseHeaders; |
| 31 class UploadDataStream; | |
| 32 class URLFetcherDelegate; | 30 class URLFetcherDelegate; |
| 33 class URLRequestContextGetter; | 31 class URLRequestContextGetter; |
| 34 class URLRequestStatus; | 32 class URLRequestStatus; |
| 35 typedef std::vector<std::string> ResponseCookies; | 33 typedef std::vector<std::string> ResponseCookies; |
| 36 | 34 |
| 37 // To use this class, create an instance with the desired URL and a pointer to | 35 // To use this class, create an instance with the desired URL and a pointer to |
| 38 // the object to be notified when the URL has been loaded: | 36 // the object to be notified when the URL has been loaded: |
| 39 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com", | 37 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com", |
| 40 // URLFetcher::GET, this); | 38 // URLFetcher::GET, this); |
| 41 // | 39 // |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 static void SetEnableInterceptionForTests(bool enabled); | 117 static void SetEnableInterceptionForTests(bool enabled); |
| 120 | 118 |
| 121 // Normally, URLFetcher will abort loads that request SSL client certificate | 119 // Normally, URLFetcher will abort loads that request SSL client certificate |
| 122 // authentication, but this method may be used to cause URLFetchers to ignore | 120 // authentication, but this method may be used to cause URLFetchers to ignore |
| 123 // requests for client certificates and continue anonymously. Because such | 121 // requests for client certificates and continue anonymously. Because such |
| 124 // behaviour affects the URLRequestContext's shared network state and socket | 122 // behaviour affects the URLRequestContext's shared network state and socket |
| 125 // pools, it should only be used for testing. | 123 // pools, it should only be used for testing. |
| 126 static void SetIgnoreCertificateRequests(bool ignored); | 124 static void SetIgnoreCertificateRequests(bool ignored); |
| 127 | 125 |
| 128 // Sets data only needed by POSTs. All callers making POST requests should | 126 // Sets data only needed by POSTs. All callers making POST requests should |
| 129 // call one of the SetUploadData* methods before the request is started. | 127 // call this before the request is started. |upload_content_type| is the MIME |
| 130 // |upload_content_type| is the MIME type of the content, while | 128 // type of the content, while |upload_content| is the data to be sent (the |
| 131 // |upload_content| is the data to be sent. | 129 // Content-Length header value will be set to the length of this data). |
| 132 virtual void SetUploadDataStream( | |
| 133 const std::string& upload_content_type, | |
| 134 scoped_ptr<UploadDataStream> upload_content) = 0; | |
| 135 | |
| 136 // Convenience method for setting upload data from a string. | |
| 137 // (the Content-Length header value will be set to the length of this data). | |
| 138 virtual void SetUploadData(const std::string& upload_content_type, | 130 virtual void SetUploadData(const std::string& upload_content_type, |
| 139 const std::string& upload_content) = 0; | 131 const std::string& upload_content) = 0; |
| 140 | 132 |
| 141 // Indicates that the POST data is sent via chunked transfer encoding. | 133 // Indicates that the POST data is sent via chunked transfer encoding. |
| 142 // This may only be called before calling Start(). | 134 // This may only be called before calling Start(). |
| 143 // Use AppendChunkToUpload() to give the data chunks after calling Start(). | 135 // Use AppendChunkToUpload() to give the data chunks after calling Start(). |
| 144 virtual void SetChunkedUpload(const std::string& upload_content_type) = 0; | 136 virtual void SetChunkedUpload(const std::string& upload_content_type) = 0; |
| 145 | 137 |
| 146 // 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 |
| 147 // transfer encoding. | 139 // transfer encoding. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // be removed once the URLFetcher is destroyed. User should not take | 277 // be removed once the URLFetcher is destroyed. User should not take |
| 286 // ownership more than once, or call this method after taking ownership. | 278 // ownership more than once, or call this method after taking ownership. |
| 287 virtual bool GetResponseAsFilePath( | 279 virtual bool GetResponseAsFilePath( |
| 288 bool take_ownership, | 280 bool take_ownership, |
| 289 base::FilePath* out_response_path) const = 0; | 281 base::FilePath* out_response_path) const = 0; |
| 290 }; | 282 }; |
| 291 | 283 |
| 292 } // namespace net | 284 } // namespace net |
| 293 | 285 |
| 294 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 286 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
| OLD | NEW |