OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef WEBKIT_FILEAPI_SYNCABLE_FILE_CHANGE_H_ | |
6 #define WEBKIT_FILEAPI_SYNCABLE_FILE_CHANGE_H_ | |
7 | |
8 #include <deque> | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/files/file_path.h" | |
13 #include "webkit/browser/fileapi/file_system_url.h" | |
14 #include "webkit/fileapi/syncable/sync_file_type.h" | |
15 #include "webkit/storage/webkit_storage_export.h" | |
16 | |
17 namespace sync_file_system { | |
18 | |
19 class WEBKIT_STORAGE_EXPORT FileChange { | |
20 public: | |
21 enum ChangeType { | |
22 FILE_CHANGE_ADD_OR_UPDATE, | |
23 FILE_CHANGE_DELETE, | |
24 }; | |
25 | |
26 FileChange(ChangeType change, SyncFileType file_type); | |
27 | |
28 bool IsAddOrUpdate() const { return change_ == FILE_CHANGE_ADD_OR_UPDATE; } | |
29 bool IsDelete() const { return change_ == FILE_CHANGE_DELETE; } | |
30 | |
31 bool IsFile() const { return file_type_ == SYNC_FILE_TYPE_FILE; } | |
32 bool IsDirectory() const { return file_type_ == SYNC_FILE_TYPE_DIRECTORY; } | |
33 bool IsTypeUnknown() const { return !IsFile() && !IsDirectory(); } | |
34 | |
35 ChangeType change() const { return change_; } | |
36 SyncFileType file_type() const { return file_type_; } | |
37 | |
38 std::string DebugString() const; | |
39 | |
40 bool operator==(const FileChange& that) const { | |
41 return change() == that.change() && | |
42 file_type() == that.file_type(); | |
43 } | |
44 | |
45 private: | |
46 ChangeType change_; | |
47 SyncFileType file_type_; | |
48 }; | |
49 | |
50 class WEBKIT_STORAGE_EXPORT FileChangeList { | |
51 public: | |
52 typedef std::deque<FileChange> List; | |
53 | |
54 FileChangeList(); | |
55 ~FileChangeList(); | |
56 | |
57 // Updates the list with the |new_change|. | |
58 void Update(const FileChange& new_change); | |
59 | |
60 size_t size() const { return list_.size(); } | |
61 bool empty() const { return list_.empty(); } | |
62 void clear() { list_.clear(); } | |
63 const List& list() const { return list_; } | |
64 const FileChange& front() const { return list_.front(); } | |
65 const FileChange& back() const { return list_.back(); } | |
66 | |
67 FileChangeList PopAndGetNewList() const; | |
68 | |
69 std::string DebugString() const; | |
70 | |
71 private: | |
72 List list_; | |
73 }; | |
74 | |
75 } // namespace sync_file_system | |
76 | |
77 #endif // WEBKIT_FILEAPI_SYNCABLE_FILE_CHANGE_H_ | |
OLD | NEW |