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 virtual ~RemoteChangeProcessorOnWorker();
35 virtual void PrepareForProcessRemoteChange(
36 const storage::FileSystemURL& url,
37 const PrepareChangeCallback& callback) OVERRIDE;
38 virtual void ApplyRemoteChange(const FileChange& change,
39 const base::FilePath& local_path,
40 const storage::FileSystemURL& url,
41 const SyncStatusCallback& callback) OVERRIDE;
42 virtual void FinalizeRemoteSync(
43 const storage::FileSystemURL& url,
44 bool clear_local_changes,
45 const base::Closure& completion_callback) OVERRIDE;
46 virtual void RecordFakeLocalChange(
47 const storage::FileSystemURL& url,
48 const FileChange& change,
49 const SyncStatusCallback& callback) OVERRIDE;
51 void DetachFromSequence();
54 base::WeakPtr<RemoteChangeProcessorWrapper> wrapper_;
55 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
56 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
58 base::SequenceChecker sequence_checker_;
60 DISALLOW_COPY_AND_ASSIGN(RemoteChangeProcessorOnWorker);
63 } // namespace drive_backend
64 } // namespace sync_file_system
66 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_ON_WORKER_H_