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

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

Issue 2689773002: [Sync] Replace typedef with using. (Closed)
Patch Set: [Sync] Replace typedef with using. Created 3 years, 10 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
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 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/syncable/syncable_id.h" 15 #include "components/sync/syncable/syncable_id.h"
16 16
17 namespace syncer { 17 namespace syncer {
18 namespace syncable { 18 namespace syncable {
19 19
20 struct EntryKernel; 20 struct EntryKernel;
21 class ParentChildIndex; 21 class ParentChildIndex;
22 22
23 // A node ordering function. 23 // A node ordering function.
24 struct ChildComparator { 24 struct ChildComparator {
25 bool operator()(const EntryKernel* a, const EntryKernel* b) const; 25 bool operator()(const EntryKernel* a, const EntryKernel* b) const;
26 }; 26 };
27 27
28 // An ordered set of nodes. 28 // An ordered set of nodes.
29 typedef std::set<EntryKernel*, ChildComparator> OrderedChildSet; 29 using OrderedChildSet = std::set<EntryKernel*, ChildComparator>;
30 typedef std::shared_ptr<OrderedChildSet> OrderedChildSetRef; 30 using OrderedChildSetRef = std::shared_ptr<OrderedChildSet>;
31 31
32 // Container that tracks parent-child relationships. 32 // Container that tracks parent-child relationships.
33 // Provides fast lookup of all items under a given parent. 33 // Provides fast lookup of all items under a given parent.
34 class ParentChildIndex { 34 class ParentChildIndex {
35 public: 35 public:
36 ParentChildIndex(); 36 ParentChildIndex();
37 ~ParentChildIndex(); 37 ~ParentChildIndex();
38 38
39 // Returns whether or not this entry belongs in the index. 39 // Returns whether or not this entry belongs in the index.
40 // True for all non-deleted, non-root entries. 40 // True for all non-deleted, non-root entries.
(...skipping 18 matching lines...) Expand all
59 59
60 // Returns all siblings of the entry. 60 // Returns all siblings of the entry.
61 const OrderedChildSet* GetSiblings(EntryKernel* e) const; 61 const OrderedChildSet* GetSiblings(EntryKernel* e) const;
62 62
63 // Estimates amount of heap memory used. 63 // Estimates amount of heap memory used.
64 size_t EstimateMemoryUsage() const; 64 size_t EstimateMemoryUsage() const;
65 65
66 private: 66 private:
67 friend class ParentChildIndexTest; 67 friend class ParentChildIndexTest;
68 68
69 typedef std::map<Id, OrderedChildSetRef> ParentChildrenMap; 69 using ParentChildrenMap = std::map<Id, OrderedChildSetRef>;
70 typedef std::vector<Id> TypeRootIds; 70 using TypeRootIds = std::vector<Id>;
71 typedef std::vector<OrderedChildSetRef> TypeRootChildSets; 71 using TypeRootChildSets = std::vector<OrderedChildSetRef>;
72 72
73 static bool ShouldUseParentId(const Id& parent_id, ModelType model_type); 73 static bool ShouldUseParentId(const Id& parent_id, ModelType model_type);
74 74
75 // Returns OrderedChildSet that should contain the specified entry 75 // Returns OrderedChildSet that should contain the specified entry
76 // based on the entry's Parent ID or model type. 76 // based on the entry's Parent ID or model type.
77 const OrderedChildSetRef GetChildSet(EntryKernel* e) const; 77 const OrderedChildSetRef GetChildSet(EntryKernel* e) const;
78 78
79 // Returns OrderedChildSet that contain entries of the |model_type| type. 79 // Returns OrderedChildSet that contain entries of the |model_type| type.
80 const OrderedChildSetRef GetModelTypeChildSet(ModelType model_type) const; 80 const OrderedChildSetRef GetModelTypeChildSet(ModelType model_type) const;
81 81
(...skipping 16 matching lines...) Expand all
98 // with implicit parent. 98 // with implicit parent.
99 TypeRootChildSets type_root_child_sets_; 99 TypeRootChildSets type_root_child_sets_;
100 100
101 DISALLOW_COPY_AND_ASSIGN(ParentChildIndex); 101 DISALLOW_COPY_AND_ASSIGN(ParentChildIndex);
102 }; 102 };
103 103
104 } // namespace syncable 104 } // namespace syncable
105 } // namespace syncer 105 } // namespace syncer
106 106
107 #endif // COMPONENTS_SYNC_SYNCABLE_PARENT_CHILD_INDEX_H_ 107 #endif // COMPONENTS_SYNC_SYNCABLE_PARENT_CHILD_INDEX_H_
OLDNEW
« no previous file with comments | « components/sync/syncable/nigori_util_unittest.cc ('k') | components/sync/syncable/syncable_delete_journal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698