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

Side by Side Diff: sync/syncable/parent_child_index.h

Issue 1008993004: Sync: Handle empty (implicit) ParentId in GetPredecessorId and GetSuccessorId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added extra unit test. Created 5 years, 9 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
« no previous file with comments | « sync/syncable/directory_unittest.cc ('k') | sync/syncable/parent_child_index.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SYNC_SYNCABLE_PARENT_CHILD_INDEX 5 #ifndef SYNC_SYNCABLE_PARENT_CHILD_INDEX
6 #define SYNC_SYNCABLE_PARENT_CHILD_INDEX 6 #define SYNC_SYNCABLE_PARENT_CHILD_INDEX
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 bool Insert(EntryKernel* e); 42 bool Insert(EntryKernel* e);
43 43
44 // Removes a given child from the index. 44 // Removes a given child from the index.
45 void Remove(EntryKernel* e); 45 void Remove(EntryKernel* e);
46 46
47 // Returns true if this item is in the index as a child. 47 // Returns true if this item is in the index as a child.
48 bool Contains(EntryKernel* e) const; 48 bool Contains(EntryKernel* e) const;
49 49
50 // Returns all children of the entry with the given Id. Returns NULL if the 50 // Returns all children of the entry with the given Id. Returns NULL if the
51 // node has no children or the Id does not identify a valid directory node. 51 // node has no children or the Id does not identify a valid directory node.
52 const OrderedChildSet* GetChildren(const Id& id); 52 const OrderedChildSet* GetChildren(const Id& id) const;
53
54 // Returns all children of the entry. Returns NULL if the node has no
55 // children.
56 const OrderedChildSet* GetChildren(EntryKernel* e) const;
57
58 // Returns all siblings of the entry.
59 const OrderedChildSet* GetSiblings(EntryKernel* e) const;
53 60
54 private: 61 private:
55 friend class ParentChildIndexTest; 62 friend class ParentChildIndexTest;
56 typedef std::map<Id, OrderedChildSet*> ParentChildrenMap; 63 typedef std::map<Id, OrderedChildSet*> ParentChildrenMap;
57 64
58 // Determines entry's model type. 65 // Determines entry's model type.
59 static ModelType GetModelType(EntryKernel* e); 66 static ModelType GetModelType(EntryKernel* e);
60 67
61 // Returns parent ID for the entry which is either its PARENT_ID value 68 // Returns parent ID for the entry which is either its PARENT_ID value
62 // or derived from its model type. 69 // or derived from its model type.
63 const Id& GetParentId(EntryKernel* e) const; 70 const Id& GetParentId(EntryKernel* e) const;
64 71
65 // Returns previously cached model type root ID for the given |model_type|. 72 // Returns previously cached model type root ID for the given |model_type|.
66 const Id& GetModelTypeRootId(ModelType model_type) const; 73 const Id& GetModelTypeRootId(ModelType model_type) const;
67 74
68 // A map of parent IDs to children. 75 // A map of parent IDs to children.
69 // Parents with no children are not included in this map. 76 // Parents with no children are not included in this map.
70 ParentChildrenMap parent_children_map_; 77 ParentChildrenMap parent_children_map_;
71 78
72 // This array tracks model type roots IDs. 79 // This array tracks model type roots IDs.
73 Id model_type_root_ids_[MODEL_TYPE_COUNT]; 80 Id model_type_root_ids_[MODEL_TYPE_COUNT];
74 81
75 DISALLOW_COPY_AND_ASSIGN(ParentChildIndex); 82 DISALLOW_COPY_AND_ASSIGN(ParentChildIndex);
76 }; 83 };
77 84
78 } // namespace syncable 85 } // namespace syncable
79 } // namespace syncer 86 } // namespace syncer
80 87
81 #endif // SYNC_SYNCABLE_PARENT_CHILD_INDEX 88 #endif // SYNC_SYNCABLE_PARENT_CHILD_INDEX
OLDNEW
« no previous file with comments | « sync/syncable/directory_unittest.cc ('k') | sync/syncable/parent_child_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698