Re-enable child account detection, now behind a flag.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / fake_remote_change_processor.h
blob48bfa8d240e38910f316526d6c7d55500328da2e
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 ~FakeRemoteChangeProcessor() override;
43 // RemoteChangeProcessor overrides.
44 void PrepareForProcessRemoteChange(
45 const storage::FileSystemURL& url,
46 const PrepareChangeCallback& callback) override;
47 void ApplyRemoteChange(const FileChange& change,
48 const base::FilePath& local_path,
49 const storage::FileSystemURL& url,
50 const SyncStatusCallback& callback) override;
51 void FinalizeRemoteSync(const storage::FileSystemURL& url,
52 bool clear_local_changes,
53 const base::Closure& completion_callback) override;
54 void RecordFakeLocalChange(const storage::FileSystemURL& url,
55 const FileChange& change,
56 const SyncStatusCallback& callback) override;
58 void UpdateLocalFileMetadata(const storage::FileSystemURL& url,
59 const FileChange& change);
60 void ClearLocalChanges(const storage::FileSystemURL& url);
62 const URLToFileChangesMap& GetAppliedRemoteChanges() const;
64 // Compare |applied_changes_| with |expected_changes|.
65 // This internally calls EXPECT_FOO, ASSERT_FOO methods in the
66 // verification.
67 void VerifyConsistency(const URLToFileChangesMap& expected_changes);
69 private:
70 // History of file changes given by ApplyRemoteChange(). Changes are arranged
71 // in chronological order, that is, the end of the vector represents the last
72 // change.
73 URLToFileChangesMap applied_changes_;
75 // History of local file changes.
76 URLToFileChangeList local_changes_;
78 // Initial local file metadata. These are overridden by applied changes.
79 URLToFileMetadata local_file_metadata_;
81 DISALLOW_COPY_AND_ASSIGN(FakeRemoteChangeProcessor);
84 } // namespace sync_file_system
86 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_FAKE_REMOTE_CHANGE_PROCESSOR_H_