OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_IN
TERFACE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_IN
TERFACE_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_IN
TERFACE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_IN
TERFACE_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/basictypes.h" | 14 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
13 | 16 |
14 namespace sync_file_system { | 17 namespace sync_file_system { |
15 namespace drive_backend { | 18 namespace drive_backend { |
16 | 19 |
17 class FileMetadata; | 20 class FileMetadata; |
18 class FileTracker; | 21 class FileTracker; |
19 class TrackerIDSet; | 22 class TrackerIDSet; |
20 | 23 |
21 struct ParentIDAndTitle { | 24 struct ParentIDAndTitle { |
22 int64 parent_id; | 25 int64_t parent_id; |
23 std::string title; | 26 std::string title; |
24 | 27 |
25 ParentIDAndTitle(); | 28 ParentIDAndTitle(); |
26 ParentIDAndTitle(int64 parent_id, const std::string& title); | 29 ParentIDAndTitle(int64_t parent_id, const std::string& title); |
27 }; | 30 }; |
28 | 31 |
29 bool operator==(const ParentIDAndTitle& left, const ParentIDAndTitle& right); | 32 bool operator==(const ParentIDAndTitle& left, const ParentIDAndTitle& right); |
30 bool operator<(const ParentIDAndTitle& left, const ParentIDAndTitle& right); | 33 bool operator<(const ParentIDAndTitle& left, const ParentIDAndTitle& right); |
31 | 34 |
32 // Interface class to maintain indexes of MetadataDatabase. | 35 // Interface class to maintain indexes of MetadataDatabase. |
33 class MetadataDatabaseIndexInterface { | 36 class MetadataDatabaseIndexInterface { |
34 public: | 37 public: |
35 MetadataDatabaseIndexInterface() {} | 38 MetadataDatabaseIndexInterface() {} |
36 virtual ~MetadataDatabaseIndexInterface() {} | 39 virtual ~MetadataDatabaseIndexInterface() {} |
37 | 40 |
38 // Removes unreachable items. | 41 // Removes unreachable items. |
39 virtual void RemoveUnreachableItems() = 0; | 42 virtual void RemoveUnreachableItems() = 0; |
40 | 43 |
41 // Returns true if FileMetadata identified by |file_id| exists. | 44 // Returns true if FileMetadata identified by |file_id| exists. |
42 // If |metadata| is not NULL, the FileMetadata is copied to it. | 45 // If |metadata| is not NULL, the FileMetadata is copied to it. |
43 virtual bool GetFileMetadata( | 46 virtual bool GetFileMetadata( |
44 const std::string& file_id, FileMetadata* metadata) const = 0; | 47 const std::string& file_id, FileMetadata* metadata) const = 0; |
45 | 48 |
46 // Returns true if FileTracker identified by |tracker_id| exists. | 49 // Returns true if FileTracker identified by |tracker_id| exists. |
47 // If |tracker| is not NULL, the FileTracker is copied to it. | 50 // If |tracker| is not NULL, the FileTracker is copied to it. |
48 virtual bool GetFileTracker( | 51 virtual bool GetFileTracker(int64_t tracker_id, |
49 int64 tracker_id, FileTracker* tracker) const = 0; | 52 FileTracker* tracker) const = 0; |
50 | 53 |
51 // Stores |metadata| and updates indexes. | 54 // Stores |metadata| and updates indexes. |
52 // This overwrites existing FileMetadata for the same |file_id|. | 55 // This overwrites existing FileMetadata for the same |file_id|. |
53 virtual void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) = 0; | 56 virtual void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) = 0; |
54 | 57 |
55 // Stores |tracker| and updates indexes. | 58 // Stores |tracker| and updates indexes. |
56 // This overwrites existing FileTracker for the same |tracker_id|. | 59 // This overwrites existing FileTracker for the same |tracker_id|. |
57 virtual void StoreFileTracker(scoped_ptr<FileTracker> tracker) = 0; | 60 virtual void StoreFileTracker(scoped_ptr<FileTracker> tracker) = 0; |
58 | 61 |
59 // Removes FileMetadata identified by |file_id| from indexes. | 62 // Removes FileMetadata identified by |file_id| from indexes. |
60 virtual void RemoveFileMetadata(const std::string& file_id) = 0; | 63 virtual void RemoveFileMetadata(const std::string& file_id) = 0; |
61 | 64 |
62 // Removes FileTracker identified by |tracker_id| from indexes. | 65 // Removes FileTracker identified by |tracker_id| from indexes. |
63 virtual void RemoveFileTracker(int64 tracker_id) = 0; | 66 virtual void RemoveFileTracker(int64_t tracker_id) = 0; |
64 | 67 |
65 // Returns a set of FileTracker that have |file_id| as its own. | 68 // Returns a set of FileTracker that have |file_id| as its own. |
66 virtual TrackerIDSet GetFileTrackerIDsByFileID( | 69 virtual TrackerIDSet GetFileTrackerIDsByFileID( |
67 const std::string& file_id) const = 0; | 70 const std::string& file_id) const = 0; |
68 | 71 |
69 // Returns an app-root tracker identified by |app_id|. Returns 0 if not | 72 // Returns an app-root tracker identified by |app_id|. Returns 0 if not |
70 // found. | 73 // found. |
71 virtual int64 GetAppRootTracker(const std::string& app_id) const = 0; | 74 virtual int64_t GetAppRootTracker(const std::string& app_id) const = 0; |
72 | 75 |
73 // Returns a set of FileTracker that have |parent_tracker_id| and |title|. | 76 // Returns a set of FileTracker that have |parent_tracker_id| and |title|. |
74 virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle( | 77 virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle( |
75 int64 parent_tracker_id, | 78 int64_t parent_tracker_id, |
76 const std::string& title) const = 0; | 79 const std::string& title) const = 0; |
77 | 80 |
78 virtual std::vector<int64> GetFileTrackerIDsByParent( | 81 virtual std::vector<int64_t> GetFileTrackerIDsByParent( |
79 int64 parent_tracker_id) const = 0; | 82 int64_t parent_tracker_id) const = 0; |
80 | 83 |
81 // Returns the |file_id| of a file that has multiple trackers. | 84 // Returns the |file_id| of a file that has multiple trackers. |
82 virtual std::string PickMultiTrackerFileID() const = 0; | 85 virtual std::string PickMultiTrackerFileID() const = 0; |
83 | 86 |
84 // Returns a pair of |parent_tracker_id| and |title| that has multiple file | 87 // Returns a pair of |parent_tracker_id| and |title| that has multiple file |
85 // at the path. | 88 // at the path. |
86 virtual ParentIDAndTitle PickMultiBackingFilePath() const = 0; | 89 virtual ParentIDAndTitle PickMultiBackingFilePath() const = 0; |
87 | 90 |
88 // Returns a FileTracker whose |dirty| is set and which isn't demoted. | 91 // Returns a FileTracker whose |dirty| is set and which isn't demoted. |
89 // Returns 0 if not found. | 92 // Returns 0 if not found. |
90 virtual int64 PickDirtyTracker() const = 0; | 93 virtual int64_t PickDirtyTracker() const = 0; |
91 | 94 |
92 // Demotes a dirty tracker. | 95 // Demotes a dirty tracker. |
93 virtual void DemoteDirtyTracker(int64 tracker_id) = 0; | 96 virtual void DemoteDirtyTracker(int64_t tracker_id) = 0; |
94 | 97 |
95 virtual bool HasDemotedDirtyTracker() const = 0; | 98 virtual bool HasDemotedDirtyTracker() const = 0; |
96 virtual bool IsDemotedDirtyTracker(int64 tracker_id) const = 0; | 99 virtual bool IsDemotedDirtyTracker(int64_t tracker_id) const = 0; |
97 | 100 |
98 // Promotes single demoted dirty tracker to a normal dirty tracker. | 101 // Promotes single demoted dirty tracker to a normal dirty tracker. |
99 virtual void PromoteDemotedDirtyTracker(int64 tracker_id) = 0; | 102 virtual void PromoteDemotedDirtyTracker(int64_t tracker_id) = 0; |
100 | 103 |
101 // Promotes all demoted dirty trackers to normal dirty trackers. | 104 // Promotes all demoted dirty trackers to normal dirty trackers. |
102 // Returns true if any tracker was promoted. | 105 // Returns true if any tracker was promoted. |
103 virtual bool PromoteDemotedDirtyTrackers() = 0; | 106 virtual bool PromoteDemotedDirtyTrackers() = 0; |
104 | 107 |
105 virtual size_t CountDirtyTracker() const = 0; | 108 virtual size_t CountDirtyTracker() const = 0; |
106 virtual size_t CountFileMetadata() const = 0; | 109 virtual size_t CountFileMetadata() const = 0; |
107 virtual size_t CountFileTracker() const = 0; | 110 virtual size_t CountFileTracker() const = 0; |
108 | 111 |
109 virtual void SetSyncRootRevalidated() const = 0; | 112 virtual void SetSyncRootRevalidated() const = 0; |
110 virtual void SetSyncRootTrackerID(int64 sync_root_id) const = 0; | 113 virtual void SetSyncRootTrackerID(int64_t sync_root_id) const = 0; |
111 virtual void SetLargestChangeID(int64 largest_change_id) const = 0; | 114 virtual void SetLargestChangeID(int64_t largest_change_id) const = 0; |
112 virtual void SetNextTrackerID(int64 next_tracker_id) const = 0; | 115 virtual void SetNextTrackerID(int64_t next_tracker_id) const = 0; |
113 virtual bool IsSyncRootRevalidated() const = 0; | 116 virtual bool IsSyncRootRevalidated() const = 0; |
114 virtual int64 GetSyncRootTrackerID() const = 0; | 117 virtual int64_t GetSyncRootTrackerID() const = 0; |
115 virtual int64 GetLargestChangeID() const = 0; | 118 virtual int64_t GetLargestChangeID() const = 0; |
116 virtual int64 GetNextTrackerID() const = 0; | 119 virtual int64_t GetNextTrackerID() const = 0; |
117 virtual std::vector<std::string> GetRegisteredAppIDs() const = 0; | 120 virtual std::vector<std::string> GetRegisteredAppIDs() const = 0; |
118 virtual std::vector<int64> GetAllTrackerIDs() const = 0; | 121 virtual std::vector<int64_t> GetAllTrackerIDs() const = 0; |
119 virtual std::vector<std::string> GetAllMetadataIDs() const = 0; | 122 virtual std::vector<std::string> GetAllMetadataIDs() const = 0; |
120 | 123 |
121 private: | 124 private: |
122 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexInterface); | 125 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexInterface); |
123 }; | 126 }; |
124 | 127 |
125 } // namespace drive_backend | 128 } // namespace drive_backend |
126 } // namespace sync_file_system | 129 } // namespace sync_file_system |
127 | 130 |
128 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX
_INTERFACE_H_ | 131 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX
_INTERFACE_H_ |
OLD | NEW |