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 "base/sequence_checker.h"
11 #include "chrome/browser/drive/drive_uploader.h"
14 class SingleThreadTaskRunner;
15 class SequencedTaskRunner;
18 namespace sync_file_system {
19 namespace drive_backend {
21 class DriveUploaderWrapper;
23 // This class wraps a part of DriveUploaderInterface class to post actual
24 // tasks to DriveUploaderWrapper which lives in another thread.
25 // Each method wraps corresponding name method of DriveUploaderInterface.
26 // See comments in drive_uploader.h for details.
27 class DriveUploaderOnWorker : public drive::DriveUploaderInterface {
29 DriveUploaderOnWorker(
30 const base::WeakPtr<DriveUploaderWrapper>& wrapper,
31 base::SingleThreadTaskRunner* ui_task_runner,
32 base::SequencedTaskRunner* worker_task_runner);
33 virtual ~DriveUploaderOnWorker();
35 virtual google_apis::CancelCallback UploadNewFile(
36 const std::string& parent_resource_id,
37 const base::FilePath& local_file_path,
38 const std::string& title,
39 const std::string& content_type,
40 const UploadNewFileOptions& options,
41 const drive::UploadCompletionCallback& callback,
42 const google_apis::ProgressCallback& progress_callback) OVERRIDE;
44 virtual google_apis::CancelCallback UploadExistingFile(
45 const std::string& resource_id,
46 const base::FilePath& local_file_path,
47 const std::string& content_type,
48 const UploadExistingFileOptions& options,
49 const drive::UploadCompletionCallback& callback,
50 const google_apis::ProgressCallback& progress_callback) OVERRIDE;
52 // Following method is expected not to be used.
53 virtual google_apis::CancelCallback ResumeUploadFile(
54 const GURL& upload_location,
55 const base::FilePath& local_file_path,
56 const std::string& content_type,
57 const drive::UploadCompletionCallback& callback,
58 const google_apis::ProgressCallback& progress_callback) OVERRIDE;
61 base::WeakPtr<DriveUploaderWrapper> wrapper_;
62 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
63 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
65 base::SequenceChecker sequece_checker_;
67 DISALLOW_COPY_AND_ASSIGN(DriveUploaderOnWorker);
70 } // namespace drive_backend
71 } // namespace sync_file_system
73 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_UPLOADER_ON_WORKER_H_