| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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 void OrderedCommitSet::Append(const OrderedCommitSet& other) { | 34 void OrderedCommitSet::Append(const OrderedCommitSet& other) { |
| 35 for (int i = 0; i < other.Size(); ++i) { | 35 for (size_t i = 0; i < other.Size(); ++i) { |
| 36 CommitItem item = other.GetCommitItemAt(i); | 36 CommitItem item = other.GetCommitItemAt(i); |
| 37 AddCommitItem(item.meta, item.id, item.group); | 37 AddCommitItem(item.meta, item.id, item.group); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 void OrderedCommitSet::AppendReverse(const OrderedCommitSet& other) { | 41 void OrderedCommitSet::AppendReverse(const OrderedCommitSet& other) { |
| 42 for (int i = other.Size() - 1; i >= 0; i--) { | 42 for (int i = other.Size() - 1; i >= 0; 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 19 matching lines...) Expand all Loading... |
| 65 if (element != p.end()) | 65 if (element != p.end()) |
| 66 p.erase(element, p.end()); | 66 p.erase(element, p.end()); |
| 67 } | 67 } |
| 68 commit_ids_.resize(max_size); | 68 commit_ids_.resize(max_size); |
| 69 metahandle_order_.resize(max_size); | 69 metahandle_order_.resize(max_size); |
| 70 types_.resize(max_size); | 70 types_.resize(max_size); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 OrderedCommitSet::CommitItem OrderedCommitSet::GetCommitItemAt( | 74 OrderedCommitSet::CommitItem OrderedCommitSet::GetCommitItemAt( |
| 75 const int position) const { | 75 const size_t position) const { |
| 76 DCHECK(position < Size()); | 76 DCHECK(position < Size()); |
| 77 CommitItem return_item = {metahandle_order_[position], | 77 CommitItem return_item = {metahandle_order_[position], |
| 78 commit_ids_[position], | 78 commit_ids_[position], |
| 79 types_[position]}; | 79 types_[position]}; |
| 80 return return_item; | 80 return return_item; |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool OrderedCommitSet::HasBookmarkCommitId() const { | 83 bool OrderedCommitSet::HasBookmarkCommitId() const { |
| 84 ModelSafeRoutingInfo::const_iterator group | 84 ModelSafeRoutingInfo::const_iterator group |
| 85 = routes_.find(syncable::BOOKMARKS); | 85 = routes_.find(syncable::BOOKMARKS); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 101 commit_ids_ = other.commit_ids_; | 101 commit_ids_ = other.commit_ids_; |
| 102 metahandle_order_ = other.metahandle_order_; | 102 metahandle_order_ = other.metahandle_order_; |
| 103 projections_ = other.projections_; | 103 projections_ = other.projections_; |
| 104 types_ = other.types_; | 104 types_ = other.types_; |
| 105 routes_ = other.routes_; | 105 routes_ = other.routes_; |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace sessions | 108 } // namespace sessions |
| 109 } // namespace browser_sync | 109 } // namespace browser_sync |
| 110 | 110 |
| OLD | NEW |