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

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

Issue 11636006: WIP: The Bookmark Position Megapatch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Various updates, including switch suffix to unique_client_tag style Created 8 years 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
« no previous file with comments | « sync/syncable/nigori_util.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SYNC_SYNCABLE_PARENT_CHILD_INDEX
6 #define SYNC_SYNCABLE_PARENT_CHILD_INDEX
7
8 #include <map>
9 #include <set>
10
11 namespace syncer {
12 namespace syncable {
13
14 struct EntryKernel;
15 class Id;
16 class ParentChildIndex;
17
18 // A node ordering function.
19 struct ChildComparator {
20 bool operator() (const EntryKernel* a, const EntryKernel* b) const;
21 };
22
23 // An ordered set of nodes.
24 typedef std::set<EntryKernel*, ChildComparator> ChildSet;
25
26 // Container that tracks parent-child relationships.
27 // Provides fast lookup of all items under a given parent.
28 class ParentChildIndex {
29 public:
30 ParentChildIndex();
31 ~ParentChildIndex();
32
33 // Returns whether or not this entry belongs in the index.
34 // True for all non-deleted, non-root entries.
35 static bool ShouldInclude(const EntryKernel* e);
36
37 // Inserts a given child into the index.
38 bool Insert(EntryKernel* e);
39
40 // Removes a given child from the index.
41 void Remove(EntryKernel* e);
42
43 // Returns true if this item is in the index as a child.
44 bool Contains(EntryKernel* e) const;
45
46 // Returns all children of the entry with the given Id. Returns NULL if the
47 // node has no children or the Id does not identify a valid directory node.
48 const ChildSet* GetChildren(const Id& id);
49
50 private:
51 typedef std::map<syncable::Id, ChildSet*> ParentChildrenMap;
52
53 // A map of parent IDs to children.
54 // Parents with no children are not included in this map.
55 ParentChildrenMap parent_children_map_;
56 };
57
58 } // namespace syncable
59 } // namespace syncer
60
61 #endif // SYNC_SYNCABLE_PARENT_CHILD_INDEX
OLDNEW
« no previous file with comments | « sync/syncable/nigori_util.cc ('k') | sync/syncable/parent_child_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698