OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 for (auto it = child_requests_.begin(); it != child_requests_.end(); ++it) { | 1275 for (auto it = child_requests_.begin(); it != child_requests_.end(); ++it) { |
1276 if ((*it)->request.get() == request_id) | 1276 if ((*it)->request.get() == request_id) |
1277 return it; | 1277 return it; |
1278 } | 1278 } |
1279 return child_requests_.end(); | 1279 return child_requests_.end(); |
1280 } | 1280 } |
1281 | 1281 |
1282 void BatchUploadRequest::MayCompletePrepare() { | 1282 void BatchUploadRequest::MayCompletePrepare() { |
1283 if (!committed_ || prepare_callback_.is_null()) | 1283 if (!committed_ || prepare_callback_.is_null()) |
1284 return; | 1284 return; |
1285 for (const auto& child : child_requests_) { | 1285 for (auto* child : child_requests_) { |
1286 if (!child->prepared) | 1286 if (!child->prepared) |
1287 return; | 1287 return; |
1288 } | 1288 } |
1289 | 1289 |
1290 // Build multipart body here. | 1290 // Build multipart body here. |
1291 int64_t total_size = 0; | 1291 int64_t total_size = 0; |
1292 std::vector<ContentTypeAndData> parts; | 1292 std::vector<ContentTypeAndData> parts; |
1293 for (auto& child : child_requests_) { | 1293 for (auto* child : child_requests_) { |
1294 std::string type; | 1294 std::string type; |
1295 std::string data; | 1295 std::string data; |
1296 const bool result = child->request->GetContentData(&type, &data); | 1296 const bool result = child->request->GetContentData(&type, &data); |
1297 // Upload request must have content data. | 1297 // Upload request must have content data. |
1298 DCHECK(result); | 1298 DCHECK(result); |
1299 | 1299 |
1300 const GURL url = child->request->GetURL(); | 1300 const GURL url = child->request->GetURL(); |
1301 std::string method; | 1301 std::string method; |
1302 switch (child->request->GetRequestType()) { | 1302 switch (child->request->GetRequestType()) { |
1303 case net::URLFetcher::POST: | 1303 case net::URLFetcher::POST: |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 delegate->NotifyResult(parts[i].code, parts[i].body, | 1395 delegate->NotifyResult(parts[i].code, parts[i].body, |
1396 base::Bind(&base::DeletePointer<BatchableDelegate>, | 1396 base::Bind(&base::DeletePointer<BatchableDelegate>, |
1397 child_requests_[i]->request.release())); | 1397 child_requests_[i]->request.release())); |
1398 } | 1398 } |
1399 child_requests_.clear(); | 1399 child_requests_.clear(); |
1400 | 1400 |
1401 sender_->RequestFinished(this); | 1401 sender_->RequestFinished(this); |
1402 } | 1402 } |
1403 | 1403 |
1404 void BatchUploadRequest::RunCallbackOnPrematureFailure(DriveApiErrorCode code) { | 1404 void BatchUploadRequest::RunCallbackOnPrematureFailure(DriveApiErrorCode code) { |
1405 for (auto& child : child_requests_) | 1405 for (auto* child : child_requests_) |
1406 child->request->NotifyError(code); | 1406 child->request->NotifyError(code); |
1407 child_requests_.clear(); | 1407 child_requests_.clear(); |
1408 } | 1408 } |
1409 | 1409 |
1410 void BatchUploadRequest::OnURLFetchUploadProgress(const net::URLFetcher* source, | 1410 void BatchUploadRequest::OnURLFetchUploadProgress(const net::URLFetcher* source, |
1411 int64_t current, | 1411 int64_t current, |
1412 int64_t total) { | 1412 int64_t total) { |
1413 for (auto& child : child_requests_) { | 1413 for (auto* child : child_requests_) { |
1414 if (child->data_offset <= current && | 1414 if (child->data_offset <= current && |
1415 current <= child->data_offset + child->data_size) { | 1415 current <= child->data_offset + child->data_size) { |
1416 child->request->NotifyUploadProgress(source, current - child->data_offset, | 1416 child->request->NotifyUploadProgress(source, current - child->data_offset, |
1417 child->data_size); | 1417 child->data_size); |
1418 } else if (last_progress_value_ < child->data_offset + child->data_size && | 1418 } else if (last_progress_value_ < child->data_offset + child->data_size && |
1419 child->data_offset + child->data_size < current) { | 1419 child->data_offset + child->data_size < current) { |
1420 child->request->NotifyUploadProgress(source, child->data_size, | 1420 child->request->NotifyUploadProgress(source, child->data_size, |
1421 child->data_size); | 1421 child->data_size); |
1422 } | 1422 } |
1423 } | 1423 } |
1424 last_progress_value_ = current; | 1424 last_progress_value_ = current; |
1425 } | 1425 } |
1426 } // namespace drive | 1426 } // namespace drive |
1427 } // namespace google_apis | 1427 } // namespace google_apis |
OLD | NEW |