Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: content/public/common/url_fetcher.h

Issue 9585009: Add URLFetcher::SaveResponseToFileAtPath (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ 5 #ifndef CONTENT_PUBLIC_COMMON_URL_FETCHER_H_
6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ 6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; 162 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0;
163 163
164 virtual void SetMaxRetries(int max_retries) = 0; 164 virtual void SetMaxRetries(int max_retries) = 0;
165 virtual int GetMaxRetries() const = 0; 165 virtual int GetMaxRetries() const = 0;
166 166
167 // Returns the back-off delay before the request will be retried, 167 // Returns the back-off delay before the request will be retried,
168 // when a 5xx response was received. 168 // when a 5xx response was received.
169 virtual base::TimeDelta GetBackoffDelay() const = 0; 169 virtual base::TimeDelta GetBackoffDelay() const = 0;
170 170
171 // By default, the response is saved in a string. Call this method to save the 171 // By default, the response is saved in a string. Call this method to save the
172 // response to a file instead. Must be called before Start().
173 // |file_message_loop_proxy| will be used for all file operations.
174 // To save to a temporary file, use SaveResponseToTemporaryFile().
175 // The created file is removed when the URLFetcher is deleted unless you
176 // take ownership by calling GetResponseAsFilePath().
177 virtual void SaveResponseToFileAtPath(
178 const FilePath& file_path,
179 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) = 0;
180
181 // By default, the response is saved in a string. Call this method to save the
172 // response to a temporary file instead. Must be called before Start(). 182 // response to a temporary file instead. Must be called before Start().
173 // |file_message_loop_proxy| will be used for all file operations. 183 // |file_message_loop_proxy| will be used for all file operations.
184 // The created file is removed when the URLFetcher is deleted unless you
185 // take ownership by calling GetResponseAsFilePath().
174 virtual void SaveResponseToTemporaryFile( 186 virtual void SaveResponseToTemporaryFile(
175 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) = 0; 187 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) = 0;
176 188
177 // Retrieve the response headers from the request. Must only be called after 189 // Retrieve the response headers from the request. Must only be called after
178 // the OnURLFetchComplete callback has run. 190 // the OnURLFetchComplete callback has run.
179 virtual net::HttpResponseHeaders* GetResponseHeaders() const = 0; 191 virtual net::HttpResponseHeaders* GetResponseHeaders() const = 0;
180 192
181 // Retrieve the remote socket address from the request. Must only 193 // Retrieve the remote socket address from the request. Must only
182 // be called after the OnURLFetchComplete callback has run and if 194 // be called after the OnURLFetchComplete callback has run and if
183 // the request has not failed. 195 // the request has not failed.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 232
221 // Reports that the received content was malformed. 233 // Reports that the received content was malformed.
222 virtual void ReceivedContentWasMalformed() = 0; 234 virtual void ReceivedContentWasMalformed() = 0;
223 235
224 // Get the response as a string. Return false if the fetcher was not 236 // Get the response as a string. Return false if the fetcher was not
225 // set to store the response as a string. 237 // set to store the response as a string.
226 virtual bool GetResponseAsString(std::string* out_response_string) const = 0; 238 virtual bool GetResponseAsString(std::string* out_response_string) const = 0;
227 239
228 // Get the path to the file containing the response body. Returns false 240 // Get the path to the file containing the response body. Returns false
229 // if the response body was not saved to a file. If take_ownership is 241 // if the response body was not saved to a file. If take_ownership is
230 // true, caller takes responsibility for the temp file, and it will not 242 // true, caller takes responsibility for the file, and it will not
231 // be removed once the URLFetcher is destroyed. User should not take 243 // be removed once the URLFetcher is destroyed. User should not take
232 // ownership more than once, or call this method after taking ownership. 244 // ownership more than once, or call this method after taking ownership.
233 virtual bool GetResponseAsFilePath(bool take_ownership, 245 virtual bool GetResponseAsFilePath(bool take_ownership,
234 FilePath* out_response_path) const = 0; 246 FilePath* out_response_path) const = 0;
235 }; 247 };
236 248
237 } // namespace content 249 } // namespace content
238 250
239 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ 251 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_
OLDNEW
« no previous file with comments | « content/common/net/url_fetcher_impl_unittest.cc ('k') | content/test/test_url_fetcher_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698