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

Side by Side Diff: google_apis/drive/drive_api_requests.cc

Issue 1138883004: Revert of Revert of Drive: Let DriveUploader use batch request API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 "google_apis/drive/drive_api_requests.h" 5 #include "google_apis/drive/drive_api_requests.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 child->request->RunCallbackOnPrematureFailure(result); 1204 child->request->RunCallbackOnPrematureFailure(result);
1205 sender_->RequestFinished(child->request); 1205 sender_->RequestFinished(child->request);
1206 child_requests_.erase(child); 1206 child_requests_.erase(child);
1207 } 1207 }
1208 MayCompletePrepare(); 1208 MayCompletePrepare();
1209 } 1209 }
1210 1210
1211 void BatchUploadRequest::Commit() { 1211 void BatchUploadRequest::Commit() {
1212 DCHECK(CalledOnValidThread()); 1212 DCHECK(CalledOnValidThread());
1213 DCHECK(!committed_); 1213 DCHECK(!committed_);
1214 CHECK(!child_requests_.empty()); 1214 if (child_requests_.empty()) {
1215 committed_ = true; 1215 Cancel();
1216 MayCompletePrepare(); 1216 } else {
1217 committed_ = true;
1218 MayCompletePrepare();
1219 }
1217 } 1220 }
1218 1221
1219 void BatchUploadRequest::Prepare(const PrepareCallback& callback) { 1222 void BatchUploadRequest::Prepare(const PrepareCallback& callback) {
1220 DCHECK(CalledOnValidThread()); 1223 DCHECK(CalledOnValidThread());
1221 DCHECK(!callback.is_null()); 1224 DCHECK(!callback.is_null());
1222 prepare_callback_ = callback; 1225 prepare_callback_ = callback;
1223 MayCompletePrepare(); 1226 MayCompletePrepare();
1224 } 1227 }
1225 1228
1226 void BatchUploadRequest::Cancel() { 1229 void BatchUploadRequest::Cancel() {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 void BatchUploadRequest::RunCallbackOnPrematureFailure(DriveApiErrorCode code) { 1347 void BatchUploadRequest::RunCallbackOnPrematureFailure(DriveApiErrorCode code) {
1345 for (auto child : child_requests_) { 1348 for (auto child : child_requests_) {
1346 child.request->RunCallbackOnPrematureFailure(code); 1349 child.request->RunCallbackOnPrematureFailure(code);
1347 sender_->RequestFinished(child.request); 1350 sender_->RequestFinished(child.request);
1348 } 1351 }
1349 child_requests_.clear(); 1352 child_requests_.clear();
1350 } 1353 }
1351 1354
1352 } // namespace drive 1355 } // namespace drive
1353 } // namespace google_apis 1356 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc ('k') | google_apis/drive/drive_api_requests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698