fake_remote_change_processor.h revision f2477e01787aa58f445919b809d89e252beef54f
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. 4 5#ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_FAKE_REMOTE_CHANGE_PROCESSOR_H_ 6#define CHROME_BROWSER_SYNC_FILE_SYSTEM_FAKE_REMOTE_CHANGE_PROCESSOR_H_ 7 8#include <map> 9#include <string> 10#include <vector> 11 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" 15 16namespace base { 17class FilePath; 18} 19 20namespace fileapi { 21class FileSystemURL; 22} 23 24namespace sync_file_system { 25 26class FileChange; 27 28class FakeRemoteChangeProcessor : public RemoteChangeProcessor { 29 public: 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; 36 37 FakeRemoteChangeProcessor(); 38 virtual ~FakeRemoteChangeProcessor(); 39 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; 57 58 void UpdateLocalFileMetadata( 59 const fileapi::FileSystemURL& url, 60 const FileChange& change); 61 62 const URLToFileChangesMap& GetAppliedRemoteChanges() const; 63 64 private: 65 // History of file changes given by ApplyRemoteChange(). Changes are arranged 66 // in chronological order, that is, the end of the vector represents the last 67 // change. 68 URLToFileChangesMap applied_changes_; 69 70 // History of local file changes. 71 URLToFileChangeList local_changes_; 72 73 // Initial local file metadata. These are overridden by applied changes. 74 URLToFileMetadata local_file_metadata_; 75 76 DISALLOW_COPY_AND_ASSIGN(FakeRemoteChangeProcessor); 77}; 78 79} // namespace sync_file_system 80 81#endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_FAKE_REMOTE_CHANGE_PROCESSOR_H_ 82