| 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 "chrome/browser/chromeos/drive/job_scheduler.h" | 5 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 params.content_type, | 87 params.content_type, |
| 88 params.callback, | 88 params.callback, |
| 89 params.progress_callback); | 89 params.progress_callback); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Parameter struct for RunUploadExistingFile. | 92 // Parameter struct for RunUploadExistingFile. |
| 93 struct UploadExistingFileParams { | 93 struct UploadExistingFileParams { |
| 94 std::string resource_id; | 94 std::string resource_id; |
| 95 base::FilePath local_file_path; | 95 base::FilePath local_file_path; |
| 96 std::string content_type; | 96 std::string content_type; |
| 97 drive::DriveUploader::UploadExistingFileOptions options; |
| 97 std::string etag; | 98 std::string etag; |
| 98 UploadCompletionCallback callback; | 99 UploadCompletionCallback callback; |
| 99 google_apis::ProgressCallback progress_callback; | 100 google_apis::ProgressCallback progress_callback; |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 // Helper function to work around the arity limitation of base::Bind. | 103 // Helper function to work around the arity limitation of base::Bind. |
| 103 google_apis::CancelCallback RunUploadExistingFile( | 104 google_apis::CancelCallback RunUploadExistingFile( |
| 104 DriveUploaderInterface* uploader, | 105 DriveUploaderInterface* uploader, |
| 105 const UploadExistingFileParams& params) { | 106 const UploadExistingFileParams& params) { |
| 106 drive::DriveUploader::UploadExistingFileOptions options; | |
| 107 options.etag = params.etag; | |
| 108 return uploader->UploadExistingFile(params.resource_id, | 107 return uploader->UploadExistingFile(params.resource_id, |
| 109 params.local_file_path, | 108 params.local_file_path, |
| 110 params.content_type, | 109 params.content_type, |
| 111 options, | 110 params.options, |
| 112 params.callback, | 111 params.callback, |
| 113 params.progress_callback); | 112 params.progress_callback); |
| 114 } | 113 } |
| 115 | 114 |
| 116 // Parameter struct for RunResumeUploadFile. | 115 // Parameter struct for RunResumeUploadFile. |
| 117 struct ResumeUploadFileParams { | 116 struct ResumeUploadFileParams { |
| 118 GURL upload_location; | 117 GURL upload_location; |
| 119 base::FilePath local_file_path; | 118 base::FilePath local_file_path; |
| 120 std::string content_type; | 119 std::string content_type; |
| 121 UploadCompletionCallback callback; | 120 UploadCompletionCallback callback; |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 new_job->task = base::Bind(&RunUploadNewFile, uploader_.get(), params); | 646 new_job->task = base::Bind(&RunUploadNewFile, uploader_.get(), params); |
| 648 new_job->abort_callback = CreateErrorRunCallback(callback); | 647 new_job->abort_callback = CreateErrorRunCallback(callback); |
| 649 StartJob(new_job); | 648 StartJob(new_job); |
| 650 } | 649 } |
| 651 | 650 |
| 652 void JobScheduler::UploadExistingFile( | 651 void JobScheduler::UploadExistingFile( |
| 653 const std::string& resource_id, | 652 const std::string& resource_id, |
| 654 const base::FilePath& drive_file_path, | 653 const base::FilePath& drive_file_path, |
| 655 const base::FilePath& local_file_path, | 654 const base::FilePath& local_file_path, |
| 656 const std::string& content_type, | 655 const std::string& content_type, |
| 657 const std::string& etag, | 656 const drive::DriveUploader::UploadExistingFileOptions& options, |
| 658 const ClientContext& context, | 657 const ClientContext& context, |
| 659 const google_apis::GetResourceEntryCallback& callback) { | 658 const google_apis::GetResourceEntryCallback& callback) { |
| 660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 659 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 661 | 660 |
| 662 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_EXISTING_FILE); | 661 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_EXISTING_FILE); |
| 663 new_job->job_info.file_path = drive_file_path; | 662 new_job->job_info.file_path = drive_file_path; |
| 664 new_job->context = context; | 663 new_job->context = context; |
| 665 | 664 |
| 666 UploadExistingFileParams params; | 665 UploadExistingFileParams params; |
| 667 params.resource_id = resource_id; | 666 params.resource_id = resource_id; |
| 668 params.local_file_path = local_file_path; | 667 params.local_file_path = local_file_path; |
| 669 params.content_type = content_type; | 668 params.content_type = content_type; |
| 670 params.etag = etag; | 669 params.options = options; |
| 671 | 670 |
| 672 ResumeUploadParams resume_params; | 671 ResumeUploadParams resume_params; |
| 673 resume_params.local_file_path = params.local_file_path; | 672 resume_params.local_file_path = params.local_file_path; |
| 674 resume_params.content_type = params.content_type; | 673 resume_params.content_type = params.content_type; |
| 675 | 674 |
| 676 params.callback = base::Bind(&JobScheduler::OnUploadCompletionJobDone, | 675 params.callback = base::Bind(&JobScheduler::OnUploadCompletionJobDone, |
| 677 weak_ptr_factory_.GetWeakPtr(), | 676 weak_ptr_factory_.GetWeakPtr(), |
| 678 new_job->job_info.job_id, | 677 new_job->job_info.job_id, |
| 679 resume_params, | 678 resume_params, |
| 680 callback); | 679 callback); |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 case FILE_QUEUE: | 1190 case FILE_QUEUE: |
| 1192 return "FILE_QUEUE"; | 1191 return "FILE_QUEUE"; |
| 1193 case NUM_QUEUES: | 1192 case NUM_QUEUES: |
| 1194 break; // This value is just a sentinel. Should never be used. | 1193 break; // This value is just a sentinel. Should never be used. |
| 1195 } | 1194 } |
| 1196 NOTREACHED(); | 1195 NOTREACHED(); |
| 1197 return ""; | 1196 return ""; |
| 1198 } | 1197 } |
| 1199 | 1198 |
| 1200 } // namespace drive | 1199 } // namespace drive |
| OLD | NEW |