| 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 COMPONENTS_DRIVE_DRIVE_UPLOADER_H_ | 5 #ifndef COMPONENTS_DRIVE_DRIVE_UPLOADER_H_ |
| 6 #define COMPONENTS_DRIVE_DRIVE_UPLOADER_H_ | 6 #define COMPONENTS_DRIVE_DRIVE_UPLOADER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 15 #include "components/drive/service/drive_service_interface.h" | 17 #include "components/drive/service/drive_service_interface.h" |
| 16 #include "google_apis/drive/drive_api_error_codes.h" | 18 #include "google_apis/drive/drive_api_error_codes.h" |
| 17 | 19 |
| 18 class GURL; | 20 class GURL; |
| 19 | 21 |
| 20 namespace base { | 22 namespace base { |
| 21 class FilePath; | 23 class FilePath; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 200 |
| 199 // Uploads the next chunk of data from the file. | 201 // Uploads the next chunk of data from the file. |
| 200 void UploadNextChunk(scoped_ptr<UploadFileInfo> upload_file_info); | 202 void UploadNextChunk(scoped_ptr<UploadFileInfo> upload_file_info); |
| 201 | 203 |
| 202 // DriveService callback for ResumeUpload. | 204 // DriveService callback for ResumeUpload. |
| 203 void OnUploadRangeResponseReceived( | 205 void OnUploadRangeResponseReceived( |
| 204 scoped_ptr<UploadFileInfo> upload_file_info, | 206 scoped_ptr<UploadFileInfo> upload_file_info, |
| 205 const google_apis::UploadRangeResponse& response, | 207 const google_apis::UploadRangeResponse& response, |
| 206 scoped_ptr<google_apis::FileResource> entry); | 208 scoped_ptr<google_apis::FileResource> entry); |
| 207 void OnUploadProgress(const google_apis::ProgressCallback& callback, | 209 void OnUploadProgress(const google_apis::ProgressCallback& callback, |
| 208 int64 start_position, | 210 int64_t start_position, |
| 209 int64 total_size, | 211 int64_t total_size, |
| 210 int64 progress_of_chunk, | 212 int64_t progress_of_chunk, |
| 211 int64 total_of_chunk); | 213 int64_t total_of_chunk); |
| 212 | 214 |
| 213 // Handles failed uploads. | 215 // Handles failed uploads. |
| 214 void UploadFailed(scoped_ptr<UploadFileInfo> upload_file_info, | 216 void UploadFailed(scoped_ptr<UploadFileInfo> upload_file_info, |
| 215 google_apis::DriveApiErrorCode error); | 217 google_apis::DriveApiErrorCode error); |
| 216 | 218 |
| 217 // Handles completion/error of multipart uploading. | 219 // Handles completion/error of multipart uploading. |
| 218 void OnMultipartUploadComplete(scoped_ptr<UploadFileInfo> upload_file_info, | 220 void OnMultipartUploadComplete(scoped_ptr<UploadFileInfo> upload_file_info, |
| 219 google_apis::DriveApiErrorCode error, | 221 google_apis::DriveApiErrorCode error, |
| 220 scoped_ptr<google_apis::FileResource> entry); | 222 scoped_ptr<google_apis::FileResource> entry); |
| 221 | 223 |
| 222 // The class is expected to run on UI thread. | 224 // The class is expected to run on UI thread. |
| 223 base::ThreadChecker thread_checker_; | 225 base::ThreadChecker thread_checker_; |
| 224 | 226 |
| 225 // The lifetime of this object should be guaranteed to exceed that of the | 227 // The lifetime of this object should be guaranteed to exceed that of the |
| 226 // DriveUploader instance. | 228 // DriveUploader instance. |
| 227 DriveServiceInterface* drive_service_; // Not owned by this class. | 229 DriveServiceInterface* drive_service_; // Not owned by this class. |
| 228 | 230 |
| 229 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 231 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
| 230 scoped_refptr<RefCountedBatchRequest> current_batch_request_; | 232 scoped_refptr<RefCountedBatchRequest> current_batch_request_; |
| 231 | 233 |
| 232 // Note: This should remain the last member so it'll be destroyed and | 234 // Note: This should remain the last member so it'll be destroyed and |
| 233 // invalidate its weak pointers before any other members are destroyed. | 235 // invalidate its weak pointers before any other members are destroyed. |
| 234 base::WeakPtrFactory<DriveUploader> weak_ptr_factory_; | 236 base::WeakPtrFactory<DriveUploader> weak_ptr_factory_; |
| 235 DISALLOW_COPY_AND_ASSIGN(DriveUploader); | 237 DISALLOW_COPY_AND_ASSIGN(DriveUploader); |
| 236 }; | 238 }; |
| 237 | 239 |
| 238 } // namespace drive | 240 } // namespace drive |
| 239 | 241 |
| 240 #endif // COMPONENTS_DRIVE_DRIVE_UPLOADER_H_ | 242 #endif // COMPONENTS_DRIVE_DRIVE_UPLOADER_H_ |
| OLD | NEW |