| 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> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 10 #include "base/location.h" | 12 #include "base/location.h" |
| 11 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 13 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 14 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
| 16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 GURL ChildrenDeleteRequest::GetURL() const { | 796 GURL ChildrenDeleteRequest::GetURL() const { |
| 795 return url_generator_.GetChildrenDeleteUrl(child_id_, folder_id_); | 797 return url_generator_.GetChildrenDeleteUrl(child_id_, folder_id_); |
| 796 } | 798 } |
| 797 | 799 |
| 798 //======================= InitiateUploadNewFileRequest ======================= | 800 //======================= InitiateUploadNewFileRequest ======================= |
| 799 | 801 |
| 800 InitiateUploadNewFileRequest::InitiateUploadNewFileRequest( | 802 InitiateUploadNewFileRequest::InitiateUploadNewFileRequest( |
| 801 RequestSender* sender, | 803 RequestSender* sender, |
| 802 const DriveApiUrlGenerator& url_generator, | 804 const DriveApiUrlGenerator& url_generator, |
| 803 const std::string& content_type, | 805 const std::string& content_type, |
| 804 int64 content_length, | 806 int64_t content_length, |
| 805 const std::string& parent_resource_id, | 807 const std::string& parent_resource_id, |
| 806 const std::string& title, | 808 const std::string& title, |
| 807 const InitiateUploadCallback& callback) | 809 const InitiateUploadCallback& callback) |
| 808 : InitiateUploadRequestBase(sender, | 810 : InitiateUploadRequestBase(sender, callback, content_type, content_length), |
| 809 callback, | |
| 810 content_type, | |
| 811 content_length), | |
| 812 url_generator_(url_generator), | 811 url_generator_(url_generator), |
| 813 parent_resource_id_(parent_resource_id), | 812 parent_resource_id_(parent_resource_id), |
| 814 title_(title) { | 813 title_(title) {} |
| 815 } | |
| 816 | 814 |
| 817 InitiateUploadNewFileRequest::~InitiateUploadNewFileRequest() {} | 815 InitiateUploadNewFileRequest::~InitiateUploadNewFileRequest() {} |
| 818 | 816 |
| 819 GURL InitiateUploadNewFileRequest::GetURL() const { | 817 GURL InitiateUploadNewFileRequest::GetURL() const { |
| 820 return url_generator_.GetInitiateUploadNewFileUrl(!modified_date_.is_null()); | 818 return url_generator_.GetInitiateUploadNewFileUrl(!modified_date_.is_null()); |
| 821 } | 819 } |
| 822 | 820 |
| 823 net::URLFetcher::RequestType | 821 net::URLFetcher::RequestType |
| 824 InitiateUploadNewFileRequest::GetRequestType() const { | 822 InitiateUploadNewFileRequest::GetRequestType() const { |
| 825 return net::URLFetcher::POST; | 823 return net::URLFetcher::POST; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 853 << *upload_content << "]"; | 851 << *upload_content << "]"; |
| 854 return true; | 852 return true; |
| 855 } | 853 } |
| 856 | 854 |
| 857 //===================== InitiateUploadExistingFileRequest ==================== | 855 //===================== InitiateUploadExistingFileRequest ==================== |
| 858 | 856 |
| 859 InitiateUploadExistingFileRequest::InitiateUploadExistingFileRequest( | 857 InitiateUploadExistingFileRequest::InitiateUploadExistingFileRequest( |
| 860 RequestSender* sender, | 858 RequestSender* sender, |
| 861 const DriveApiUrlGenerator& url_generator, | 859 const DriveApiUrlGenerator& url_generator, |
| 862 const std::string& content_type, | 860 const std::string& content_type, |
| 863 int64 content_length, | 861 int64_t content_length, |
| 864 const std::string& resource_id, | 862 const std::string& resource_id, |
| 865 const std::string& etag, | 863 const std::string& etag, |
| 866 const InitiateUploadCallback& callback) | 864 const InitiateUploadCallback& callback) |
| 867 : InitiateUploadRequestBase(sender, | 865 : InitiateUploadRequestBase(sender, callback, content_type, content_length), |
| 868 callback, | |
| 869 content_type, | |
| 870 content_length), | |
| 871 url_generator_(url_generator), | 866 url_generator_(url_generator), |
| 872 resource_id_(resource_id), | 867 resource_id_(resource_id), |
| 873 etag_(etag) { | 868 etag_(etag) {} |
| 874 } | |
| 875 | 869 |
| 876 InitiateUploadExistingFileRequest::~InitiateUploadExistingFileRequest() {} | 870 InitiateUploadExistingFileRequest::~InitiateUploadExistingFileRequest() {} |
| 877 | 871 |
| 878 GURL InitiateUploadExistingFileRequest::GetURL() const { | 872 GURL InitiateUploadExistingFileRequest::GetURL() const { |
| 879 return url_generator_.GetInitiateUploadExistingFileUrl( | 873 return url_generator_.GetInitiateUploadExistingFileUrl( |
| 880 resource_id_, !modified_date_.is_null()); | 874 resource_id_, !modified_date_.is_null()); |
| 881 } | 875 } |
| 882 | 876 |
| 883 net::URLFetcher::RequestType | 877 net::URLFetcher::RequestType |
| 884 InitiateUploadExistingFileRequest::GetRequestType() const { | 878 InitiateUploadExistingFileRequest::GetRequestType() const { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 DVLOG(1) << "InitiateUploadExistingFile data: " << *upload_content_type | 917 DVLOG(1) << "InitiateUploadExistingFile data: " << *upload_content_type |
| 924 << ", [" << *upload_content << "]"; | 918 << ", [" << *upload_content << "]"; |
| 925 return true; | 919 return true; |
| 926 } | 920 } |
| 927 | 921 |
| 928 //============================ ResumeUploadRequest =========================== | 922 //============================ ResumeUploadRequest =========================== |
| 929 | 923 |
| 930 ResumeUploadRequest::ResumeUploadRequest( | 924 ResumeUploadRequest::ResumeUploadRequest( |
| 931 RequestSender* sender, | 925 RequestSender* sender, |
| 932 const GURL& upload_location, | 926 const GURL& upload_location, |
| 933 int64 start_position, | 927 int64_t start_position, |
| 934 int64 end_position, | 928 int64_t end_position, |
| 935 int64 content_length, | 929 int64_t content_length, |
| 936 const std::string& content_type, | 930 const std::string& content_type, |
| 937 const base::FilePath& local_file_path, | 931 const base::FilePath& local_file_path, |
| 938 const UploadRangeCallback& callback, | 932 const UploadRangeCallback& callback, |
| 939 const ProgressCallback& progress_callback) | 933 const ProgressCallback& progress_callback) |
| 940 : ResumeUploadRequestBase(sender, | 934 : ResumeUploadRequestBase(sender, |
| 941 upload_location, | 935 upload_location, |
| 942 start_position, | 936 start_position, |
| 943 end_position, | 937 end_position, |
| 944 content_length, | 938 content_length, |
| 945 content_type, | 939 content_type, |
| 946 local_file_path), | 940 local_file_path), |
| 947 callback_(callback), | 941 callback_(callback), |
| 948 progress_callback_(progress_callback) { | 942 progress_callback_(progress_callback) { |
| 949 DCHECK(!callback_.is_null()); | 943 DCHECK(!callback_.is_null()); |
| 950 } | 944 } |
| 951 | 945 |
| 952 ResumeUploadRequest::~ResumeUploadRequest() {} | 946 ResumeUploadRequest::~ResumeUploadRequest() {} |
| 953 | 947 |
| 954 void ResumeUploadRequest::OnRangeRequestComplete( | 948 void ResumeUploadRequest::OnRangeRequestComplete( |
| 955 const UploadRangeResponse& response, | 949 const UploadRangeResponse& response, |
| 956 scoped_ptr<base::Value> value) { | 950 scoped_ptr<base::Value> value) { |
| 957 DCHECK(CalledOnValidThread()); | 951 DCHECK(CalledOnValidThread()); |
| 958 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); | 952 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); |
| 959 } | 953 } |
| 960 | 954 |
| 961 void ResumeUploadRequest::OnURLFetchUploadProgress( | 955 void ResumeUploadRequest::OnURLFetchUploadProgress( |
| 962 const net::URLFetcher* source, int64 current, int64 total) { | 956 const net::URLFetcher* source, |
| 957 int64_t current, |
| 958 int64_t total) { |
| 963 if (!progress_callback_.is_null()) | 959 if (!progress_callback_.is_null()) |
| 964 progress_callback_.Run(current, total); | 960 progress_callback_.Run(current, total); |
| 965 } | 961 } |
| 966 | 962 |
| 967 //========================== GetUploadStatusRequest ========================== | 963 //========================== GetUploadStatusRequest ========================== |
| 968 | 964 |
| 969 GetUploadStatusRequest::GetUploadStatusRequest( | 965 GetUploadStatusRequest::GetUploadStatusRequest( |
| 970 RequestSender* sender, | 966 RequestSender* sender, |
| 971 const GURL& upload_url, | 967 const GURL& upload_url, |
| 972 int64 content_length, | 968 int64_t content_length, |
| 973 const UploadRangeCallback& callback) | 969 const UploadRangeCallback& callback) |
| 974 : GetUploadStatusRequestBase(sender, | 970 : GetUploadStatusRequestBase(sender, upload_url, content_length), |
| 975 upload_url, | |
| 976 content_length), | |
| 977 callback_(callback) { | 971 callback_(callback) { |
| 978 DCHECK(!callback.is_null()); | 972 DCHECK(!callback.is_null()); |
| 979 } | 973 } |
| 980 | 974 |
| 981 GetUploadStatusRequest::~GetUploadStatusRequest() {} | 975 GetUploadStatusRequest::~GetUploadStatusRequest() {} |
| 982 | 976 |
| 983 void GetUploadStatusRequest::OnRangeRequestComplete( | 977 void GetUploadStatusRequest::OnRangeRequestComplete( |
| 984 const UploadRangeResponse& response, | 978 const UploadRangeResponse& response, |
| 985 scoped_ptr<base::Value> value) { | 979 scoped_ptr<base::Value> value) { |
| 986 DCHECK(CalledOnValidThread()); | 980 DCHECK(CalledOnValidThread()); |
| 987 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); | 981 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); |
| 988 } | 982 } |
| 989 | 983 |
| 990 //======================= MultipartUploadNewFileDelegate ======================= | 984 //======================= MultipartUploadNewFileDelegate ======================= |
| 991 | 985 |
| 992 MultipartUploadNewFileDelegate::MultipartUploadNewFileDelegate( | 986 MultipartUploadNewFileDelegate::MultipartUploadNewFileDelegate( |
| 993 base::SequencedTaskRunner* task_runner, | 987 base::SequencedTaskRunner* task_runner, |
| 994 const std::string& title, | 988 const std::string& title, |
| 995 const std::string& parent_resource_id, | 989 const std::string& parent_resource_id, |
| 996 const std::string& content_type, | 990 const std::string& content_type, |
| 997 int64 content_length, | 991 int64_t content_length, |
| 998 const base::Time& modified_date, | 992 const base::Time& modified_date, |
| 999 const base::Time& last_viewed_by_me_date, | 993 const base::Time& last_viewed_by_me_date, |
| 1000 const base::FilePath& local_file_path, | 994 const base::FilePath& local_file_path, |
| 1001 const Properties& properties, | 995 const Properties& properties, |
| 1002 const DriveApiUrlGenerator& url_generator, | 996 const DriveApiUrlGenerator& url_generator, |
| 1003 const FileResourceCallback& callback, | 997 const FileResourceCallback& callback, |
| 1004 const ProgressCallback& progress_callback) | 998 const ProgressCallback& progress_callback) |
| 1005 : MultipartUploadRequestBase( | 999 : MultipartUploadRequestBase( |
| 1006 task_runner, | 1000 task_runner, |
| 1007 CreateMultipartUploadMetadataJson(title, | 1001 CreateMultipartUploadMetadataJson(title, |
| 1008 parent_resource_id, | 1002 parent_resource_id, |
| 1009 modified_date, | 1003 modified_date, |
| 1010 last_viewed_by_me_date, | 1004 last_viewed_by_me_date, |
| 1011 properties), | 1005 properties), |
| 1012 content_type, | 1006 content_type, |
| 1013 content_length, | 1007 content_length, |
| 1014 local_file_path, | 1008 local_file_path, |
| 1015 callback, | 1009 callback, |
| 1016 progress_callback), | 1010 progress_callback), |
| 1017 has_modified_date_(!modified_date.is_null()), | 1011 has_modified_date_(!modified_date.is_null()), |
| 1018 url_generator_(url_generator) { | 1012 url_generator_(url_generator) {} |
| 1019 } | |
| 1020 | 1013 |
| 1021 MultipartUploadNewFileDelegate::~MultipartUploadNewFileDelegate() { | 1014 MultipartUploadNewFileDelegate::~MultipartUploadNewFileDelegate() { |
| 1022 } | 1015 } |
| 1023 | 1016 |
| 1024 GURL MultipartUploadNewFileDelegate::GetURL() const { | 1017 GURL MultipartUploadNewFileDelegate::GetURL() const { |
| 1025 return url_generator_.GetMultipartUploadNewFileUrl(has_modified_date_); | 1018 return url_generator_.GetMultipartUploadNewFileUrl(has_modified_date_); |
| 1026 } | 1019 } |
| 1027 | 1020 |
| 1028 net::URLFetcher::RequestType MultipartUploadNewFileDelegate::GetRequestType() | 1021 net::URLFetcher::RequestType MultipartUploadNewFileDelegate::GetRequestType() |
| 1029 const { | 1022 const { |
| 1030 return net::URLFetcher::POST; | 1023 return net::URLFetcher::POST; |
| 1031 } | 1024 } |
| 1032 | 1025 |
| 1033 //====================== MultipartUploadExistingFileDelegate =================== | 1026 //====================== MultipartUploadExistingFileDelegate =================== |
| 1034 | 1027 |
| 1035 MultipartUploadExistingFileDelegate::MultipartUploadExistingFileDelegate( | 1028 MultipartUploadExistingFileDelegate::MultipartUploadExistingFileDelegate( |
| 1036 base::SequencedTaskRunner* task_runner, | 1029 base::SequencedTaskRunner* task_runner, |
| 1037 const std::string& title, | 1030 const std::string& title, |
| 1038 const std::string& resource_id, | 1031 const std::string& resource_id, |
| 1039 const std::string& parent_resource_id, | 1032 const std::string& parent_resource_id, |
| 1040 const std::string& content_type, | 1033 const std::string& content_type, |
| 1041 int64 content_length, | 1034 int64_t content_length, |
| 1042 const base::Time& modified_date, | 1035 const base::Time& modified_date, |
| 1043 const base::Time& last_viewed_by_me_date, | 1036 const base::Time& last_viewed_by_me_date, |
| 1044 const base::FilePath& local_file_path, | 1037 const base::FilePath& local_file_path, |
| 1045 const std::string& etag, | 1038 const std::string& etag, |
| 1046 const Properties& properties, | 1039 const Properties& properties, |
| 1047 const DriveApiUrlGenerator& url_generator, | 1040 const DriveApiUrlGenerator& url_generator, |
| 1048 const FileResourceCallback& callback, | 1041 const FileResourceCallback& callback, |
| 1049 const ProgressCallback& progress_callback) | 1042 const ProgressCallback& progress_callback) |
| 1050 : MultipartUploadRequestBase( | 1043 : MultipartUploadRequestBase( |
| 1051 task_runner, | 1044 task_runner, |
| 1052 CreateMultipartUploadMetadataJson(title, | 1045 CreateMultipartUploadMetadataJson(title, |
| 1053 parent_resource_id, | 1046 parent_resource_id, |
| 1054 modified_date, | 1047 modified_date, |
| 1055 last_viewed_by_me_date, | 1048 last_viewed_by_me_date, |
| 1056 properties), | 1049 properties), |
| 1057 content_type, | 1050 content_type, |
| 1058 content_length, | 1051 content_length, |
| 1059 local_file_path, | 1052 local_file_path, |
| 1060 callback, | 1053 callback, |
| 1061 progress_callback), | 1054 progress_callback), |
| 1062 resource_id_(resource_id), | 1055 resource_id_(resource_id), |
| 1063 etag_(etag), | 1056 etag_(etag), |
| 1064 has_modified_date_(!modified_date.is_null()), | 1057 has_modified_date_(!modified_date.is_null()), |
| 1065 url_generator_(url_generator) { | 1058 url_generator_(url_generator) {} |
| 1066 } | |
| 1067 | 1059 |
| 1068 MultipartUploadExistingFileDelegate::~MultipartUploadExistingFileDelegate() { | 1060 MultipartUploadExistingFileDelegate::~MultipartUploadExistingFileDelegate() { |
| 1069 } | 1061 } |
| 1070 | 1062 |
| 1071 std::vector<std::string> | 1063 std::vector<std::string> |
| 1072 MultipartUploadExistingFileDelegate::GetExtraRequestHeaders() const { | 1064 MultipartUploadExistingFileDelegate::GetExtraRequestHeaders() const { |
| 1073 std::vector<std::string> headers( | 1065 std::vector<std::string> headers( |
| 1074 MultipartUploadRequestBase::GetExtraRequestHeaders()); | 1066 MultipartUploadRequestBase::GetExtraRequestHeaders()); |
| 1075 headers.push_back(util::GenerateIfMatchHeader(etag_)); | 1067 headers.push_back(util::GenerateIfMatchHeader(etag_)); |
| 1076 return headers; | 1068 return headers; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 weak_ptr_factory_.GetWeakPtr())); | 1213 weak_ptr_factory_.GetWeakPtr())); |
| 1222 } | 1214 } |
| 1223 | 1215 |
| 1224 void SingleBatchableDelegateRequest::RunCallbackOnPrematureFailure( | 1216 void SingleBatchableDelegateRequest::RunCallbackOnPrematureFailure( |
| 1225 DriveApiErrorCode code) { | 1217 DriveApiErrorCode code) { |
| 1226 delegate_->NotifyError(code); | 1218 delegate_->NotifyError(code); |
| 1227 } | 1219 } |
| 1228 | 1220 |
| 1229 void SingleBatchableDelegateRequest::OnURLFetchUploadProgress( | 1221 void SingleBatchableDelegateRequest::OnURLFetchUploadProgress( |
| 1230 const net::URLFetcher* source, | 1222 const net::URLFetcher* source, |
| 1231 int64 current, | 1223 int64_t current, |
| 1232 int64 total) { | 1224 int64_t total) { |
| 1233 delegate_->NotifyUploadProgress(source, current, total); | 1225 delegate_->NotifyUploadProgress(source, current, total); |
| 1234 } | 1226 } |
| 1235 | 1227 |
| 1236 //========================== BatchUploadRequest ========================== | 1228 //========================== BatchUploadRequest ========================== |
| 1237 | 1229 |
| 1238 BatchUploadChildEntry::BatchUploadChildEntry(BatchableDelegate* request) | 1230 BatchUploadChildEntry::BatchUploadChildEntry(BatchableDelegate* request) |
| 1239 : request(request), prepared(false), data_offset(0), data_size(0) { | 1231 : request(request), prepared(false), data_offset(0), data_size(0) { |
| 1240 } | 1232 } |
| 1241 | 1233 |
| 1242 BatchUploadChildEntry::~BatchUploadChildEntry() { | 1234 BatchUploadChildEntry::~BatchUploadChildEntry() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 | 1312 |
| 1321 void BatchUploadRequest::MayCompletePrepare() { | 1313 void BatchUploadRequest::MayCompletePrepare() { |
| 1322 if (!committed_ || prepare_callback_.is_null()) | 1314 if (!committed_ || prepare_callback_.is_null()) |
| 1323 return; | 1315 return; |
| 1324 for (const auto& child : child_requests_) { | 1316 for (const auto& child : child_requests_) { |
| 1325 if (!child->prepared) | 1317 if (!child->prepared) |
| 1326 return; | 1318 return; |
| 1327 } | 1319 } |
| 1328 | 1320 |
| 1329 // Build multipart body here. | 1321 // Build multipart body here. |
| 1330 int64 total_size = 0; | 1322 int64_t total_size = 0; |
| 1331 std::vector<ContentTypeAndData> parts; | 1323 std::vector<ContentTypeAndData> parts; |
| 1332 for (auto& child : child_requests_) { | 1324 for (auto& child : child_requests_) { |
| 1333 std::string type; | 1325 std::string type; |
| 1334 std::string data; | 1326 std::string data; |
| 1335 const bool result = child->request->GetContentData(&type, &data); | 1327 const bool result = child->request->GetContentData(&type, &data); |
| 1336 // Upload request must have content data. | 1328 // Upload request must have content data. |
| 1337 DCHECK(result); | 1329 DCHECK(result); |
| 1338 | 1330 |
| 1339 const GURL url = child->request->GetURL(); | 1331 const GURL url = child->request->GetURL(); |
| 1340 std::string method; | 1332 std::string method; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1360 parts.push_back(ContentTypeAndData()); | 1352 parts.push_back(ContentTypeAndData()); |
| 1361 parts.back().type = kHttpContentType; | 1353 parts.back().type = kHttpContentType; |
| 1362 parts.back().data = header; | 1354 parts.back().data = header; |
| 1363 parts.back().data.append(data); | 1355 parts.back().data.append(data); |
| 1364 } | 1356 } |
| 1365 | 1357 |
| 1366 UMA_HISTOGRAM_COUNTS_100(kUMADriveTotalFileCountInBatchUpload, parts.size()); | 1358 UMA_HISTOGRAM_COUNTS_100(kUMADriveTotalFileCountInBatchUpload, parts.size()); |
| 1367 UMA_HISTOGRAM_MEMORY_KB(kUMADriveTotalFileSizeInBatchUpload, | 1359 UMA_HISTOGRAM_MEMORY_KB(kUMADriveTotalFileSizeInBatchUpload, |
| 1368 total_size / 1024); | 1360 total_size / 1024); |
| 1369 | 1361 |
| 1370 std::vector<uint64> part_data_offset; | 1362 std::vector<uint64_t> part_data_offset; |
| 1371 GenerateMultipartBody(MULTIPART_MIXED, boundary_, parts, &upload_content_, | 1363 GenerateMultipartBody(MULTIPART_MIXED, boundary_, parts, &upload_content_, |
| 1372 &part_data_offset); | 1364 &part_data_offset); |
| 1373 DCHECK(part_data_offset.size() == child_requests_.size()); | 1365 DCHECK(part_data_offset.size() == child_requests_.size()); |
| 1374 for (size_t i = 0; i < child_requests_.size(); ++i) { | 1366 for (size_t i = 0; i < child_requests_.size(); ++i) { |
| 1375 child_requests_[i]->data_offset += part_data_offset[i]; | 1367 child_requests_[i]->data_offset += part_data_offset[i]; |
| 1376 } | 1368 } |
| 1377 prepare_callback_.Run(HTTP_SUCCESS); | 1369 prepare_callback_.Run(HTTP_SUCCESS); |
| 1378 } | 1370 } |
| 1379 | 1371 |
| 1380 bool BatchUploadRequest::GetContentData(std::string* upload_content_type, | 1372 bool BatchUploadRequest::GetContentData(std::string* upload_content_type, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 } | 1436 } |
| 1445 | 1437 |
| 1446 void BatchUploadRequest::RunCallbackOnPrematureFailure(DriveApiErrorCode code) { | 1438 void BatchUploadRequest::RunCallbackOnPrematureFailure(DriveApiErrorCode code) { |
| 1447 for (auto child : child_requests_) { | 1439 for (auto child : child_requests_) { |
| 1448 child->request->NotifyError(code); | 1440 child->request->NotifyError(code); |
| 1449 } | 1441 } |
| 1450 child_requests_.clear(); | 1442 child_requests_.clear(); |
| 1451 } | 1443 } |
| 1452 | 1444 |
| 1453 void BatchUploadRequest::OnURLFetchUploadProgress(const net::URLFetcher* source, | 1445 void BatchUploadRequest::OnURLFetchUploadProgress(const net::URLFetcher* source, |
| 1454 int64 current, | 1446 int64_t current, |
| 1455 int64 total) { | 1447 int64_t total) { |
| 1456 for (auto child : child_requests_) { | 1448 for (auto child : child_requests_) { |
| 1457 if (child->data_offset <= current && | 1449 if (child->data_offset <= current && |
| 1458 current <= child->data_offset + child->data_size) { | 1450 current <= child->data_offset + child->data_size) { |
| 1459 child->request->NotifyUploadProgress(source, current - child->data_offset, | 1451 child->request->NotifyUploadProgress(source, current - child->data_offset, |
| 1460 child->data_size); | 1452 child->data_size); |
| 1461 } else if (last_progress_value_ < child->data_offset + child->data_size && | 1453 } else if (last_progress_value_ < child->data_offset + child->data_size && |
| 1462 child->data_offset + child->data_size < current) { | 1454 child->data_offset + child->data_size < current) { |
| 1463 child->request->NotifyUploadProgress(source, child->data_size, | 1455 child->request->NotifyUploadProgress(source, child->data_size, |
| 1464 child->data_size); | 1456 child->data_size); |
| 1465 } | 1457 } |
| 1466 } | 1458 } |
| 1467 last_progress_value_ = current; | 1459 last_progress_value_ = current; |
| 1468 } | 1460 } |
| 1469 } // namespace drive | 1461 } // namespace drive |
| 1470 } // namespace google_apis | 1462 } // namespace google_apis |
| OLD | NEW |