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

Unified Diff: chrome/common/net/url_fetcher.h

Issue 6904057: Schetch changes required to support URLFetcher saving response to a file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/net/url_fetcher.h
diff --git a/chrome/common/net/url_fetcher.h b/chrome/common/net/url_fetcher.h
index 3ed0e6491c1fdf81394df470874f585927d8ebca..bf2648ca4c6a9c6c1aff76b7c901fe89ef718922 100644
--- a/chrome/common/net/url_fetcher.h
+++ b/chrome/common/net/url_fetcher.h
@@ -67,12 +67,36 @@ class URLFetcher {
HEAD,
};
+ // Abstract class used to hold the response body. Delegate generates
+ // an implementation of this interface, and gets a pointer to it when
+ // the fetch is complete.
+ class ResponseBodyContainerInterface {
+ public:
+ // Add bytes to the response body.
+ virtual void Append(char* data, int data_length) = 0;
+
+ // If the class supports returning the body as a string, return true
+ // and set |out_body| to the response body. Otherwise, return false.
+ virtual bool GetAsString(std::string* out_body) const = 0;
+ };
+
class Delegate {
public:
// This will be called when the URL has been fetched, successfully or not.
// |response_code| is the HTTP response code (200, 404, etc.) if
// applicable. |url|, |status| and |data| are all valid until the
// URLFetcher instance is destroyed.
+ virtual void OnURLFetchCompleteNew(
+ const URLFetcher* source,
+ const GURL& url,
+ const net::URLRequestStatus& status,
+ int response_code,
+ const ResponseCookies& cookies,
+ const ResponseBodyContainerInterface& response_body);
+
+ // TODO(skerner): To avoid changing existing code, keep the old
+ // method, whre |data| is a string. Once we finalize interface changes,
+ // this will be removed.
virtual void OnURLFetchComplete(const URLFetcher* source,
const GURL& url,
const net::URLRequestStatus& status,
@@ -80,6 +104,13 @@ class URLFetcher {
const ResponseCookies& cookies,
const std::string& data) = 0;
+ // Get a container into which the response body can be written.
+ // Delegate can control how response is held by the choice of the
+ // concrete type this method returns. For example, to process the
+ // response body as it is received, return a class that does
+ // processing on each call to ResponseBodyContainerInterface::Append().
+ virtual ResponseBodyContainerInterface* CreateResponseBodyContainer();
+
protected:
virtual ~Delegate() {}
};

Powered by Google App Engine
This is Rietveld 408576698