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_REMOTE_CHANGE_PROCESSOR_ON_WORKER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_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/sync_file_system/remote_change_processor.h"
14 class SingleThreadTaskRunner;
15 class SequencedTaskRunner;
18 namespace sync_file_system {
19 namespace drive_backend {
21 class RemoteChangeProcessorWrapper;
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 {
29 RemoteChangeProcessorOnWorker(
30 const base::WeakPtr<RemoteChangeProcessorWrapper>& wrapper,
31 base::SingleThreadTaskRunner* ui_task_runner,
32 base::SequencedTaskRunner* worker_task_runner);
33 ~RemoteChangeProcessorOnWorker() override;
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;
49 void DetachFromSequence();
52 base::WeakPtr<RemoteChangeProcessorWrapper> wrapper_;
53 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
54 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
56 base::SequenceChecker sequence_checker_;
58 DISALLOW_COPY_AND_ASSIGN(RemoteChangeProcessorOnWorker);
61 } // namespace drive_backend
62 } // namespace sync_file_system
64 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_ON_WORKER_H_