drive_uploader_on_worker.h revision 5c02ac1a9c1b504631c0a3d2b6e737b5d738bae1
1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_UPLOADER_ON_WORKER_H_ 6#define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_UPLOADER_ON_WORKER_H_ 7 8#include "base/memory/ref_counted.h" 9#include "base/memory/weak_ptr.h" 10#include "chrome/browser/drive/drive_uploader.h" 11 12namespace base { 13class SingleThreadTaskRunner; 14class SequencedTaskRunner; 15} 16 17namespace sync_file_system { 18namespace drive_backend { 19 20class DriveUploaderWrapper; 21 22// This class wraps a part of DriveUploaderInterface class to post actual 23// tasks to DriveUploaderWrapper which lives in another thread. 24// Each method wraps corresponding name method of DriveUploaderInterface. 25// See comments in drive_uploader.h for details. 26class DriveUploaderOnWorker : public drive::DriveUploaderInterface { 27 public: 28 DriveUploaderOnWorker( 29 const base::WeakPtr<DriveUploaderWrapper>& wrapper, 30 base::SingleThreadTaskRunner* ui_task_runner, 31 base::SequencedTaskRunner* worker_task_runner); 32 virtual ~DriveUploaderOnWorker(); 33 34 virtual google_apis::CancelCallback UploadNewFile( 35 const std::string& parent_resource_id, 36 const base::FilePath& local_file_path, 37 const std::string& title, 38 const std::string& content_type, 39 const UploadNewFileOptions& options, 40 const drive::UploadCompletionCallback& callback, 41 const google_apis::ProgressCallback& progress_callback) OVERRIDE; 42 43 virtual google_apis::CancelCallback UploadExistingFile( 44 const std::string& resource_id, 45 const base::FilePath& local_file_path, 46 const std::string& content_type, 47 const UploadExistingFileOptions& options, 48 const drive::UploadCompletionCallback& callback, 49 const google_apis::ProgressCallback& progress_callback) OVERRIDE; 50 51 // Following method is expected not to be used. 52 virtual google_apis::CancelCallback ResumeUploadFile( 53 const GURL& upload_location, 54 const base::FilePath& local_file_path, 55 const std::string& content_type, 56 const drive::UploadCompletionCallback& callback, 57 const google_apis::ProgressCallback& progress_callback) OVERRIDE; 58 59 private: 60 base::WeakPtr<DriveUploaderWrapper> wrapper_; 61 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 62 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; 63 64 DISALLOW_COPY_AND_ASSIGN(DriveUploaderOnWorker); 65}; 66 67} // namespace drive_backend 68} // namespace sync_file_system 69 70#endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_UPLOADER_ON_WORKER_H_ 71