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

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

Issue 13446003: Add DriveScheduler::UploadNewFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded #include. Created 7 years, 8 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/drive_scheduler.h" 5 #include "chrome/browser/chromeos/drive/drive_scheduler.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 new_job->download_url = download_url; 289 new_job->download_url = download_url;
290 new_job->context = context; 290 new_job->context = context;
291 new_job->download_action_callback = download_action_callback; 291 new_job->download_action_callback = download_action_callback;
292 new_job->get_content_callback = get_content_callback; 292 new_job->get_content_callback = get_content_callback;
293 293
294 QueueJob(new_job.Pass()); 294 QueueJob(new_job.Pass());
295 295
296 StartJobLoop(GetJobQueueType(TYPE_DOWNLOAD_FILE)); 296 StartJobLoop(GetJobQueueType(TYPE_DOWNLOAD_FILE));
297 } 297 }
298 298
299 void DriveScheduler::UploadNewFile(
300 const std::string& parent_resource_id,
301 const base::FilePath& drive_file_path,
302 const base::FilePath& local_file_path,
303 const std::string& title,
304 const std::string& content_type,
305 const DriveClientContext& context,
306 const google_apis::UploadCompletionCallback& callback) {
307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
308
309 scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_UPLOAD_NEW_FILE));
310 new_job->resource_id = parent_resource_id;
311 new_job->drive_file_path = drive_file_path;
312 new_job->local_file_path = local_file_path;
313 new_job->title = title;
314 new_job->content_type = content_type;
315 new_job->upload_completion_callback = callback;
316 new_job->context = context;
317
318 QueueJob(new_job.Pass());
319
320 StartJobLoop(GetJobQueueType(TYPE_UPLOAD_NEW_FILE));
321 }
322
299 void DriveScheduler::UploadExistingFile( 323 void DriveScheduler::UploadExistingFile(
300 const std::string& resource_id, 324 const std::string& resource_id,
301 const base::FilePath& drive_file_path, 325 const base::FilePath& drive_file_path,
302 const base::FilePath& local_file_path, 326 const base::FilePath& local_file_path,
303 const std::string& content_type, 327 const std::string& content_type,
304 const std::string& etag, 328 const std::string& etag,
305 const DriveClientContext& context, 329 const DriveClientContext& context,
306 const google_apis::UploadCompletionCallback& upload_completion_callback) { 330 const google_apis::UploadCompletionCallback& upload_completion_callback) {
307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
308 332
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 entry->virtual_path, 500 entry->virtual_path,
477 entry->local_cache_path, 501 entry->local_cache_path,
478 entry->download_url, 502 entry->download_url,
479 base::Bind(&DriveScheduler::OnDownloadActionJobDone, 503 base::Bind(&DriveScheduler::OnDownloadActionJobDone,
480 weak_ptr_factory_.GetWeakPtr(), 504 weak_ptr_factory_.GetWeakPtr(),
481 base::Passed(&queue_entry)), 505 base::Passed(&queue_entry)),
482 entry->get_content_callback); 506 entry->get_content_callback);
483 } 507 }
484 break; 508 break;
485 509
510 case TYPE_UPLOAD_NEW_FILE: {
511 uploader_->UploadNewFile(
512 entry->resource_id,
513 entry->drive_file_path,
514 entry->local_file_path,
515 entry->title,
516 entry->content_type,
517 base::Bind(&DriveScheduler::OnUploadCompletionJobDone,
518 weak_ptr_factory_.GetWeakPtr(),
519 base::Passed(&queue_entry)));
520 }
521 break;
522
486 case TYPE_UPLOAD_EXISTING_FILE: { 523 case TYPE_UPLOAD_EXISTING_FILE: {
487 uploader_->UploadExistingFile( 524 uploader_->UploadExistingFile(
488 entry->resource_id, 525 entry->resource_id,
489 entry->drive_file_path, 526 entry->drive_file_path,
490 entry->local_file_path, 527 entry->local_file_path,
491 entry->content_type, 528 entry->content_type,
492 entry->etag, 529 entry->etag,
493 base::Bind(&DriveScheduler::OnUploadCompletionJobDone, 530 base::Bind(&DriveScheduler::OnUploadCompletionJobDone,
494 weak_ptr_factory_.GetWeakPtr(), 531 weak_ptr_factory_.GetWeakPtr(),
495 base::Passed(&queue_entry))); 532 base::Passed(&queue_entry)));
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 case TYPE_GET_RESOURCE_ENTRY: 804 case TYPE_GET_RESOURCE_ENTRY:
768 case TYPE_DELETE_RESOURCE: 805 case TYPE_DELETE_RESOURCE:
769 case TYPE_COPY_HOSTED_DOCUMENT: 806 case TYPE_COPY_HOSTED_DOCUMENT:
770 case TYPE_RENAME_RESOURCE: 807 case TYPE_RENAME_RESOURCE:
771 case TYPE_ADD_RESOURCE_TO_DIRECTORY: 808 case TYPE_ADD_RESOURCE_TO_DIRECTORY:
772 case TYPE_REMOVE_RESOURCE_FROM_DIRECTORY: 809 case TYPE_REMOVE_RESOURCE_FROM_DIRECTORY:
773 case TYPE_ADD_NEW_DIRECTORY: 810 case TYPE_ADD_NEW_DIRECTORY:
774 return METADATA_QUEUE; 811 return METADATA_QUEUE;
775 812
776 case TYPE_DOWNLOAD_FILE: 813 case TYPE_DOWNLOAD_FILE:
814 case TYPE_UPLOAD_NEW_FILE:
777 case TYPE_UPLOAD_EXISTING_FILE: 815 case TYPE_UPLOAD_EXISTING_FILE:
778 return FILE_QUEUE; 816 return FILE_QUEUE;
779 } 817 }
780 NOTREACHED(); 818 NOTREACHED();
781 return FILE_QUEUE; 819 return FILE_QUEUE;
782 } 820 }
783 821
784 } // namespace drive 822 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_scheduler.h ('k') | chrome/browser/chromeos/drive/file_system/copy_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698