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

Unified Diff: chrome/browser/google_apis/fake_drive_service.cc

Issue 14215003: Add ProgressCallback to DriveServiceInterface::DownloadFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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/browser/google_apis/fake_drive_service.cc
diff --git a/chrome/browser/google_apis/fake_drive_service.cc b/chrome/browser/google_apis/fake_drive_service.cc
index fa364bbacb5f646d7be82e672ae8098eb13e4e6b..bd422cca3a6d9622b20960bd52e03804ac316e50 100644
--- a/chrome/browser/google_apis/fake_drive_service.cc
+++ b/chrome/browser/google_apis/fake_drive_service.cc
@@ -487,7 +487,8 @@ void FakeDriveService::DownloadFile(
const base::FilePath& local_cache_path,
const GURL& download_url,
const DownloadActionCallback& download_action_callback,
- const GetContentCallback& get_content_callback) {
+ const GetContentCallback& get_content_callback,
+ const ProgressCallback& progress_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!download_action_callback.is_null());
@@ -500,7 +501,7 @@ void FakeDriveService::DownloadFile(
return;
}
- // The field content.src is the URL to donwload the file.
+ // The field content.src is the URL to download the file.
base::DictionaryValue* entry = FindEntryByContentUrl(download_url);
if (!entry) {
base::MessageLoopProxy::current()->PostTask(
@@ -522,6 +523,17 @@ void FakeDriveService::DownloadFile(
file_util::WriteFile(local_cache_path,
content.data(),
content.size())) {
+ if (!progress_callback.is_null()) {
+ // See also the comment in ResumeUpload(). For testing that clients
+ // can handle the case progress_callback is called multiple times,
+ // here we invoke the callback twice.
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(progress_callback, file_size / 2, file_size));
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(progress_callback, file_size, file_size));
+ }
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(download_action_callback,
« no previous file with comments | « chrome/browser/google_apis/fake_drive_service.h ('k') | chrome/browser/google_apis/fake_drive_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698