1 // Copyright 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_FILE_CHANGE_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_FILE_CHANGE_H_
11 #include "base/basictypes.h"
12 #include "base/files/file_path.h"
13 #include "chrome/browser/sync_file_system/sync_file_type.h"
14 #include "webkit/browser/fileapi/file_system_url.h"
16 namespace sync_file_system
{
21 FILE_CHANGE_ADD_OR_UPDATE
,
25 FileChange(ChangeType change
, SyncFileType file_type
);
27 bool IsAddOrUpdate() const { return change_
== FILE_CHANGE_ADD_OR_UPDATE
; }
28 bool IsDelete() const { return change_
== FILE_CHANGE_DELETE
; }
30 bool IsFile() const { return file_type_
== SYNC_FILE_TYPE_FILE
; }
31 bool IsDirectory() const { return file_type_
== SYNC_FILE_TYPE_DIRECTORY
; }
32 bool IsTypeUnknown() const { return !IsFile() && !IsDirectory(); }
34 ChangeType
change() const { return change_
; }
35 SyncFileType
file_type() const { return file_type_
; }
37 std::string
DebugString() const;
39 bool operator==(const FileChange
& that
) const {
40 return change() == that
.change() &&
41 file_type() == that
.file_type();
46 SyncFileType file_type_
;
49 class FileChangeList
{
51 typedef std::deque
<FileChange
> List
;
56 // Updates the list with the |new_change|.
57 void Update(const FileChange
& new_change
);
59 size_t size() const { return list_
.size(); }
60 bool empty() const { return list_
.empty(); }
61 void clear() { list_
.clear(); }
62 const List
& list() const { return list_
; }
63 const FileChange
& front() const { return list_
.front(); }
64 const FileChange
& back() const { return list_
.back(); }
66 FileChangeList
PopAndGetNewList() const;
68 std::string
DebugString() const;
74 } // namespace sync_file_system
76 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_FILE_CHANGE_H_