Upstream version 8.37.180.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync_file_system / drive_backend / drive_uploader_on_worker.h
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 "base/sequence_checker.h"
11 #include "chrome/browser/drive/drive_uploader.h"
12
13 namespace base {
14 class SingleThreadTaskRunner;
15 class SequencedTaskRunner;
16 }
17
18 namespace sync_file_system {
19 namespace drive_backend {
20
21 class DriveUploaderWrapper;
22
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 {
28  public:
29   DriveUploaderOnWorker(
30       const base::WeakPtr<DriveUploaderWrapper>& wrapper,
31       base::SingleThreadTaskRunner* ui_task_runner,
32       base::SequencedTaskRunner* worker_task_runner);
33   virtual ~DriveUploaderOnWorker();
34
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;
43
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;
51
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;
59
60  private:
61   base::WeakPtr<DriveUploaderWrapper> wrapper_;
62   scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
63   scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
64
65   base::SequenceChecker sequece_checker_;
66
67   DISALLOW_COPY_AND_ASSIGN(DriveUploaderOnWorker);
68 };
69
70 }  // namespace drive_backend
71 }  // namespace sync_file_system
72
73 #endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_UPLOADER_ON_WORKER_H_