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

Unified Diff: sync/syncable/parent_child_index.h

Issue 1226213002: Sync: Support nodes with implicit permanent folders: Node Browser and out-of-order loading from DB (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 5 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: sync/syncable/parent_child_index.h
diff --git a/sync/syncable/parent_child_index.h b/sync/syncable/parent_child_index.h
index 84c0771403e566642e6065962f463bb0d9cde16a..7e1572760bd1336b91b2c65b40f06303b33c634b 100644
--- a/sync/syncable/parent_child_index.h
+++ b/sync/syncable/parent_child_index.h
@@ -60,14 +60,23 @@ class SYNC_EXPORT_PRIVATE ParentChildIndex {
private:
friend class ParentChildIndexTest;
+
typedef std::map<Id, OrderedChildSet*> ParentChildrenMap;
+ typedef std::vector<Id> TypeRootIds;
+ typedef std::vector<OrderedChildSet*> TypeRootChildSets;
+
+ static bool ShouldUseParentId(const Id& parent_id, ModelType model_type);
- // Determines entry's model type.
- static ModelType GetModelType(EntryKernel* e);
+ // Returns OrderedChildSet that should contain the specified entry
+ // based on the entry's Parent ID or model type.
+ const OrderedChildSet* GetChildSet(EntryKernel* e) const;
- // Returns parent ID for the entry which is either its PARENT_ID value
- // or derived from its model type.
- const Id& GetParentId(EntryKernel* e) const;
+ // Returns OrderedChildSet that contain entries of the |model_type| type.
+ const OrderedChildSet* GetModelTypeChildSet(ModelType model_type) const;
+
+ // Returns mutable OrderedChildSet that contain entries of the |model_type|
+ // type. Create one as necessary.
+ OrderedChildSet* GetOrCreateModelTypeChildSet(ModelType model_type);
// Returns previously cached model type root ID for the given |model_type|.
const Id& GetModelTypeRootId(ModelType model_type) const;
@@ -77,7 +86,12 @@ class SYNC_EXPORT_PRIVATE ParentChildIndex {
ParentChildrenMap parent_children_map_;
// This array tracks model type roots IDs.
- Id model_type_root_ids_[MODEL_TYPE_COUNT];
+ TypeRootIds model_type_root_ids_;
+
+ // This array contains pre-defined child sets for
+ // non-hierarchical types (types with flat hierarchy) that support entries
+ // with implicit parent.
+ TypeRootChildSets type_root_child_sets_;
DISALLOW_COPY_AND_ASSIGN(ParentChildIndex);
};

Powered by Google App Engine
This is Rietveld 408576698