OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/sessions/ordered_commit_set.h" | 5 #include "chrome/browser/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 13 matching lines...) Expand all Loading... |
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 void OrderedCommitSet::Append(const OrderedCommitSet& other) { |
| 35 for (int i = 0; i < other.Size(); ++i) { |
| 36 CommitItem item = other.GetCommitItemAt(i); |
| 37 AddCommitItem(item.meta, item.id, item.group); |
| 38 } |
| 39 } |
| 40 |
34 void OrderedCommitSet::AppendReverse(const OrderedCommitSet& other) { | 41 void OrderedCommitSet::AppendReverse(const OrderedCommitSet& other) { |
35 for (int i = other.Size() - 1; i >= 0; i--) { | 42 for (int i = other.Size() - 1; i >= 0; i--) { |
36 CommitItem item = other.GetCommitItemAt(i); | 43 CommitItem item = other.GetCommitItemAt(i); |
37 AddCommitItem(item.meta, item.id, item.group); | 44 AddCommitItem(item.meta, item.id, item.group); |
38 } | 45 } |
39 } | 46 } |
40 | 47 |
41 void OrderedCommitSet::Truncate(size_t max_size) { | 48 void OrderedCommitSet::Truncate(size_t max_size) { |
42 if (max_size < metahandle_order_.size()) { | 49 if (max_size < metahandle_order_.size()) { |
43 for (size_t i = max_size; i < metahandle_order_.size(); ++i) { | 50 for (size_t i = max_size; i < metahandle_order_.size(); ++i) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 commit_ids_ = other.commit_ids_; | 101 commit_ids_ = other.commit_ids_; |
95 metahandle_order_ = other.metahandle_order_; | 102 metahandle_order_ = other.metahandle_order_; |
96 projections_ = other.projections_; | 103 projections_ = other.projections_; |
97 types_ = other.types_; | 104 types_ = other.types_; |
98 routes_ = other.routes_; | 105 routes_ = other.routes_; |
99 } | 106 } |
100 | 107 |
101 } // namespace sessions | 108 } // namespace sessions |
102 } // namespace browser_sync | 109 } // namespace browser_sync |
103 | 110 |
OLD | NEW |