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

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: Fixed memory leak 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..6689812da803fad2dbf6faf86df3429b8fcbb61a 100644
--- a/sync/syncable/parent_child_index.h
+++ b/sync/syncable/parent_child_index.h
@@ -60,14 +60,32 @@ class SYNC_EXPORT_PRIVATE ParentChildIndex {
private:
friend class ParentChildIndexTest;
- typedef std::map<Id, OrderedChildSet*> ParentChildrenMap;
- // Determines entry's model type.
- static ModelType GetModelType(EntryKernel* e);
+ struct ChildSetEntry {
Nicolas Zea 2015/07/09 20:36:34 Comment about what this does? In particular would
stanisc 2015/07/09 21:45:17 The main problem is that entries might be inserted
stanisc 2015/07/09 23:59:27 Done. Reimplemented this without ChildSetEntry.
+ ChildSetEntry(OrderedChildSet* child_set, bool owned)
+ : child_set_(child_set), owned_(owned) {}
- // 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;
+ OrderedChildSet* const& child_set() const { return child_set_; }
+ bool owned() const { return owned_; }
+
+ static const ChildSetEntry& Empty();
+
+ private:
+ OrderedChildSet* child_set_;
+ bool owned_;
+ };
+
+ typedef std::map<Id, ChildSetEntry> ParentChildrenMap;
+
+ static bool ShouldUseParentId(const Id& parent_id, ModelType model_type);
+
+ // Returns OrderedChildSet that should contain the specified entry
+ // based on the entry's Parent ID or model type.
+ const OrderedChildSet* GetChildSet(EntryKernel* e) const;
+
+ // Inserts a new child set in the map. The ownership depends on
+ // |child_set_entry.owned()| flag.
+ void InsertChildSet(const Id& id, const ChildSetEntry& child_set_entry);
// Returns previously cached model type root ID for the given |model_type|.
const Id& GetModelTypeRootId(ModelType model_type) const;
@@ -78,6 +96,10 @@ class SYNC_EXPORT_PRIVATE ParentChildIndex {
// This array tracks model type roots IDs.
Id model_type_root_ids_[MODEL_TYPE_COUNT];
+ // This array contains pre-defined child sets for
Nicolas Zea 2015/07/09 20:36:34 nit: newline above
stanisc 2015/07/09 23:59:27 Done.
+ // non-hierarchical types (types with flat hierarchy) that support entries
+ // with implicit parent.
+ OrderedChildSet type_root_child_sets_[MODEL_TYPE_COUNT];
DISALLOW_COPY_AND_ASSIGN(ParentChildIndex);
};

Powered by Google App Engine
This is Rietveld 408576698