OLD | NEW |
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 COMPONENTS_SYNC_SYNCABLE_PARENT_CHILD_INDEX_H_ | 5 #ifndef COMPONENTS_SYNC_SYNCABLE_PARENT_CHILD_INDEX_H_ |
6 #define COMPONENTS_SYNC_SYNCABLE_PARENT_CHILD_INDEX_H_ | 6 #define COMPONENTS_SYNC_SYNCABLE_PARENT_CHILD_INDEX_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "components/sync/base/model_type.h" | 14 #include "components/sync/base/model_type.h" |
15 #include "components/sync/base/sync_export.h" | |
16 #include "components/sync/syncable/syncable_id.h" | 15 #include "components/sync/syncable/syncable_id.h" |
17 | 16 |
18 namespace syncer { | 17 namespace syncer { |
19 namespace syncable { | 18 namespace syncable { |
20 | 19 |
21 struct EntryKernel; | 20 struct EntryKernel; |
22 class ParentChildIndex; | 21 class ParentChildIndex; |
23 | 22 |
24 // A node ordering function. | 23 // A node ordering function. |
25 struct SYNC_EXPORT ChildComparator { | 24 struct ChildComparator { |
26 bool operator()(const EntryKernel* a, const EntryKernel* b) const; | 25 bool operator()(const EntryKernel* a, const EntryKernel* b) const; |
27 }; | 26 }; |
28 | 27 |
29 // An ordered set of nodes. | 28 // An ordered set of nodes. |
30 typedef std::set<EntryKernel*, ChildComparator> OrderedChildSet; | 29 typedef std::set<EntryKernel*, ChildComparator> OrderedChildSet; |
31 typedef std::shared_ptr<OrderedChildSet> OrderedChildSetRef; | 30 typedef std::shared_ptr<OrderedChildSet> OrderedChildSetRef; |
32 | 31 |
33 // Container that tracks parent-child relationships. | 32 // Container that tracks parent-child relationships. |
34 // Provides fast lookup of all items under a given parent. | 33 // Provides fast lookup of all items under a given parent. |
35 class SYNC_EXPORT ParentChildIndex { | 34 class ParentChildIndex { |
36 public: | 35 public: |
37 ParentChildIndex(); | 36 ParentChildIndex(); |
38 ~ParentChildIndex(); | 37 ~ParentChildIndex(); |
39 | 38 |
40 // Returns whether or not this entry belongs in the index. | 39 // Returns whether or not this entry belongs in the index. |
41 // True for all non-deleted, non-root entries. | 40 // True for all non-deleted, non-root entries. |
42 static bool ShouldInclude(const EntryKernel* e); | 41 static bool ShouldInclude(const EntryKernel* e); |
43 | 42 |
44 // Inserts a given child into the index. | 43 // Inserts a given child into the index. |
45 bool Insert(EntryKernel* e); | 44 bool Insert(EntryKernel* e); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // with implicit parent. | 95 // with implicit parent. |
97 TypeRootChildSets type_root_child_sets_; | 96 TypeRootChildSets type_root_child_sets_; |
98 | 97 |
99 DISALLOW_COPY_AND_ASSIGN(ParentChildIndex); | 98 DISALLOW_COPY_AND_ASSIGN(ParentChildIndex); |
100 }; | 99 }; |
101 | 100 |
102 } // namespace syncable | 101 } // namespace syncable |
103 } // namespace syncer | 102 } // namespace syncer |
104 | 103 |
105 #endif // COMPONENTS_SYNC_SYNCABLE_PARENT_CHILD_INDEX_H_ | 104 #endif // COMPONENTS_SYNC_SYNCABLE_PARENT_CHILD_INDEX_H_ |
OLD | NEW |