Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/chromeos/drive/job_scheduler.cc

Issue 148233006: drive: Use UploadNewFile from EntryUpdatePerformer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 CreateErrorRunCallback(const base::Callback<CallbackType>& callback) { 66 CreateErrorRunCallback(const base::Callback<CallbackType>& callback) {
67 return base::Bind(&CreateErrorRunCallbackHelper<CallbackType>::Run, callback); 67 return base::Bind(&CreateErrorRunCallbackHelper<CallbackType>::Run, callback);
68 } 68 }
69 69
70 // Parameter struct for RunUploadNewFile. 70 // Parameter struct for RunUploadNewFile.
71 struct UploadNewFileParams { 71 struct UploadNewFileParams {
72 std::string parent_resource_id; 72 std::string parent_resource_id;
73 base::FilePath local_file_path; 73 base::FilePath local_file_path;
74 std::string title; 74 std::string title;
75 std::string content_type; 75 std::string content_type;
76 drive::DriveUploader::UploadNewFileOptions options;
76 UploadCompletionCallback callback; 77 UploadCompletionCallback callback;
77 google_apis::ProgressCallback progress_callback; 78 google_apis::ProgressCallback progress_callback;
78 }; 79 };
79 80
80 // Helper function to work around the arity limitation of base::Bind. 81 // Helper function to work around the arity limitation of base::Bind.
81 google_apis::CancelCallback RunUploadNewFile( 82 google_apis::CancelCallback RunUploadNewFile(
82 DriveUploaderInterface* uploader, 83 DriveUploaderInterface* uploader,
83 const UploadNewFileParams& params) { 84 const UploadNewFileParams& params) {
84 return uploader->UploadNewFile(params.parent_resource_id, 85 return uploader->UploadNewFile(params.parent_resource_id,
85 params.local_file_path, 86 params.local_file_path,
86 params.title, 87 params.title,
87 params.content_type, 88 params.content_type,
88 DriveUploader::UploadNewFileOptions(), 89 params.options,
89 params.callback, 90 params.callback,
90 params.progress_callback); 91 params.progress_callback);
91 } 92 }
92 93
93 // Parameter struct for RunUploadExistingFile. 94 // Parameter struct for RunUploadExistingFile.
94 struct UploadExistingFileParams { 95 struct UploadExistingFileParams {
95 std::string resource_id; 96 std::string resource_id;
96 base::FilePath local_file_path; 97 base::FilePath local_file_path;
97 std::string content_type; 98 std::string content_type;
98 drive::DriveUploader::UploadExistingFileOptions options; 99 drive::DriveUploader::UploadExistingFileOptions options;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 StartJob(new_job); 612 StartJob(new_job);
612 return new_job->job_info.job_id; 613 return new_job->job_info.job_id;
613 } 614 }
614 615
615 void JobScheduler::UploadNewFile( 616 void JobScheduler::UploadNewFile(
616 const std::string& parent_resource_id, 617 const std::string& parent_resource_id,
617 const base::FilePath& drive_file_path, 618 const base::FilePath& drive_file_path,
618 const base::FilePath& local_file_path, 619 const base::FilePath& local_file_path,
619 const std::string& title, 620 const std::string& title,
620 const std::string& content_type, 621 const std::string& content_type,
622 const drive::DriveUploader::UploadNewFileOptions& options,
621 const ClientContext& context, 623 const ClientContext& context,
622 const google_apis::GetResourceEntryCallback& callback) { 624 const google_apis::GetResourceEntryCallback& callback) {
623 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
624 626
625 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_NEW_FILE); 627 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_NEW_FILE);
626 new_job->job_info.file_path = drive_file_path; 628 new_job->job_info.file_path = drive_file_path;
627 new_job->context = context; 629 new_job->context = context;
628 630
629 UploadNewFileParams params; 631 UploadNewFileParams params;
630 params.parent_resource_id = parent_resource_id; 632 params.parent_resource_id = parent_resource_id;
631 params.local_file_path = local_file_path; 633 params.local_file_path = local_file_path;
632 params.title = title; 634 params.title = title;
633 params.content_type = content_type; 635 params.content_type = content_type;
636 params.options = options;
634 637
635 ResumeUploadParams resume_params; 638 ResumeUploadParams resume_params;
636 resume_params.local_file_path = params.local_file_path; 639 resume_params.local_file_path = params.local_file_path;
637 resume_params.content_type = params.content_type; 640 resume_params.content_type = params.content_type;
638 641
639 params.callback = base::Bind(&JobScheduler::OnUploadCompletionJobDone, 642 params.callback = base::Bind(&JobScheduler::OnUploadCompletionJobDone,
640 weak_ptr_factory_.GetWeakPtr(), 643 weak_ptr_factory_.GetWeakPtr(),
641 new_job->job_info.job_id, 644 new_job->job_info.job_id,
642 resume_params, 645 resume_params,
643 callback); 646 callback);
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 case FILE_QUEUE: 1194 case FILE_QUEUE:
1192 return "FILE_QUEUE"; 1195 return "FILE_QUEUE";
1193 case NUM_QUEUES: 1196 case NUM_QUEUES:
1194 break; // This value is just a sentinel. Should never be used. 1197 break; // This value is just a sentinel. Should never be used.
1195 } 1198 }
1196 NOTREACHED(); 1199 NOTREACHED();
1197 return ""; 1200 return "";
1198 } 1201 }
1199 1202
1200 } // namespace drive 1203 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.h ('k') | chrome/browser/chromeos/drive/job_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698