| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 | 12 |
| 13 namespace leveldb { | |
| 14 class WriteBatch; | |
| 15 } | |
| 16 | |
| 17 namespace sync_file_system { | 13 namespace sync_file_system { |
| 18 namespace drive_backend { | 14 namespace drive_backend { |
| 19 | 15 |
| 20 class FileMetadata; | 16 class FileMetadata; |
| 21 class FileTracker; | 17 class FileTracker; |
| 22 class TrackerIDSet; | 18 class TrackerIDSet; |
| 23 | 19 |
| 24 struct ParentIDAndTitle { | 20 struct ParentIDAndTitle { |
| 25 int64 parent_id; | 21 int64 parent_id; |
| 26 std::string title; | 22 std::string title; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 virtual bool GetFileMetadata( | 39 virtual bool GetFileMetadata( |
| 44 const std::string& file_id, FileMetadata* metadata) const = 0; | 40 const std::string& file_id, FileMetadata* metadata) const = 0; |
| 45 | 41 |
| 46 // Returns true if FileTracker identified by |tracker_id| exists. | 42 // Returns true if FileTracker identified by |tracker_id| exists. |
| 47 // If |tracker| is not NULL, the FileTracker is copied to it. | 43 // If |tracker| is not NULL, the FileTracker is copied to it. |
| 48 virtual bool GetFileTracker( | 44 virtual bool GetFileTracker( |
| 49 int64 tracker_id, FileTracker* tracker) const = 0; | 45 int64 tracker_id, FileTracker* tracker) const = 0; |
| 50 | 46 |
| 51 // Stores |metadata| and updates indexes. | 47 // Stores |metadata| and updates indexes. |
| 52 // This overwrites existing FileMetadata for the same |file_id|. | 48 // This overwrites existing FileMetadata for the same |file_id|. |
| 53 virtual void StoreFileMetadata( | 49 virtual void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) = 0; |
| 54 scoped_ptr<FileMetadata> metadata, leveldb::WriteBatch* batch) = 0; | |
| 55 | 50 |
| 56 // Stores |tracker| and updates indexes. | 51 // Stores |tracker| and updates indexes. |
| 57 // This overwrites existing FileTracker for the same |tracker_id|. | 52 // This overwrites existing FileTracker for the same |tracker_id|. |
| 58 virtual void StoreFileTracker( | 53 virtual void StoreFileTracker(scoped_ptr<FileTracker> tracker) = 0; |
| 59 scoped_ptr<FileTracker> tracker, leveldb::WriteBatch* batch) = 0; | |
| 60 | 54 |
| 61 // Removes FileMetadata identified by |file_id| from indexes. | 55 // Removes FileMetadata identified by |file_id| from indexes. |
| 62 virtual void RemoveFileMetadata( | 56 virtual void RemoveFileMetadata(const std::string& file_id) = 0; |
| 63 const std::string& file_id, leveldb::WriteBatch* batch) = 0; | |
| 64 | 57 |
| 65 // Removes FileTracker identified by |tracker_id| from indexes. | 58 // Removes FileTracker identified by |tracker_id| from indexes. |
| 66 virtual void RemoveFileTracker( | 59 virtual void RemoveFileTracker(int64 tracker_id) = 0; |
| 67 int64 tracker_id, leveldb::WriteBatch* batch) = 0; | |
| 68 | 60 |
| 69 // Returns a set of FileTracker that have |file_id| as its own. | 61 // Returns a set of FileTracker that have |file_id| as its own. |
| 70 virtual TrackerIDSet GetFileTrackerIDsByFileID( | 62 virtual TrackerIDSet GetFileTrackerIDsByFileID( |
| 71 const std::string& file_id) const = 0; | 63 const std::string& file_id) const = 0; |
| 72 | 64 |
| 73 // Returns an app-root tracker identified by |app_id|. Returns 0 if not | 65 // Returns an app-root tracker identified by |app_id|. Returns 0 if not |
| 74 // found. | 66 // found. |
| 75 virtual int64 GetAppRootTracker(const std::string& app_id) const = 0; | 67 virtual int64 GetAppRootTracker(const std::string& app_id) const = 0; |
| 76 | 68 |
| 77 // Returns a set of FileTracker that have |parent_tracker_id| and |title|. | 69 // Returns a set of FileTracker that have |parent_tracker_id| and |title|. |
| 78 virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle( | 70 virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle( |
| 79 int64 parent_tracker_id, | 71 int64 parent_tracker_id, |
| 80 const std::string& title) const = 0; | 72 const std::string& title) const = 0; |
| 81 | 73 |
| 82 virtual std::vector<int64> GetFileTrackerIDsByParent( | 74 virtual std::vector<int64> GetFileTrackerIDsByParent( |
| 83 int64 parent_tracker_id) const = 0; | 75 int64 parent_tracker_id) const = 0; |
| 84 | 76 |
| 85 // Returns the |file_id| of a file that has multiple trackers. | 77 // Returns the |file_id| of a file that has multiple trackers. |
| 86 virtual std::string PickMultiTrackerFileID() const = 0; | 78 virtual std::string PickMultiTrackerFileID() const = 0; |
| 87 | 79 |
| 88 // Returns a pair of |parent_tracker_id| and |title| that has multiple file | 80 // Returns a pair of |parent_tracker_id| and |title| that has multiple file |
| 89 // at the path. | 81 // at the path. |
| 90 virtual ParentIDAndTitle PickMultiBackingFilePath() const = 0; | 82 virtual ParentIDAndTitle PickMultiBackingFilePath() const = 0; |
| 91 | 83 |
| 92 // Returns a FileTracker whose |dirty| is set and which isn't demoted. | 84 // Returns a FileTracker whose |dirty| is set and which isn't demoted. |
| 93 // Returns 0 if not found. | 85 // Returns 0 if not found. |
| 94 virtual int64 PickDirtyTracker() const = 0; | 86 virtual int64 PickDirtyTracker() const = 0; |
| 95 | 87 |
| 96 // Demotes a dirty tracker. | 88 // Demotes a dirty tracker. |
| 97 virtual void DemoteDirtyTracker( | 89 virtual void DemoteDirtyTracker(int64 tracker_id) = 0; |
| 98 int64 tracker_id, leveldb::WriteBatch* batch) = 0; | |
| 99 | 90 |
| 100 virtual bool HasDemotedDirtyTracker() const = 0; | 91 virtual bool HasDemotedDirtyTracker() const = 0; |
| 101 | 92 |
| 102 // Promotes all demoted dirty trackers to normal dirty trackers. | 93 // Promotes all demoted dirty trackers to normal dirty trackers. |
| 103 virtual void PromoteDemotedDirtyTrackers(leveldb::WriteBatch* batch) = 0; | 94 virtual void PromoteDemotedDirtyTrackers() = 0; |
| 104 | 95 |
| 105 virtual size_t CountDirtyTracker() const = 0; | 96 virtual size_t CountDirtyTracker() const = 0; |
| 106 virtual size_t CountFileMetadata() const = 0; | 97 virtual size_t CountFileMetadata() const = 0; |
| 107 virtual size_t CountFileTracker() const = 0; | 98 virtual size_t CountFileTracker() const = 0; |
| 108 | 99 |
| 109 virtual void SetSyncRootTrackerID(int64 sync_root_id, | 100 virtual void SetSyncRootTrackerID(int64 sync_root_id) const = 0; |
| 110 leveldb::WriteBatch* batch) const = 0; | 101 virtual void SetLargestChangeID(int64 largest_change_id) const = 0; |
| 111 virtual void SetLargestChangeID(int64 largest_change_id, | 102 virtual void SetNextTrackerID(int64 next_tracker_id) const = 0; |
| 112 leveldb::WriteBatch* batch) const = 0; | |
| 113 virtual void SetNextTrackerID(int64 next_tracker_id, | |
| 114 leveldb::WriteBatch* batch) const = 0; | |
| 115 virtual int64 GetSyncRootTrackerID() const = 0; | 103 virtual int64 GetSyncRootTrackerID() const = 0; |
| 116 virtual int64 GetLargestChangeID() const = 0; | 104 virtual int64 GetLargestChangeID() const = 0; |
| 117 virtual int64 GetNextTrackerID() const = 0; | 105 virtual int64 GetNextTrackerID() const = 0; |
| 118 virtual std::vector<std::string> GetRegisteredAppIDs() const = 0; | 106 virtual std::vector<std::string> GetRegisteredAppIDs() const = 0; |
| 119 virtual std::vector<int64> GetAllTrackerIDs() const = 0; | 107 virtual std::vector<int64> GetAllTrackerIDs() const = 0; |
| 120 virtual std::vector<std::string> GetAllMetadataIDs() const = 0; | 108 virtual std::vector<std::string> GetAllMetadataIDs() const = 0; |
| 121 | 109 |
| 122 private: | 110 private: |
| 123 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexInterface); | 111 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexInterface); |
| 124 }; | 112 }; |
| 125 | 113 |
| 126 } // namespace drive_backend | 114 } // namespace drive_backend |
| 127 } // namespace sync_file_system | 115 } // namespace sync_file_system |
| 128 | 116 |
| 129 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX
_INTERFACE_H_ | 117 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX
_INTERFACE_H_ |
| OLD | NEW |