Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / sync_file_system / file_change.h
blobe06db9028cf93ac6f46982b46c90f2fc464e1ad7
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_
8 #include <deque>
9 #include <string>
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 "storage/browser/fileapi/file_system_url.h"
16 namespace sync_file_system {
18 class FileChange {
19 public:
20 enum ChangeType {
21 FILE_CHANGE_ADD_OR_UPDATE,
22 FILE_CHANGE_DELETE,
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();
44 private:
45 ChangeType change_;
46 SyncFileType file_type_;
49 class FileChangeList {
50 public:
51 typedef std::deque<FileChange> List;
53 FileChangeList();
54 ~FileChangeList();
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;
70 private:
71 List list_;
74 } // namespace sync_file_system
76 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_FILE_CHANGE_H_