1 // Copyright (c) 2012 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_CHROMEOS_DRIVE_FILE_CHANGE_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CHANGE_H_
12 #include "base/basictypes.h"
13 #include "base/files/file_path.h"
14 #include "webkit/browser/fileapi/file_system_url.h"
34 Change(ChangeType change, FileType file_type);
36 bool IsAddOrUpdate() const { return change_ == ADD_OR_UPDATE; }
37 bool IsDelete() const { return change_ == DELETE; }
39 bool IsFile() const { return file_type_ == FILE_TYPE_FILE; }
40 bool IsDirectory() const { return file_type_ == FILE_TYPE_DIRECTORY; }
41 bool IsTypeUnknown() const { return !IsFile() && !IsDirectory(); }
43 ChangeType change() const { return change_; }
44 FileType file_type() const { return file_type_; }
46 std::string DebugString() const;
48 bool operator==(const Change& that) const {
49 return change() == that.change() && file_type() == that.file_type();
59 typedef std::deque<Change> List;
64 // Updates the list with the |new_change|.
65 void Update(const Change& new_change);
67 size_t size() const { return list_.size(); }
68 bool empty() const { return list_.empty(); }
69 void clear() { list_.clear(); }
70 const List& list() const { return list_; }
71 const Change& front() const { return list_.front(); }
72 const Change& back() const { return list_.back(); }
74 ChangeList PopAndGetNewList() const;
76 std::string DebugString() const;
83 typedef std::map<base::FilePath, FileChange::ChangeList> Map;
88 void Update(const base::FilePath file_path,
89 const FileChange::Change& new_change);
90 void Update(const base::FilePath file_path,
91 const FileChange::ChangeList& list);
92 void Update(const base::FilePath file_path,
94 FileChange::ChangeType change);
95 void Update(const base::FilePath file_path,
96 const ResourceEntry& entry,
97 FileChange::ChangeType change);
98 void Apply(const FileChange& new_changed_files);
100 const Map& map() const { return map_; }
102 size_t size() const { return map_.size(); }
103 bool empty() const { return map_.empty(); }
104 void ClearForTest() { map_.clear(); }
105 size_t CountDirectory(const base::FilePath& directory_path) const;
106 size_t count(const base::FilePath& file_path) const {
107 return map_.count(file_path);
110 std::string DebugString() const;
118 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CHANGE_H_