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

Side by Side Diff: sync/sessions/ordered_commit_set.h

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/protocol/sync_protocol_error.h ('k') | sync/sessions/ordered_commit_set.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_SESSIONS_ORDERED_COMMIT_SET_H_ 5 #ifndef SYNC_SESSIONS_ORDERED_COMMIT_SET_H_
6 #define SYNC_SESSIONS_ORDERED_COMMIT_SET_H_ 6 #define SYNC_SESSIONS_ORDERED_COMMIT_SET_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 20 matching lines...) Expand all
31 31
32 // TODO(chron): Reserve space according to batch size? 32 // TODO(chron): Reserve space according to batch size?
33 explicit OrderedCommitSet(const syncer::ModelSafeRoutingInfo& routes); 33 explicit OrderedCommitSet(const syncer::ModelSafeRoutingInfo& routes);
34 ~OrderedCommitSet(); 34 ~OrderedCommitSet();
35 35
36 bool HaveCommitItem(const int64 metahandle) const { 36 bool HaveCommitItem(const int64 metahandle) const {
37 return inserted_metahandles_.count(metahandle) > 0; 37 return inserted_metahandles_.count(metahandle) > 0;
38 } 38 }
39 39
40 void AddCommitItem(const int64 metahandle, const syncable::Id& commit_id, 40 void AddCommitItem(const int64 metahandle, const syncable::Id& commit_id,
41 syncable::ModelType type); 41 syncer::ModelType type);
42 42
43 const std::vector<syncable::Id>& GetAllCommitIds() const { 43 const std::vector<syncable::Id>& GetAllCommitIds() const {
44 return commit_ids_; 44 return commit_ids_;
45 } 45 }
46 46
47 // Return the Id at index |position| in this OrderedCommitSet. Note that 47 // Return the Id at index |position| in this OrderedCommitSet. Note that
48 // the index uniquely identifies the same logical item in each of: 48 // the index uniquely identifies the same logical item in each of:
49 // 1) this OrderedCommitSet 49 // 1) this OrderedCommitSet
50 // 2) the CommitRequest sent to the server 50 // 2) the CommitRequest sent to the server
51 // 3) the list of EntryResponse objects in the CommitResponse. 51 // 3) the list of EntryResponse objects in the CommitResponse.
52 // These together allow re-association of the pre-commit Id with the 52 // These together allow re-association of the pre-commit Id with the
53 // actual committed entry. 53 // actual committed entry.
54 const syncable::Id& GetCommitIdAt(const size_t position) const { 54 const syncable::Id& GetCommitIdAt(const size_t position) const {
55 return commit_ids_[position]; 55 return commit_ids_[position];
56 } 56 }
57 57
58 // Same as above, but for ModelType of the item. 58 // Same as above, but for ModelType of the item.
59 syncable::ModelType GetModelTypeAt(const size_t position) const { 59 syncer::ModelType GetModelTypeAt(const size_t position) const {
60 return types_[position]; 60 return types_[position];
61 } 61 }
62 62
63 // Get the projection of commit ids onto the space of commit ids 63 // Get the projection of commit ids onto the space of commit ids
64 // belonging to |group|. This is useful when you need to process a commit 64 // belonging to |group|. This is useful when you need to process a commit
65 // response one ModelSafeGroup at a time. See GetCommitIdAt for how the 65 // response one ModelSafeGroup at a time. See GetCommitIdAt for how the
66 // indices contained in the returned Projection can be used. 66 // indices contained in the returned Projection can be used.
67 const Projection& GetCommitIdProjection( 67 const Projection& GetCommitIdProjection(
68 syncer::ModelSafeGroup group) const; 68 syncer::ModelSafeGroup group) const;
69 69
(...skipping 18 matching lines...) Expand all
88 88
89 void operator=(const OrderedCommitSet& other); 89 void operator=(const OrderedCommitSet& other);
90 private: 90 private:
91 // A set of CommitIdProjections associated with particular ModelSafeGroups. 91 // A set of CommitIdProjections associated with particular ModelSafeGroups.
92 typedef std::map<syncer::ModelSafeGroup, Projection> Projections; 92 typedef std::map<syncer::ModelSafeGroup, Projection> Projections;
93 93
94 // Helper container for return value of GetCommitItemAt. 94 // Helper container for return value of GetCommitItemAt.
95 struct CommitItem { 95 struct CommitItem {
96 int64 meta; 96 int64 meta;
97 syncable::Id id; 97 syncable::Id id;
98 syncable::ModelType group; 98 syncer::ModelType group;
99 }; 99 };
100 100
101 CommitItem GetCommitItemAt(const size_t position) const; 101 CommitItem GetCommitItemAt(const size_t position) const;
102 102
103 // These lists are different views of the same items; e.g they are 103 // These lists are different views of the same items; e.g they are
104 // isomorphic. 104 // isomorphic.
105 std::set<int64> inserted_metahandles_; 105 std::set<int64> inserted_metahandles_;
106 std::vector<syncable::Id> commit_ids_; 106 std::vector<syncable::Id> commit_ids_;
107 std::vector<int64> metahandle_order_; 107 std::vector<int64> metahandle_order_;
108 Projections projections_; 108 Projections projections_;
109 109
110 // We need this because of operations like AppendReverse that take ids from 110 // We need this because of operations like AppendReverse that take ids from
111 // one OrderedCommitSet and insert into another -- we need to know the 111 // one OrderedCommitSet and insert into another -- we need to know the
112 // group for each ID so that the insertion can update the appropriate 112 // group for each ID so that the insertion can update the appropriate
113 // projection. We could store it in commit_ids_, but sometimes we want 113 // projection. We could store it in commit_ids_, but sometimes we want
114 // to just return the vector of Ids, so this is more straightforward 114 // to just return the vector of Ids, so this is more straightforward
115 // and shouldn't take up too much extra space since commit lists are small. 115 // and shouldn't take up too much extra space since commit lists are small.
116 std::vector<syncable::ModelType> types_; 116 std::vector<syncer::ModelType> types_;
117 117
118 syncer::ModelSafeRoutingInfo routes_; 118 syncer::ModelSafeRoutingInfo routes_;
119 }; 119 };
120 120
121 } // namespace sessions 121 } // namespace sessions
122 } // namespace syncer 122 } // namespace syncer
123 123
124 #endif // SYNC_SESSIONS_ORDERED_COMMIT_SET_H_ 124 #endif // SYNC_SESSIONS_ORDERED_COMMIT_SET_H_
125 125
OLDNEW
« no previous file with comments | « sync/protocol/sync_protocol_error.h ('k') | sync/sessions/ordered_commit_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698