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 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 5 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
6 #define GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 6 #define GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 std::string value_; | 1107 std::string value_; |
1108 | 1108 |
1109 DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest); | 1109 DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest); |
1110 }; | 1110 }; |
1111 | 1111 |
1112 //========================== BatchUploadRequest ========================== | 1112 //========================== BatchUploadRequest ========================== |
1113 | 1113 |
1114 struct BatchUploadChildEntry { | 1114 struct BatchUploadChildEntry { |
1115 BatchUploadChildEntry() : request(NULL), prepared(false) {} | 1115 BatchUploadChildEntry() : request(NULL), prepared(false) {} |
1116 explicit BatchUploadChildEntry(BatchableRequestBase* request) | 1116 explicit BatchUploadChildEntry(BatchableRequestBase* request) |
1117 : request(request), prepared(false) {} | 1117 : request(request), prepared(false), data_offset(0), data_size(0) {} |
1118 BatchableRequestBase* request; | 1118 BatchableRequestBase* request; |
1119 bool prepared; | 1119 bool prepared; |
| 1120 int64 data_offset; |
| 1121 int64 data_size; |
1120 }; | 1122 }; |
1121 | 1123 |
1122 class BatchUploadRequest : public UrlFetchRequestBase { | 1124 class BatchUploadRequest : public UrlFetchRequestBase { |
1123 public: | 1125 public: |
1124 BatchUploadRequest(RequestSender* sender, | 1126 BatchUploadRequest(RequestSender* sender, |
1125 const DriveApiUrlGenerator& url_generator); | 1127 const DriveApiUrlGenerator& url_generator); |
1126 ~BatchUploadRequest() override; | 1128 ~BatchUploadRequest() override; |
1127 | 1129 |
1128 // Adds request to the batch request. | 1130 // Adds request to the batch request. |
1129 void AddRequest(BatchableRequestBase* request); | 1131 void AddRequest(BatchableRequestBase* request); |
(...skipping 18 matching lines...) Expand all Loading... |
1148 void Prepare(const PrepareCallback& callback) override; | 1150 void Prepare(const PrepareCallback& callback) override; |
1149 void Cancel() override; | 1151 void Cancel() override; |
1150 GURL GetURL() const override; | 1152 GURL GetURL() const override; |
1151 net::URLFetcher::RequestType GetRequestType() const override; | 1153 net::URLFetcher::RequestType GetRequestType() const override; |
1152 std::vector<std::string> GetExtraRequestHeaders() const override; | 1154 std::vector<std::string> GetExtraRequestHeaders() const override; |
1153 bool GetContentData(std::string* upload_content_type, | 1155 bool GetContentData(std::string* upload_content_type, |
1154 std::string* upload_content) override; | 1156 std::string* upload_content) override; |
1155 void ProcessURLFetchResults(const net::URLFetcher* source) override; | 1157 void ProcessURLFetchResults(const net::URLFetcher* source) override; |
1156 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override; | 1158 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override; |
1157 | 1159 |
| 1160 // content::UrlFetcherDelegate overrides. |
| 1161 void OnURLFetchUploadProgress(const net::URLFetcher* source, |
| 1162 int64 current, |
| 1163 int64 total) override; |
| 1164 |
1158 private: | 1165 private: |
1159 typedef void* RequestID; | 1166 typedef void* RequestID; |
1160 // Obtains corresponding child entry of |request_id|. Returns NULL if the | 1167 // Obtains corresponding child entry of |request_id|. Returns NULL if the |
1161 // entry is not found. | 1168 // entry is not found. |
1162 std::vector<BatchUploadChildEntry>::iterator GetChildEntry( | 1169 std::vector<BatchUploadChildEntry>::iterator GetChildEntry( |
1163 RequestID request_id); | 1170 RequestID request_id); |
1164 | 1171 |
1165 // Called after child requests' |Prepare| method. | 1172 // Called after child requests' |Prepare| method. |
1166 void OnChildRequestPrepared(RequestID request_id, DriveApiErrorCode result); | 1173 void OnChildRequestPrepared(RequestID request_id, DriveApiErrorCode result); |
1167 | 1174 |
1168 // Complete |Prepare| if possible. | 1175 // Complete |Prepare| if possible. |
1169 void MayCompletePrepare(); | 1176 void MayCompletePrepare(); |
1170 | 1177 |
1171 // Process result for each child. | 1178 // Process result for each child. |
1172 void ProcessURLFetchResultsForChild(RequestID id, const std::string& body); | 1179 void ProcessURLFetchResultsForChild(RequestID id, const std::string& body); |
1173 | 1180 |
1174 RequestSender* const sender_; | 1181 RequestSender* const sender_; |
1175 const DriveApiUrlGenerator url_generator_; | 1182 const DriveApiUrlGenerator url_generator_; |
1176 std::vector<BatchUploadChildEntry> child_requests_; | 1183 std::vector<BatchUploadChildEntry> child_requests_; |
1177 | 1184 |
1178 PrepareCallback prepare_callback_; | 1185 PrepareCallback prepare_callback_; |
1179 bool committed_; | 1186 bool committed_; |
1180 | 1187 |
1181 // Boundary of multipart body. | 1188 // Boundary of multipart body. |
1182 std::string boundary_; | 1189 std::string boundary_; |
1183 | 1190 |
1184 // Multipart of child requests. | 1191 // Multipart of child requests. |
1185 ContentTypeAndData upload_content_; | 1192 ContentTypeAndData upload_content_; |
1186 | 1193 |
| 1194 // Last reported progress value. |
| 1195 int64 last_progress_value_; |
| 1196 |
1187 // Note: This should remain the last member so it'll be destroyed and | 1197 // Note: This should remain the last member so it'll be destroyed and |
1188 // invalidate its weak pointers before any other members are destroyed. | 1198 // invalidate its weak pointers before any other members are destroyed. |
1189 base::WeakPtrFactory<BatchUploadRequest> weak_ptr_factory_; | 1199 base::WeakPtrFactory<BatchUploadRequest> weak_ptr_factory_; |
1190 | 1200 |
1191 DISALLOW_COPY_AND_ASSIGN(BatchUploadRequest); | 1201 DISALLOW_COPY_AND_ASSIGN(BatchUploadRequest); |
1192 }; | 1202 }; |
1193 | 1203 |
1194 } // namespace drive | 1204 } // namespace drive |
1195 } // namespace google_apis | 1205 } // namespace google_apis |
1196 | 1206 |
1197 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 1207 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
OLD | NEW |