| 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 csync { | 11 namespace syncer { |
| 12 namespace sessions { | 12 namespace sessions { |
| 13 | 13 |
| 14 OrderedCommitSet::OrderedCommitSet( | 14 OrderedCommitSet::OrderedCommitSet( |
| 15 const csync::ModelSafeRoutingInfo& routes) | 15 const syncer::ModelSafeRoutingInfo& routes) |
| 16 : routes_(routes) { | 16 : routes_(routes) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 OrderedCommitSet::~OrderedCommitSet() {} | 19 OrderedCommitSet::~OrderedCommitSet() {} |
| 20 | 20 |
| 21 void OrderedCommitSet::AddCommitItem(const int64 metahandle, | 21 void OrderedCommitSet::AddCommitItem(const int64 metahandle, |
| 22 const syncable::Id& commit_id, | 22 const syncable::Id& commit_id, |
| 23 syncable::ModelType type) { | 23 syncable::ModelType type) { |
| 24 if (!HaveCommitItem(metahandle)) { | 24 if (!HaveCommitItem(metahandle)) { |
| 25 inserted_metahandles_.insert(metahandle); | 25 inserted_metahandles_.insert(metahandle); |
| 26 metahandle_order_.push_back(metahandle); | 26 metahandle_order_.push_back(metahandle); |
| 27 commit_ids_.push_back(commit_id); | 27 commit_ids_.push_back(commit_id); |
| 28 projections_[GetGroupForModelType(type, routes_)].push_back( | 28 projections_[GetGroupForModelType(type, routes_)].push_back( |
| 29 commit_ids_.size() - 1); | 29 commit_ids_.size() - 1); |
| 30 types_.push_back(type); | 30 types_.push_back(type); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection( | 34 const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection( |
| 35 csync::ModelSafeGroup group) const { | 35 syncer::ModelSafeGroup group) const { |
| 36 Projections::const_iterator i = projections_.find(group); | 36 Projections::const_iterator i = projections_.find(group); |
| 37 DCHECK(i != projections_.end()); | 37 DCHECK(i != projections_.end()); |
| 38 return i->second; | 38 return i->second; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void OrderedCommitSet::Append(const OrderedCommitSet& other) { | 41 void OrderedCommitSet::Append(const OrderedCommitSet& other) { |
| 42 for (size_t i = 0; i < other.Size(); ++i) { | 42 for (size_t i = 0; i < other.Size(); ++i) { |
| 43 CommitItem item = other.GetCommitItemAt(i); | 43 CommitItem item = other.GetCommitItemAt(i); |
| 44 AddCommitItem(item.meta, item.id, item.group); | 44 AddCommitItem(item.meta, item.id, item.group); |
| 45 } | 45 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void OrderedCommitSet::operator=(const OrderedCommitSet& other) { | 117 void OrderedCommitSet::operator=(const OrderedCommitSet& other) { |
| 118 inserted_metahandles_ = other.inserted_metahandles_; | 118 inserted_metahandles_ = other.inserted_metahandles_; |
| 119 commit_ids_ = other.commit_ids_; | 119 commit_ids_ = other.commit_ids_; |
| 120 metahandle_order_ = other.metahandle_order_; | 120 metahandle_order_ = other.metahandle_order_; |
| 121 projections_ = other.projections_; | 121 projections_ = other.projections_; |
| 122 types_ = other.types_; | 122 types_ = other.types_; |
| 123 routes_ = other.routes_; | 123 routes_ = other.routes_; |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace sessions | 126 } // namespace sessions |
| 127 } // namespace csync | 127 } // namespace syncer |
| 128 | 128 |
| OLD | NEW |