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 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
14 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
15 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 if (!file_resource) { | 71 if (!file_resource) { |
71 callback.Run( | 72 callback.Run( |
72 UploadRangeResponse(DRIVE_PARSE_ERROR, | 73 UploadRangeResponse(DRIVE_PARSE_ERROR, |
73 response.start_position_received, | 74 response.start_position_received, |
74 response.end_position_received), | 75 response.end_position_received), |
75 scoped_ptr<FileResource>()); | 76 scoped_ptr<FileResource>()); |
76 return; | 77 return; |
77 } | 78 } |
78 } | 79 } |
79 | 80 |
80 callback.Run(response, file_resource.Pass()); | 81 callback.Run(response, std::move(file_resource)); |
81 } | 82 } |
82 | 83 |
83 // Attaches |properties| to the |request_body| if |properties| is not empty. | 84 // Attaches |properties| to the |request_body| if |properties| is not empty. |
84 // |request_body| must not be NULL. | 85 // |request_body| must not be NULL. |
85 void AttachProperties(const Properties& properties, | 86 void AttachProperties(const Properties& properties, |
86 base::DictionaryValue* request_body) { | 87 base::DictionaryValue* request_body) { |
87 DCHECK(request_body); | 88 DCHECK(request_body); |
88 if (properties.empty()) | 89 if (properties.empty()) |
89 return; | 90 return; |
90 | 91 |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 progress_callback_(progress_callback) { | 943 progress_callback_(progress_callback) { |
943 DCHECK(!callback_.is_null()); | 944 DCHECK(!callback_.is_null()); |
944 } | 945 } |
945 | 946 |
946 ResumeUploadRequest::~ResumeUploadRequest() {} | 947 ResumeUploadRequest::~ResumeUploadRequest() {} |
947 | 948 |
948 void ResumeUploadRequest::OnRangeRequestComplete( | 949 void ResumeUploadRequest::OnRangeRequestComplete( |
949 const UploadRangeResponse& response, | 950 const UploadRangeResponse& response, |
950 scoped_ptr<base::Value> value) { | 951 scoped_ptr<base::Value> value) { |
951 DCHECK(CalledOnValidThread()); | 952 DCHECK(CalledOnValidThread()); |
952 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); | 953 ParseFileResourceWithUploadRangeAndRun(callback_, response, std::move(value)); |
953 } | 954 } |
954 | 955 |
955 void ResumeUploadRequest::OnURLFetchUploadProgress( | 956 void ResumeUploadRequest::OnURLFetchUploadProgress( |
956 const net::URLFetcher* source, | 957 const net::URLFetcher* source, |
957 int64_t current, | 958 int64_t current, |
958 int64_t total) { | 959 int64_t total) { |
959 if (!progress_callback_.is_null()) | 960 if (!progress_callback_.is_null()) |
960 progress_callback_.Run(current, total); | 961 progress_callback_.Run(current, total); |
961 } | 962 } |
962 | 963 |
963 //========================== GetUploadStatusRequest ========================== | 964 //========================== GetUploadStatusRequest ========================== |
964 | 965 |
965 GetUploadStatusRequest::GetUploadStatusRequest( | 966 GetUploadStatusRequest::GetUploadStatusRequest( |
966 RequestSender* sender, | 967 RequestSender* sender, |
967 const GURL& upload_url, | 968 const GURL& upload_url, |
968 int64_t content_length, | 969 int64_t content_length, |
969 const UploadRangeCallback& callback) | 970 const UploadRangeCallback& callback) |
970 : GetUploadStatusRequestBase(sender, upload_url, content_length), | 971 : GetUploadStatusRequestBase(sender, upload_url, content_length), |
971 callback_(callback) { | 972 callback_(callback) { |
972 DCHECK(!callback.is_null()); | 973 DCHECK(!callback.is_null()); |
973 } | 974 } |
974 | 975 |
975 GetUploadStatusRequest::~GetUploadStatusRequest() {} | 976 GetUploadStatusRequest::~GetUploadStatusRequest() {} |
976 | 977 |
977 void GetUploadStatusRequest::OnRangeRequestComplete( | 978 void GetUploadStatusRequest::OnRangeRequestComplete( |
978 const UploadRangeResponse& response, | 979 const UploadRangeResponse& response, |
979 scoped_ptr<base::Value> value) { | 980 scoped_ptr<base::Value> value) { |
980 DCHECK(CalledOnValidThread()); | 981 DCHECK(CalledOnValidThread()); |
981 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); | 982 ParseFileResourceWithUploadRangeAndRun(callback_, response, std::move(value)); |
982 } | 983 } |
983 | 984 |
984 //======================= MultipartUploadNewFileDelegate ======================= | 985 //======================= MultipartUploadNewFileDelegate ======================= |
985 | 986 |
986 MultipartUploadNewFileDelegate::MultipartUploadNewFileDelegate( | 987 MultipartUploadNewFileDelegate::MultipartUploadNewFileDelegate( |
987 base::SequencedTaskRunner* task_runner, | 988 base::SequencedTaskRunner* task_runner, |
988 const std::string& title, | 989 const std::string& title, |
989 const std::string& parent_resource_id, | 990 const std::string& parent_resource_id, |
990 const std::string& content_type, | 991 const std::string& content_type, |
991 int64_t content_length, | 992 int64_t content_length, |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 } else if (last_progress_value_ < child->data_offset + child->data_size && | 1454 } else if (last_progress_value_ < child->data_offset + child->data_size && |
1454 child->data_offset + child->data_size < current) { | 1455 child->data_offset + child->data_size < current) { |
1455 child->request->NotifyUploadProgress(source, child->data_size, | 1456 child->request->NotifyUploadProgress(source, child->data_size, |
1456 child->data_size); | 1457 child->data_size); |
1457 } | 1458 } |
1458 } | 1459 } |
1459 last_progress_value_ = current; | 1460 last_progress_value_ = current; |
1460 } | 1461 } |
1461 } // namespace drive | 1462 } // namespace drive |
1462 } // namespace google_apis | 1463 } // namespace google_apis |
OLD | NEW |