Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: sync/sessions/ordered_commit_set.cc

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/sessions/ordered_commit_set.h ('k') | sync/sessions/ordered_commit_set_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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( 14 OrderedCommitSet::OrderedCommitSet(
15 const syncer::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 syncer::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
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const size_t position) const { 93 const size_t position) const {
94 DCHECK(position < Size()); 94 DCHECK(position < Size());
95 CommitItem return_item = {metahandle_order_[position], 95 CommitItem return_item = {metahandle_order_[position],
96 commit_ids_[position], 96 commit_ids_[position],
97 types_[position]}; 97 types_[position]};
98 return return_item; 98 return return_item;
99 } 99 }
100 100
101 bool OrderedCommitSet::HasBookmarkCommitId() const { 101 bool OrderedCommitSet::HasBookmarkCommitId() const {
102 ModelSafeRoutingInfo::const_iterator group 102 ModelSafeRoutingInfo::const_iterator group
103 = routes_.find(syncable::BOOKMARKS); 103 = routes_.find(syncer::BOOKMARKS);
104 if (group == routes_.end()) 104 if (group == routes_.end())
105 return false; 105 return false;
106 Projections::const_iterator proj = projections_.find(group->second); 106 Projections::const_iterator proj = projections_.find(group->second);
107 if (proj == projections_.end()) 107 if (proj == projections_.end())
108 return false; 108 return false;
109 DCHECK_LE(proj->second.size(), types_.size()); 109 DCHECK_LE(proj->second.size(), types_.size());
110 for (size_t i = 0; i < proj->second.size(); i++) { 110 for (size_t i = 0; i < proj->second.size(); i++) {
111 if (types_[proj->second[i]] == syncable::BOOKMARKS) 111 if (types_[proj->second[i]] == syncer::BOOKMARKS)
112 return true; 112 return true;
113 } 113 }
114 return false; 114 return false;
115 } 115 }
116 116
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 syncer 127 } // namespace syncer
128 128
OLDNEW
« no previous file with comments | « sync/sessions/ordered_commit_set.h ('k') | sync/sessions/ordered_commit_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698