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

Side by Side Diff: sync/engine/commit_processor.cc

Issue 1096983002: Update usages of std::map to use ScopedPtrMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passwordmanager-scopedmemory
Patch Set: Rebase. Created 5 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
« no previous file with comments | « sync/engine/commit_processor.h ('k') | sync/engine/directory_update_handler_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/engine/commit_processor.h" 5 #include "sync/engine/commit_processor.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "sync/engine/commit_contribution.h" 9 #include "sync/engine/commit_contribution.h"
10 #include "sync/engine/commit_contributor.h" 10 #include "sync/engine/commit_contributor.h"
11 #include "sync/protocol/sync.pb.h" 11 #include "sync/protocol/sync.pb.h"
12 12
13 namespace syncer { 13 namespace syncer {
14 14
15 typedef std::map<ModelType, size_t> TypeToIndexMap; 15 typedef std::map<ModelType, size_t> TypeToIndexMap;
16 16
17 CommitProcessor::CommitProcessor(CommitContributorMap* commit_contributor_map) 17 CommitProcessor::CommitProcessor(CommitContributorMap* commit_contributor_map)
18 : commit_contributor_map_(commit_contributor_map) {} 18 : commit_contributor_map_(commit_contributor_map) {}
19 19
20 CommitProcessor::~CommitProcessor() {} 20 CommitProcessor::~CommitProcessor() {}
21 21
22 void CommitProcessor::GatherCommitContributions( 22 void CommitProcessor::GatherCommitContributions(
23 ModelTypeSet commit_types, 23 ModelTypeSet commit_types,
24 size_t max_entries, 24 size_t max_entries,
25 ContributionMap* contributions) { 25 Commit::ContributionMap* contributions) {
26 size_t num_entries = 0; 26 size_t num_entries = 0;
27 for (ModelTypeSet::Iterator it = commit_types.First(); 27 for (ModelTypeSet::Iterator it = commit_types.First();
28 it.Good(); it.Inc()) { 28 it.Good(); it.Inc()) {
29 CommitContributorMap::iterator cm_it = 29 CommitContributorMap::iterator cm_it =
30 commit_contributor_map_->find(it.Get()); 30 commit_contributor_map_->find(it.Get());
31 if (cm_it == commit_contributor_map_->end()) { 31 if (cm_it == commit_contributor_map_->end()) {
32 NOTREACHED() 32 NOTREACHED()
33 << "Could not find requested type " << ModelTypeToString(it.Get()) 33 << "Could not find requested type " << ModelTypeToString(it.Get())
34 << " in contributor map."; 34 << " in contributor map.";
35 continue; 35 continue;
36 } 36 }
37 size_t spaces_remaining = max_entries - num_entries; 37 size_t spaces_remaining = max_entries - num_entries;
38 scoped_ptr<CommitContribution> contribution = 38 scoped_ptr<CommitContribution> contribution =
39 cm_it->second->GetContribution(spaces_remaining); 39 cm_it->second->GetContribution(spaces_remaining);
40 if (contribution) { 40 if (contribution) {
41 num_entries += contribution->GetNumEntries(); 41 num_entries += contribution->GetNumEntries();
42 contributions->insert(std::make_pair(it.Get(), contribution.release())); 42 contributions->insert(it.Get(), contribution.Pass());
43 } 43 }
44 if (num_entries >= max_entries) { 44 if (num_entries >= max_entries) {
45 DCHECK_EQ(num_entries, max_entries) 45 DCHECK_EQ(num_entries, max_entries)
46 << "Number of commit entries exceeeds maximum"; 46 << "Number of commit entries exceeeds maximum";
47 break; 47 break;
48 } 48 }
49 } 49 }
50 } 50 }
51 51
52 } // namespace syncer 52 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/commit_processor.h ('k') | sync/engine/directory_update_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698