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.
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_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/drive/drive_uploader.h"
13 class SingleThreadTaskRunner;
14 class SequencedTaskRunner;
17 namespace sync_file_system {
18 namespace drive_backend {
20 class DriveUploaderWrapper;
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.
26 class DriveUploaderOnWorker : public drive::DriveUploaderInterface {
28 DriveUploaderOnWorker(
29 const base::WeakPtr<DriveUploaderWrapper>& wrapper,
30 base::SingleThreadTaskRunner* ui_task_runner,
31 base::SequencedTaskRunner* worker_task_runner);
32 virtual ~DriveUploaderOnWorker();
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;
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;
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;
60 base::WeakPtr<DriveUploaderWrapper> wrapper_;
61 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
62 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
64 DISALLOW_COPY_AND_ASSIGN(DriveUploaderOnWorker);
67 } // namespace drive_backend
68 } // namespace sync_file_system
70 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_UPLOADER_ON_WORKER_H_