OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file contains URLFetcher, a wrapper around net::URLRequest that handles | 5 // This file contains URLFetcher, a wrapper around net::URLRequest that handles |
6 // low-level details like thread safety, ref counting, and incremental buffer | 6 // low-level details like thread safety, ref counting, and incremental buffer |
7 // reading. This is useful for callers who simply want to get the data from a | 7 // reading. This is useful for callers who simply want to get the data from a |
8 // URL and don't care about all the nitty-gritty details. | 8 // URL and don't care about all the nitty-gritty details. |
9 // | 9 // |
10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a | 10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 static URLFetcher* Create(int id, const GURL& url, RequestType request_type, | 125 static URLFetcher* Create(int id, const GURL& url, RequestType request_type, |
126 Delegate* d); | 126 Delegate* d); |
127 | 127 |
128 // Sets data only needed by POSTs. All callers making POST requests should | 128 // Sets data only needed by POSTs. All callers making POST requests should |
129 // call this before the request is started. |upload_content_type| is the MIME | 129 // call this before the request is started. |upload_content_type| is the MIME |
130 // type of the content, while |upload_content| is the data to be sent (the | 130 // type of the content, while |upload_content| is the data to be sent (the |
131 // Content-Length header value will be set to the length of this data). | 131 // Content-Length header value will be set to the length of this data). |
132 void set_upload_data(const std::string& upload_content_type, | 132 void set_upload_data(const std::string& upload_content_type, |
133 const std::string& upload_content); | 133 const std::string& upload_content); |
134 | 134 |
| 135 // Indicates that the POST data is sent via chunked transfer encoding. |
| 136 // This may only be called before calling Start(). |
| 137 // Use AppendChunkToUpload() to give the data chunks after calling Start(). |
| 138 void set_chunked_upload(const std::string& upload_content_type); |
| 139 |
| 140 // Adds the given bytes to a request's POST data transmitted using chunked |
| 141 // transfer encoding. |
| 142 // This method should be called ONLY after calling Start(). |
| 143 void AppendChunkToUpload(const std::string& data); |
| 144 |
| 145 // Signals the end of a chunked transfer encoded data stream. This method |
| 146 // should be called ONLY after calling Start(), set_chunked_upload() and |
| 147 // typically one or more calls to AppendChunkToUpload. |
| 148 void MarkEndOfChunks(); |
| 149 |
135 // Set one or more load flags as defined in net/base/load_flags.h. Must be | 150 // Set one or more load flags as defined in net/base/load_flags.h. Must be |
136 // called before the request is started. | 151 // called before the request is started. |
137 void set_load_flags(int load_flags); | 152 void set_load_flags(int load_flags); |
138 | 153 |
139 // Returns the current load flags. | 154 // Returns the current load flags. |
140 int load_flags() const; | 155 int load_flags() const; |
141 | 156 |
142 // The referrer URL for the request. Must be called before the request is | 157 // The referrer URL for the request. Must be called before the request is |
143 // started. | 158 // started. |
144 void set_referrer(const std::string& referrer); | 159 void set_referrer(const std::string& referrer); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 base::TimeDelta backoff_delay_; | 232 base::TimeDelta backoff_delay_; |
218 // Maximum retries allowed. | 233 // Maximum retries allowed. |
219 int max_retries_; | 234 int max_retries_; |
220 | 235 |
221 static bool g_interception_enabled; | 236 static bool g_interception_enabled; |
222 | 237 |
223 DISALLOW_COPY_AND_ASSIGN(URLFetcher); | 238 DISALLOW_COPY_AND_ASSIGN(URLFetcher); |
224 }; | 239 }; |
225 | 240 |
226 #endif // CHROME_COMMON_NET_URL_FETCHER_H_ | 241 #endif // CHROME_COMMON_NET_URL_FETCHER_H_ |
OLD | NEW |