summaryrefslogtreecommitdiffstats
path: root/sync/sessions/ordered_commit_set.cc
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-04 04:50:58 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-04 04:50:58 +0000
commit093722c9efb1143e17bfaf981f1680da2207171e (patch)
tree2e8ea397f692ac790817c56441755af7c8ce9bac /sync/sessions/ordered_commit_set.cc
parent1ba18129d43852bdf15884cb05261eb53fd5c05a (diff)
downloadchromium_src-093722c9efb1143e17bfaf981f1680da2207171e.zip
chromium_src-093722c9efb1143e17bfaf981f1680da2207171e.tar.gz
chromium_src-093722c9efb1143e17bfaf981f1680da2207171e.tar.bz2
sync: Remove IDs from OrderedCommitSet
Remove the IDs from OrderedCommitSet in order to add a new member, AddCommitItems(). Removing the IDs from this class would have been a good idea on its own. There hasn't been any need to track both IDs and metahandles for quite some time, and storing redundant information always carries the risk that the two copies will disagree with each other. It is particularly risky in this case because the entries' IDs will be changed when a commit response is successful. The AddCommitItems() function would have needed to have an inconvenient signature if it had to pass in both the handles and IDs of all the entries being added to the set. It's much easier to implement now that we only need to pass in the entries' metahandles. The new member function is not used in this commit. It will be used in a future commit that allows us to run GetCommitIdsCommand on a single model type at a time. BUG=278484 Review URL: https://chromiumcodereview.appspot.com/23694004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221154 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/sessions/ordered_commit_set.cc')
-rw-r--r--sync/sessions/ordered_commit_set.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/sync/sessions/ordered_commit_set.cc b/sync/sessions/ordered_commit_set.cc
index 842a0e9..3bbddb9 100644
--- a/sync/sessions/ordered_commit_set.cc
+++ b/sync/sessions/ordered_commit_set.cc
@@ -18,19 +18,26 @@ OrderedCommitSet::OrderedCommitSet(const ModelSafeRoutingInfo& routes)
OrderedCommitSet::~OrderedCommitSet() {}
void OrderedCommitSet::AddCommitItem(const int64 metahandle,
- const syncable::Id& commit_id,
ModelType type) {
if (!HaveCommitItem(metahandle)) {
inserted_metahandles_.insert(metahandle);
metahandle_order_.push_back(metahandle);
- commit_ids_.push_back(commit_id);
projections_[GetGroupForModelType(type, routes_)].push_back(
- commit_ids_.size() - 1);
+ inserted_metahandles_.size() - 1);
types_.push_back(type);
types_in_list_.Put(type);
}
}
+void OrderedCommitSet::AddCommitItems(
+ const std::vector<int64> metahandles,
+ ModelType type) {
+ for (std::vector<int64>::const_iterator it = metahandles.begin();
+ it != metahandles.end(); ++it) {
+ AddCommitItem(*it, type);
+ }
+}
+
const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection(
ModelSafeGroup group) const {
Projections::const_iterator i = projections_.find(group);
@@ -41,14 +48,14 @@ const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection(
void OrderedCommitSet::Append(const OrderedCommitSet& other) {
for (size_t i = 0; i < other.Size(); ++i) {
CommitItem item = other.GetCommitItemAt(i);
- AddCommitItem(item.meta, item.id, item.group);
+ AddCommitItem(item.meta, item.group);
}
}
void OrderedCommitSet::AppendReverse(const OrderedCommitSet& other) {
for (int i = other.Size() - 1; i >= 0; i--) {
CommitItem item = other.GetCommitItemAt(i);
- AddCommitItem(item.meta, item.id, item.group);
+ AddCommitItem(item.meta, item.group);
}
}
@@ -72,7 +79,6 @@ void OrderedCommitSet::Truncate(size_t max_size) {
if (element != p.end())
p.erase(element, p.end());
}
- commit_ids_.resize(max_size);
metahandle_order_.resize(max_size);
types_.resize(max_size);
}
@@ -80,7 +86,6 @@ void OrderedCommitSet::Truncate(size_t max_size) {
void OrderedCommitSet::Clear() {
inserted_metahandles_.clear();
- commit_ids_.clear();
metahandle_order_.clear();
for (Projections::iterator it = projections_.begin();
it != projections_.end(); ++it) {
@@ -94,7 +99,6 @@ OrderedCommitSet::CommitItem OrderedCommitSet::GetCommitItemAt(
const size_t position) const {
DCHECK(position < Size());
CommitItem return_item = {metahandle_order_[position],
- commit_ids_[position],
types_[position]};
return return_item;
}
@@ -116,7 +120,6 @@ bool OrderedCommitSet::HasBookmarkCommitId() const {
void OrderedCommitSet::operator=(const OrderedCommitSet& other) {
inserted_metahandles_ = other.inserted_metahandles_;
- commit_ids_ = other.commit_ids_;
metahandle_order_ = other.metahandle_order_;
projections_ = other.projections_;
types_ = other.types_;