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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/google_apis/fake_drive_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/google_apis/fake_drive_service.h" 5 #include "chrome/browser/google_apis/fake_drive_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 base::Bind(callback, 909 base::Bind(callback,
910 UploadRangeResponse(HTTP_NOT_FOUND, 910 UploadRangeResponse(HTTP_NOT_FOUND,
911 start_position, 911 start_position,
912 end_position), 912 end_position),
913 base::Passed(&result_entry))); 913 base::Passed(&result_entry)));
914 return; 914 return;
915 } 915 }
916 916
917 entry->SetString("docs$size.$t", base::Int64ToString(end_position)); 917 entry->SetString("docs$size.$t", base::Int64ToString(end_position));
918 918
919 if (!progress_callback.is_null()) {
920 // In the real GDataWapi/Drive DriveService, progress is reported in
921 // nondeterministic timing. In this fake implementation, we choose to call
922 // it twice per one ResumeUpload. This is for making sure that client code
923 // works fine even if the callback is invoked more than once; it is the
924 // crucial difference of the progress callback from others.
925 int64 mid_position = start_position + (end_position - start_position) / 2;
926 MessageLoop::current()->PostTask(
927 FROM_HERE, base::Bind(progress_callback, mid_position));
928 MessageLoop::current()->PostTask(
929 FROM_HERE, base::Bind(progress_callback, end_position));
930 }
931
919 if (content_length != end_position) { 932 if (content_length != end_position) {
920 MessageLoop::current()->PostTask( 933 MessageLoop::current()->PostTask(
921 FROM_HERE, 934 FROM_HERE,
922 base::Bind(callback, 935 base::Bind(callback,
923 UploadRangeResponse(HTTP_RESUME_INCOMPLETE, 936 UploadRangeResponse(HTTP_RESUME_INCOMPLETE,
924 start_position, 937 start_position,
925 end_position), 938 end_position),
926 base::Passed(&result_entry))); 939 base::Passed(&result_entry)));
927 return; 940 return;
928 } 941 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 1321
1309 ++resource_list_load_count_; 1322 ++resource_list_load_count_;
1310 MessageLoop::current()->PostTask( 1323 MessageLoop::current()->PostTask(
1311 FROM_HERE, 1324 FROM_HERE,
1312 base::Bind(callback, 1325 base::Bind(callback,
1313 HTTP_SUCCESS, 1326 HTTP_SUCCESS,
1314 base::Passed(&resource_list))); 1327 base::Passed(&resource_list)));
1315 } 1328 }
1316 1329
1317 } // namespace google_apis 1330 } // namespace google_apis
OLDNEW
« 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