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

Unified Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h

Issue 378213002: [SyncFS] Implement GetFileTrackerIDsByParent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work for a nit Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h
index df44df70d3882d0f5eae4942498e3a40edda1f79..86259a74067bbf28e80dcfb9a605b312d101afce 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h
@@ -50,8 +50,7 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
const std::string& file_id) const OVERRIDE;
virtual int64 GetAppRootTracker(const std::string& app_id) const OVERRIDE;
virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle(
- int64 parent_tracker_id,
- const std::string& title) const OVERRIDE;
+ int64 parent_tracker_id, const std::string& title) const OVERRIDE;
virtual std::vector<int64> GetFileTrackerIDsByParent(
int64 parent_tracker_id) const OVERRIDE;
virtual std::string PickMultiTrackerFileID() const OVERRIDE;
@@ -69,6 +68,12 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
virtual std::vector<std::string> GetAllMetadataIDs() const OVERRIDE;
private:
+ enum NumEntries {
+ NONE, // No entries are found.
+ SINGLE, // One entry is found.
+ MULTIPLE, // Two or more entires are found.
+ };
+
// Maintain indexes from AppIDs to tracker IDs.
void AddToAppIDIndex(const FileTracker& new_tracker,
leveldb::WriteBatch* batch);
@@ -78,7 +83,7 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
void RemoveFromAppIDIndex(const FileTracker& tracker,
leveldb::WriteBatch* batch);
- // Maintain indexes from remote file IDs to tracker IDs
+ // Maintain indexes from remote file IDs to tracker ID sets.
void AddToFileIDIndexes(const FileTracker& new_tracker,
leveldb::WriteBatch* batch);
void UpdateInFileIDIndexes(const FileTracker& old_tracker,
@@ -87,6 +92,15 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
void RemoveFromFileIDIndexes(const FileTracker& tracker,
leveldb::WriteBatch* batch);
+ // Maintain indexes from path indexes to tracker ID sets
+ void AddToPathIndexes(const FileTracker& new_tracker,
+ leveldb::WriteBatch* batch);
+ void UpdateInPathIndexes(const FileTracker& old_tracker,
+ const FileTracker& new_tracker,
+ leveldb::WriteBatch* batch);
+ void RemoveFromPathIndexes(const FileTracker& tracker,
+ leveldb::WriteBatch* batch);
+
// Maintain dirty tracker IDs.
void AddToDirtyTrackerIndexes(const FileTracker& new_tracker,
leveldb::WriteBatch* batch);
@@ -140,6 +154,10 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface {
// Checks if |db_| has an entry whose key is |key|.
bool DBHasKey(const std::string& key);
+ // Returns the number of entries starting with |prefix| in NumEntries format.
+ // Entries for |ignored_id| are not counted in.
+ NumEntries CountWithPrefix(const std::string& prefix, int64 ignored_id);
+
leveldb::DB* db_; // Not owned.
DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexOnDisk);

Powered by Google App Engine
This is Rietveld 408576698