Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync_file_system / drive_backend / remote_change_processor_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_REMOTE_CHANGE_PROCESSOR_ON_WORKER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_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/sync_file_system/remote_change_processor.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 RemoteChangeProcessorWrapper;
22
23 // This class wraps a part of RemoteChangeProcessor class to post actual
24 // tasks to RemoteChangeProcessorWrapper which lives in another thread.
25 // Each method wraps corresponding name method of RemoteChangeProcessor.
26 // See comments in remote_change_processor.h for details.
27 class RemoteChangeProcessorOnWorker : public RemoteChangeProcessor {
28  public:
29   RemoteChangeProcessorOnWorker(
30       const base::WeakPtr<RemoteChangeProcessorWrapper>& wrapper,
31       base::SingleThreadTaskRunner* ui_task_runner,
32       base::SequencedTaskRunner* worker_task_runner);
33   ~RemoteChangeProcessorOnWorker() override;
34
35   void PrepareForProcessRemoteChange(
36       const storage::FileSystemURL& url,
37       const PrepareChangeCallback& callback) override;
38   void ApplyRemoteChange(const FileChange& change,
39                          const base::FilePath& local_path,
40                          const storage::FileSystemURL& url,
41                          const SyncStatusCallback& callback) override;
42   void FinalizeRemoteSync(const storage::FileSystemURL& url,
43                           bool clear_local_changes,
44                           const base::Closure& completion_callback) override;
45   void RecordFakeLocalChange(const storage::FileSystemURL& url,
46                              const FileChange& change,
47                              const SyncStatusCallback& callback) override;
48
49   void DetachFromSequence();
50
51  private:
52   base::WeakPtr<RemoteChangeProcessorWrapper> wrapper_;
53   scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
54   scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
55
56   base::SequenceChecker sequence_checker_;
57
58   DISALLOW_COPY_AND_ASSIGN(RemoteChangeProcessorOnWorker);
59 };
60
61 }  // namespace drive_backend
62 }  // namespace sync_file_system
63
64 #endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_ON_WORKER_H_