Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h

Issue 349543003: [SyncFS] Use pointers to MetadataDatabaseIndexInterface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
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_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/scoped_ptr.h"
12
13 namespace sync_file_system {
14 namespace drive_backend {
15
16 struct ParentIDAndTitle {
17 int64 parent_id;
18 std::string title;
19
20 ParentIDAndTitle();
21 ParentIDAndTitle(int64 parent_id, const std::string& title);
22 };
23
24 bool operator==(const ParentIDAndTitle& left, const ParentIDAndTitle& right);
25 bool operator<(const ParentIDAndTitle& left, const ParentIDAndTitle& right);
26
27 } // namespace drive_backend
28 } // namespace sync_file_system
29
30 namespace BASE_HASH_NAMESPACE {
31
32 #if defined(COMPILER_GCC)
33 template<> struct hash<sync_file_system::drive_backend::ParentIDAndTitle> {
34 std::size_t operator()(
35 const sync_file_system::drive_backend::ParentIDAndTitle& v) const {
36 return base::HashInts64(v.parent_id, hash<std::string>()(v.title));
37 }
38 };
39 #elif defined(COMPILER_MSVC)
40 inline size_t hash_value(
41 const sync_file_system::drive_backend::ParentIDAndTitle& v) {
42 return base::HashInts64(v.parent_id, hash_value(v.title));
43 }
44 #endif // COMPILER
tzik 2014/06/20 03:57:47 Can we move this block to the original file? I thi
peria 2014/06/20 04:44:22 Done.
45
46 } // namespace BASE_HASH_NAMESPACE
47
48 namespace sync_file_system {
49 namespace drive_backend {
50
51 class FileMetadata;
52 class FileTracker;
53
54 // Maintains indexes of MetadataDatabase. This class doesn't modify database
55 // entries on memory nor on disk.
tzik 2014/06/20 03:57:47 Could you update this comment? I think this is no
peria 2014/06/20 04:44:23 Done.
56 class MetadataDatabaseIndexInterface {
57 public:
58 MetadataDatabaseIndexInterface() {}
59 virtual ~MetadataDatabaseIndexInterface() {}
60
61 // Returns FileMetadata identified by |file_id| if exists, otherwise returns
62 // NULL.
63 virtual const FileMetadata* GetFileMetadata(
64 const std::string& file_id) const = 0;
65
66 // Returns FileTracker identified by |tracker_id| if exists, otherwise returns
67 // NULL.
68 virtual const FileTracker* GetFileTracker(int64 tracker_id) const = 0;
69
70 // Stores |metadata| and updates indexes.
71 // This overwrites existing FileMetadata for the same |file_id|.
72 virtual void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) = 0;
73
74 // Stores |tracker| and updates indexes.
75 // This overwrites existing FileTracker for the same |tracker_id|.
76 virtual void StoreFileTracker(scoped_ptr<FileTracker> tracker) = 0;
77
78 // Removes FileMetadata identified by |file_id| from indexes.
79 virtual void RemoveFileMetadata(const std::string& file_id) = 0;
80
81 // Removes FileTracker identified by |tracker_id| from indexes.
82 virtual void RemoveFileTracker(int64 tracker_id) = 0;
83
84 // Returns a set of FileTracker that have |file_id| as its own.
85 virtual TrackerIDSet GetFileTrackerIDsByFileID(
86 const std::string& file_id) const = 0;
87
88 // Returns an app-root tracker identified by |app_id|. Returns 0 if not
89 // found.
90 virtual int64 GetAppRootTracker(const std::string& app_id) const = 0;
91
92 // Returns a set of FileTracker that have |parent_tracker_id| and |title|.
93 virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle(
94 int64 parent_tracker_id,
95 const std::string& title) const = 0;
96
97 virtual std::vector<int64> GetFileTrackerIDsByParent(
98 int64 parent_tracker_id) const = 0;
99
100 // Returns the |file_id| of a file that has multiple trackers.
101 virtual std::string PickMultiTrackerFileID() const = 0;
102
103 // Returns a pair of |parent_tracker_id| and |title| that has multiple file
104 // at the path.
105 virtual ParentIDAndTitle PickMultiBackingFilePath() const = 0;
106
107 // Returns a FileTracker whose |dirty| is set and which isn't demoted.
108 // Returns 0 if not found.
109 virtual int64 PickDirtyTracker() const = 0;
110
111 // Demotes a dirty tracker.
112 virtual void DemoteDirtyTracker(int64 tracker_id) = 0;
113
114 virtual bool HasDemotedDirtyTracker() const = 0;
115
116 // Promotes all demoted dirty trackers to normal dirty trackers.
117 virtual void PromoteDemotedDirtyTrackers() = 0;
118
119 virtual size_t CountDirtyTracker() const = 0;
120 virtual size_t CountFileMetadata() const = 0;
121 virtual size_t CountFileTracker() const = 0;
122
123 virtual std::vector<std::string> GetRegisteredAppIDs() const = 0;
124 virtual std::vector<int64> GetAllTrackerIDs() const = 0;
125 virtual std::vector<std::string> GetAllMetadataIDs() const = 0;
126
127 private:
128 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexInterface);
129 };
130
131 } // namespace drive_backend
132 } // namespace sync_file_system
133
134 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX _INTERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698