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 #include "sync/sessions/ordered_commit_set.h" | 5 #include "sync/sessions/ordered_commit_set.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
11 namespace syncer { | 11 namespace syncer { |
12 namespace sessions { | 12 namespace sessions { |
13 | 13 |
14 OrderedCommitSet::OrderedCommitSet(const ModelSafeRoutingInfo& routes) | 14 OrderedCommitSet::OrderedCommitSet(const ModelSafeRoutingInfo& routes) |
15 : routes_(routes) { | 15 : routes_(routes) { |
16 } | 16 } |
17 | 17 |
18 OrderedCommitSet::~OrderedCommitSet() {} | 18 OrderedCommitSet::~OrderedCommitSet() {} |
19 | 19 |
20 void OrderedCommitSet::AddCommitItem(const int64 metahandle, | 20 void OrderedCommitSet::AddCommitItem(const int64 metahandle, |
21 const syncable::Id& commit_id, | 21 const syncable::Id& commit_id, |
22 ModelType type) { | 22 ModelType type) { |
23 if (!HaveCommitItem(metahandle)) { | 23 if (!HaveCommitItem(metahandle)) { |
24 inserted_metahandles_.insert(metahandle); | 24 inserted_metahandles_.insert(metahandle); |
25 metahandle_order_.push_back(metahandle); | 25 metahandle_order_.push_back(metahandle); |
26 commit_ids_.push_back(commit_id); | 26 commit_ids_.push_back(commit_id); |
27 projections_[GetGroupForModelType(type, routes_)].push_back( | 27 projections_[GetGroupForModelType(type, routes_)].push_back( |
28 commit_ids_.size() - 1); | 28 commit_ids_.size() - 1); |
29 types_.push_back(type); | 29 types_.push_back(type); |
| 30 types_in_list_.Put(type); |
30 } | 31 } |
31 } | 32 } |
32 | 33 |
33 const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection( | 34 const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection( |
34 ModelSafeGroup group) const { | 35 ModelSafeGroup group) const { |
35 Projections::const_iterator i = projections_.find(group); | 36 Projections::const_iterator i = projections_.find(group); |
36 DCHECK(i != projections_.end()); | 37 DCHECK(i != projections_.end()); |
37 return i->second; | 38 return i->second; |
38 } | 39 } |
39 | 40 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 80 |
80 void OrderedCommitSet::Clear() { | 81 void OrderedCommitSet::Clear() { |
81 inserted_metahandles_.clear(); | 82 inserted_metahandles_.clear(); |
82 commit_ids_.clear(); | 83 commit_ids_.clear(); |
83 metahandle_order_.clear(); | 84 metahandle_order_.clear(); |
84 for (Projections::iterator it = projections_.begin(); | 85 for (Projections::iterator it = projections_.begin(); |
85 it != projections_.end(); ++it) { | 86 it != projections_.end(); ++it) { |
86 it->second.clear(); | 87 it->second.clear(); |
87 } | 88 } |
88 types_.clear(); | 89 types_.clear(); |
| 90 types_in_list_.Clear(); |
89 } | 91 } |
90 | 92 |
91 OrderedCommitSet::CommitItem OrderedCommitSet::GetCommitItemAt( | 93 OrderedCommitSet::CommitItem OrderedCommitSet::GetCommitItemAt( |
92 const size_t position) const { | 94 const size_t position) const { |
93 DCHECK(position < Size()); | 95 DCHECK(position < Size()); |
94 CommitItem return_item = {metahandle_order_[position], | 96 CommitItem return_item = {metahandle_order_[position], |
95 commit_ids_[position], | 97 commit_ids_[position], |
96 types_[position]}; | 98 types_[position]}; |
97 return return_item; | 99 return return_item; |
98 } | 100 } |
(...skipping 18 matching lines...) Expand all Loading... |
117 commit_ids_ = other.commit_ids_; | 119 commit_ids_ = other.commit_ids_; |
118 metahandle_order_ = other.metahandle_order_; | 120 metahandle_order_ = other.metahandle_order_; |
119 projections_ = other.projections_; | 121 projections_ = other.projections_; |
120 types_ = other.types_; | 122 types_ = other.types_; |
121 routes_ = other.routes_; | 123 routes_ = other.routes_; |
122 } | 124 } |
123 | 125 |
124 } // namespace sessions | 126 } // namespace sessions |
125 } // namespace syncer | 127 } // namespace syncer |
126 | 128 |
OLD | NEW |