blob: 83143d8027aa264fdf1ddecac13b67b83d417c9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_BROWSER_FILEAPI_SYNCABLE_FILE_CHANGE_H_
#define WEBKIT_BROWSER_FILEAPI_SYNCABLE_FILE_CHANGE_H_
#include <deque>
#include <string>
#include "base/basictypes.h"
#include "base/files/file_path.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/syncable/sync_file_type.h"
#include "webkit/browser/webkit_storage_browser_export.h"
namespace sync_file_system {
class WEBKIT_STORAGE_BROWSER_EXPORT FileChange {
public:
enum ChangeType {
FILE_CHANGE_ADD_OR_UPDATE,
FILE_CHANGE_DELETE,
};
FileChange(ChangeType change, SyncFileType file_type);
bool IsAddOrUpdate() const { return change_ == FILE_CHANGE_ADD_OR_UPDATE; }
bool IsDelete() const { return change_ == FILE_CHANGE_DELETE; }
bool IsFile() const { return file_type_ == SYNC_FILE_TYPE_FILE; }
bool IsDirectory() const { return file_type_ == SYNC_FILE_TYPE_DIRECTORY; }
bool IsTypeUnknown() const { return !IsFile() && !IsDirectory(); }
ChangeType change() const { return change_; }
SyncFileType file_type() const { return file_type_; }
std::string DebugString() const;
bool operator==(const FileChange& that) const {
return change() == that.change() &&
file_type() == that.file_type();
}
private:
ChangeType change_;
SyncFileType file_type_;
};
class WEBKIT_STORAGE_BROWSER_EXPORT FileChangeList {
public:
typedef std::deque<FileChange> List;
FileChangeList();
~FileChangeList();
// Updates the list with the |new_change|.
void Update(const FileChange& new_change);
size_t size() const { return list_.size(); }
bool empty() const { return list_.empty(); }
void clear() { list_.clear(); }
const List& list() const { return list_; }
const FileChange& front() const { return list_.front(); }
const FileChange& back() const { return list_.back(); }
FileChangeList PopAndGetNewList() const;
std::string DebugString() const;
private:
List list_;
};
} // namespace sync_file_system
#endif // WEBKIT_BROWSER_FILEAPI_SYNCABLE_FILE_CHANGE_H_
|