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

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: _ 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.
Sam Kerner (Chrome) 2012/03/06 00:23:06 Add something like: // To save to a temporary pat
hashimoto 2012/03/06 10:16:01 Done.
174 virtual void SaveResponseToFile(
175 const FilePath& file_path,
176 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) = 0;
177
178 // 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(). 179 // response to a temporary file instead. Must be called before Start().
173 // |file_message_loop_proxy| will be used for all file operations. 180 // |file_message_loop_proxy| will be used for all file operations.
174 virtual void SaveResponseToTemporaryFile( 181 virtual void SaveResponseToTemporaryFile(
175 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) = 0; 182 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) = 0;
176 183
177 // Retrieve the response headers from the request. Must only be called after 184 // Retrieve the response headers from the request. Must only be called after
178 // the OnURLFetchComplete callback has run. 185 // the OnURLFetchComplete callback has run.
179 virtual net::HttpResponseHeaders* GetResponseHeaders() const = 0; 186 virtual net::HttpResponseHeaders* GetResponseHeaders() const = 0;
180 187
181 // Retrieve the remote socket address from the request. Must only 188 // Retrieve the remote socket address from the request. Must only
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 230
224 // Get the response as a string. Return false if the fetcher was not 231 // Get the response as a string. Return false if the fetcher was not
225 // set to store the response as a string. 232 // set to store the response as a string.
226 virtual bool GetResponseAsString(std::string* out_response_string) const = 0; 233 virtual bool GetResponseAsString(std::string* out_response_string) const = 0;
227 234
228 // Get the path to the file containing the response body. Returns false 235 // 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 236 // 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 237 // true, caller takes responsibility for the temp file, and it will not
231 // be removed once the URLFetcher is destroyed. User should not take 238 // be removed once the URLFetcher is destroyed. User should not take
232 // ownership more than once, or call this method after taking ownership. 239 // ownership more than once, or call this method after taking ownership.
233 virtual bool GetResponseAsFilePath(bool take_ownership, 240 virtual bool GetResponseAsFilePath(bool take_ownership,
Sam Kerner (Chrome) 2012/03/06 00:23:06 One tricky aspect of fetching a file is deleting i
hashimoto 2012/03/06 10:16:01 Good point, added comments for SaveResponseToFileA
Sam Kerner (Chrome) 2012/03/06 19:44:31 Sounds good to me. When I created his method, the
234 FilePath* out_response_path) const = 0; 241 FilePath* out_response_path) const = 0;
235 }; 242 };
236 243
237 } // namespace content 244 } // namespace content
238 245
239 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ 246 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698