Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / drive_backend / metadata_database_index_interface.h
blob388cf485a5b5043167bfbcf7d760b8b1e76bfd11
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_INTERFACE_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_INTERFACE_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
13 namespace sync_file_system {
14 namespace drive_backend {
16 class FileMetadata;
17 class FileTracker;
18 class TrackerIDSet;
20 struct ParentIDAndTitle {
21 int64 parent_id;
22 std::string title;
24 ParentIDAndTitle();
25 ParentIDAndTitle(int64 parent_id, const std::string& title);
28 bool operator==(const ParentIDAndTitle& left, const ParentIDAndTitle& right);
29 bool operator<(const ParentIDAndTitle& left, const ParentIDAndTitle& right);
31 // Interface class to maintain indexes of MetadataDatabase.
32 class MetadataDatabaseIndexInterface {
33 public:
34 MetadataDatabaseIndexInterface() {}
35 virtual ~MetadataDatabaseIndexInterface() {}
37 // Returns true if FileMetadata identified by |file_id| exists.
38 // If |metadata| is not NULL, the FileMetadata is copied to it.
39 virtual bool GetFileMetadata(
40 const std::string& file_id, FileMetadata* metadata) const = 0;
42 // Returns true if FileTracker identified by |tracker_id| exists.
43 // If |tracker| is not NULL, the FileTracker is copied to it.
44 virtual bool GetFileTracker(
45 int64 tracker_id, FileTracker* tracker) const = 0;
47 // Stores |metadata| and updates indexes.
48 // This overwrites existing FileMetadata for the same |file_id|.
49 virtual void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) = 0;
51 // Stores |tracker| and updates indexes.
52 // This overwrites existing FileTracker for the same |tracker_id|.
53 virtual void StoreFileTracker(scoped_ptr<FileTracker> tracker) = 0;
55 // Removes FileMetadata identified by |file_id| from indexes.
56 virtual void RemoveFileMetadata(const std::string& file_id) = 0;
58 // Removes FileTracker identified by |tracker_id| from indexes.
59 virtual void RemoveFileTracker(int64 tracker_id) = 0;
61 // Returns a set of FileTracker that have |file_id| as its own.
62 virtual TrackerIDSet GetFileTrackerIDsByFileID(
63 const std::string& file_id) const = 0;
65 // Returns an app-root tracker identified by |app_id|. Returns 0 if not
66 // found.
67 virtual int64 GetAppRootTracker(const std::string& app_id) const = 0;
69 // Returns a set of FileTracker that have |parent_tracker_id| and |title|.
70 virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle(
71 int64 parent_tracker_id,
72 const std::string& title) const = 0;
74 virtual std::vector<int64> GetFileTrackerIDsByParent(
75 int64 parent_tracker_id) const = 0;
77 // Returns the |file_id| of a file that has multiple trackers.
78 virtual std::string PickMultiTrackerFileID() const = 0;
80 // Returns a pair of |parent_tracker_id| and |title| that has multiple file
81 // at the path.
82 virtual ParentIDAndTitle PickMultiBackingFilePath() const = 0;
84 // Returns a FileTracker whose |dirty| is set and which isn't demoted.
85 // Returns 0 if not found.
86 virtual int64 PickDirtyTracker() const = 0;
88 // Demotes a dirty tracker.
89 virtual void DemoteDirtyTracker(int64 tracker_id) = 0;
91 virtual bool HasDemotedDirtyTracker() const = 0;
92 virtual bool IsDemotedDirtyTracker(int64 tracker_id) const = 0;
94 // Promotes single demoted dirty tracker to a normal dirty tracker.
95 virtual void PromoteDemotedDirtyTracker(int64 tracker_id) = 0;
97 // Promotes all demoted dirty trackers to normal dirty trackers.
98 // Returns true if any tracker was promoted.
99 virtual bool PromoteDemotedDirtyTrackers() = 0;
101 virtual size_t CountDirtyTracker() const = 0;
102 virtual size_t CountFileMetadata() const = 0;
103 virtual size_t CountFileTracker() const = 0;
105 virtual void SetSyncRootTrackerID(int64 sync_root_id) const = 0;
106 virtual void SetLargestChangeID(int64 largest_change_id) const = 0;
107 virtual void SetNextTrackerID(int64 next_tracker_id) const = 0;
108 virtual int64 GetSyncRootTrackerID() const = 0;
109 virtual int64 GetLargestChangeID() const = 0;
110 virtual int64 GetNextTrackerID() const = 0;
111 virtual std::vector<std::string> GetRegisteredAppIDs() const = 0;
112 virtual std::vector<int64> GetAllTrackerIDs() const = 0;
113 virtual std::vector<std::string> GetAllMetadataIDs() const = 0;
115 private:
116 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexInterface);
119 } // namespace drive_backend
120 } // namespace sync_file_system
122 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_INTERFACE_H_