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_
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"
24 namespace sync_file_system
{
28 class FakeRemoteChangeProcessor
: public RemoteChangeProcessor
{
30 typedef std::map
<fileapi::FileSystemURL
, std::vector
<FileChange
>,
31 fileapi::FileSystemURL::Comparator
> URLToFileChangesMap
;
32 typedef std::map
<fileapi::FileSystemURL
, FileChangeList
,
33 fileapi::FileSystemURL::Comparator
> URLToFileChangeList
;
34 typedef std::map
<fileapi::FileSystemURL
, SyncFileMetadata
,
35 fileapi::FileSystemURL::Comparator
> URLToFileMetadata
;
37 FakeRemoteChangeProcessor();
38 virtual ~FakeRemoteChangeProcessor();
40 // RemoteChangeProcessor overrides.
41 virtual void PrepareForProcessRemoteChange(
42 const fileapi::FileSystemURL
& url
,
43 const PrepareChangeCallback
& callback
) OVERRIDE
;
44 virtual void ApplyRemoteChange(
45 const FileChange
& change
,
46 const base::FilePath
& local_path
,
47 const fileapi::FileSystemURL
& url
,
48 const SyncStatusCallback
& callback
) OVERRIDE
;
49 virtual void FinalizeRemoteSync(
50 const fileapi::FileSystemURL
& url
,
51 bool clear_local_changes
,
52 const base::Closure
& completion_callback
) OVERRIDE
;
53 virtual void RecordFakeLocalChange(
54 const fileapi::FileSystemURL
& url
,
55 const FileChange
& change
,
56 const SyncStatusCallback
& callback
) OVERRIDE
;
58 void UpdateLocalFileMetadata(
59 const fileapi::FileSystemURL
& url
,
60 const FileChange
& change
);
61 void ClearLocalChanges(const fileapi::FileSystemURL
& url
);
63 const URLToFileChangesMap
& GetAppliedRemoteChanges() const;
65 // Compare |applied_changes_| with |expected_changes|.
66 // This internally calls EXPECT_FOO, ASSERT_FOO methods in the
68 void VerifyConsistency(const URLToFileChangesMap
& expected_changes
);
71 // History of file changes given by ApplyRemoteChange(). Changes are arranged
72 // in chronological order, that is, the end of the vector represents the last
74 URLToFileChangesMap applied_changes_
;
76 // History of local file changes.
77 URLToFileChangeList local_changes_
;
79 // Initial local file metadata. These are overridden by applied changes.
80 URLToFileMetadata local_file_metadata_
;
82 DISALLOW_COPY_AND_ASSIGN(FakeRemoteChangeProcessor
);
85 } // namespace sync_file_system
87 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_FAKE_REMOTE_CHANGE_PROCESSOR_H_