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

Unified Diff: chrome/browser/google_apis/base_operations.h

Issue 12088104: Move DownloadFileOperation to base_operations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@b148627_download_file_3_test_util
Patch Set: Rebase Created 7 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/google_apis/base_operations.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/base_operations.h
diff --git a/chrome/browser/google_apis/base_operations.h b/chrome/browser/google_apis/base_operations.h
index e2cc58300515531c529e8c96818a795479d6d3ca..c5adfb38fbce0f2253e815c66fb22c1ee9f300d8 100644
--- a/chrome/browser/google_apis/base_operations.h
+++ b/chrome/browser/google_apis/base_operations.h
@@ -258,6 +258,65 @@ class GetDataOperation : public UrlFetchOperationBase {
DISALLOW_COPY_AND_ASSIGN(GetDataOperation);
};
+//============================ DownloadFileOperation ===========================
+
+// Callback type for DownloadHostedDocument/DownloadFile
+// DocumentServiceInterface calls.
+typedef base::Callback<void(GDataErrorCode error,
+ const FilePath& temp_file)> DownloadActionCallback;
+
+// This class performs the operation for downloading of a given document/file.
+class DownloadFileOperation : public UrlFetchOperationBase {
+ public:
+ // download_action_callback:
+ // This callback is called when the download is complete. Must not be null.
+ //
+ // get_content_callback:
+ // This callback is called when some part of the content is
+ // read. Used to read the download content progressively. May be null.
+ //
+ // download_url:
+ // Specifies the target file to download.
+ //
+ // drive_file_path:
+ // Specifies the drive path of the target file. Shown in UI.
+ // TODO(satorux): Remove the drive file path hack. crbug.com/163296
+ //
+ // output_file_path:
+ // Specifies the file path to save the downloaded file.
+ //
+ DownloadFileOperation(
+ OperationRegistry* registry,
+ net::URLRequestContextGetter* url_request_context_getter,
+ const DownloadActionCallback& download_action_callback,
+ const GetContentCallback& get_content_callback,
+ const GURL& download_url,
+ const FilePath& drive_file_path,
+ const FilePath& output_file_path);
+ virtual ~DownloadFileOperation();
+
+ protected:
+ // UrlFetchOperationBase overrides.
+ virtual GURL GetURL() const OVERRIDE;
+ virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
+ virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
+
+ // net::URLFetcherDelegate overrides.
+ virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source,
+ int64 current, int64 total) OVERRIDE;
+ virtual bool ShouldSendDownloadData() OVERRIDE;
+ virtual void OnURLFetchDownloadData(
+ const net::URLFetcher* source,
+ scoped_ptr<std::string> download_data) OVERRIDE;
+
+ private:
+ const DownloadActionCallback download_action_callback_;
+ const GetContentCallback get_content_callback_;
+ const GURL download_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation);
+};
+
} // namespace google_apis
#endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_
« no previous file with comments | « no previous file | chrome/browser/google_apis/base_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698