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

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

Issue 13941004: Implement upload progress reporting in FakeDriveSerivice. (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
« no previous file with comments | « no previous file | chrome/browser/google_apis/fake_drive_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8e55f45fd8b1e480d7a2cddd29d2e2c135c560e5..f5d6ba606758e81d88fee39a8f0aebe29c6e431a 100644
--- a/chrome/browser/google_apis/fake_drive_service.cc
+++ b/chrome/browser/google_apis/fake_drive_service.cc
@@ -916,6 +916,19 @@ void FakeDriveService::ResumeUpload(
entry->SetString("docs$size.$t", base::Int64ToString(end_position));
+ if (!progress_callback.is_null()) {
+ // In the real GDataWapi/Drive DriveService, progress is reported in
+ // nondeterministic timing. In this fake implementation, we choose to call
+ // it twice per one ResumeUpload. This is for making sure that client code
+ // works fine even if the callback is invoked more than once; it is the
+ // crucial difference of the progress callback from others.
+ int64 mid_position = start_position + (end_position - start_position) / 2;
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(progress_callback, mid_position));
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(progress_callback, end_position));
+ }
+
if (content_length != end_position) {
MessageLoop::current()->PostTask(
FROM_HERE,
« no previous file with comments | « no previous file | chrome/browser/google_apis/fake_drive_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698