remote_change_processor_on_worker.h revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
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
13namespace base {
14class SingleThreadTaskRunner;
15class SequencedTaskRunner;
16}
17
18namespace sync_file_system {
19namespace drive_backend {
20
21class 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.
27class 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  virtual ~RemoteChangeProcessorOnWorker();
34
35  virtual void PrepareForProcessRemoteChange(
36      const fileapi::FileSystemURL& url,
37      const PrepareChangeCallback& callback) OVERRIDE;
38  virtual void ApplyRemoteChange(
39      const FileChange& change,
40      const base::FilePath& local_path,
41      const fileapi::FileSystemURL& url,
42      const SyncStatusCallback& callback) OVERRIDE;
43  virtual void FinalizeRemoteSync(
44      const fileapi::FileSystemURL& url,
45      bool clear_local_changes,
46      const base::Closure& completion_callback) OVERRIDE;
47  virtual void RecordFakeLocalChange(
48      const fileapi::FileSystemURL& url,
49      const FileChange& change,
50      const SyncStatusCallback& callback) OVERRIDE;
51
52 private:
53  base::WeakPtr<RemoteChangeProcessorWrapper> wrapper_;
54  scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
55  scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
56
57  base::SequenceChecker sequence_checker_;
58
59  DISALLOW_COPY_AND_ASSIGN(RemoteChangeProcessorOnWorker);
60};
61
62}  // namespace drive_backend
63}  // namespace sync_file_system
64
65#endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_ON_WORKER_H_
66