Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chrome / browser / sync_file_system / fake_remote_change_processor.h
blobcc56d286410e9d3d99f70ebd5e2f1ecf491d3ee2
1 // Copyright (c) 2013 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_FAKE_REMOTE_CHANGE_PROCESSOR_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_FAKE_REMOTE_CHANGE_PROCESSOR_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/callback.h"
13 #include "chrome/browser/sync_file_system/remote_change_processor.h"
14 #include "chrome/browser/sync_file_system/sync_callbacks.h"
16 namespace base {
17 class FilePath;
20 namespace storage {
21 class FileSystemURL;
24 namespace sync_file_system {
26 class FileChange;
28 class FakeRemoteChangeProcessor : public RemoteChangeProcessor {
29 public:
30 typedef std::map<storage::FileSystemURL,
31 std::vector<FileChange>,
32 storage::FileSystemURL::Comparator> URLToFileChangesMap;
33 typedef std::map<storage::FileSystemURL,
34 FileChangeList,
35 storage::FileSystemURL::Comparator> URLToFileChangeList;
36 typedef std::map<storage::FileSystemURL,
37 SyncFileMetadata,
38 storage::FileSystemURL::Comparator> URLToFileMetadata;
40 FakeRemoteChangeProcessor();
41 virtual ~FakeRemoteChangeProcessor();
43 // RemoteChangeProcessor overrides.
44 virtual void PrepareForProcessRemoteChange(
45 const storage::FileSystemURL& url,
46 const PrepareChangeCallback& callback) OVERRIDE;
47 virtual void ApplyRemoteChange(const FileChange& change,
48 const base::FilePath& local_path,
49 const storage::FileSystemURL& url,
50 const SyncStatusCallback& callback) OVERRIDE;
51 virtual void FinalizeRemoteSync(
52 const storage::FileSystemURL& url,
53 bool clear_local_changes,
54 const base::Closure& completion_callback) OVERRIDE;
55 virtual void RecordFakeLocalChange(
56 const storage::FileSystemURL& url,
57 const FileChange& change,
58 const SyncStatusCallback& callback) OVERRIDE;
60 void UpdateLocalFileMetadata(const storage::FileSystemURL& url,
61 const FileChange& change);
62 void ClearLocalChanges(const storage::FileSystemURL& url);
64 const URLToFileChangesMap& GetAppliedRemoteChanges() const;
66 // Compare |applied_changes_| with |expected_changes|.
67 // This internally calls EXPECT_FOO, ASSERT_FOO methods in the
68 // verification.
69 void VerifyConsistency(const URLToFileChangesMap& expected_changes);
71 private:
72 // History of file changes given by ApplyRemoteChange(). Changes are arranged
73 // in chronological order, that is, the end of the vector represents the last
74 // change.
75 URLToFileChangesMap applied_changes_;
77 // History of local file changes.
78 URLToFileChangeList local_changes_;
80 // Initial local file metadata. These are overridden by applied changes.
81 URLToFileMetadata local_file_metadata_;
83 DISALLOW_COPY_AND_ASSIGN(FakeRemoteChangeProcessor);
86 } // namespace sync_file_system
88 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_FAKE_REMOTE_CHANGE_PROCESSOR_H_