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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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/commit_queue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sync/engine/commit_processor.h"
6
7 #include <stddef.h>
8
9 #include <utility>
10
11 #include "base/metrics/histogram_macros.h"
12 #include "sync/engine/commit_contribution.h"
13 #include "sync/engine/commit_contributor.h"
14 #include "sync/protocol/sync.pb.h"
15
16 namespace syncer {
17
18 typedef std::map<ModelType, size_t> TypeToIndexMap;
19
20 CommitProcessor::CommitProcessor(CommitContributorMap* commit_contributor_map)
21 : commit_contributor_map_(commit_contributor_map) {}
22
23 CommitProcessor::~CommitProcessor() {}
24
25 void CommitProcessor::GatherCommitContributions(
26 ModelTypeSet commit_types,
27 size_t max_entries,
28 bool cookie_jar_mismatch,
29 bool cookie_jar_empty,
30 Commit::ContributionMap* contributions) {
31 size_t num_entries = 0;
32 for (ModelTypeSet::Iterator it = commit_types.First();
33 it.Good(); it.Inc()) {
34 CommitContributorMap::iterator cm_it =
35 commit_contributor_map_->find(it.Get());
36 if (cm_it == commit_contributor_map_->end()) {
37 NOTREACHED()
38 << "Could not find requested type " << ModelTypeToString(it.Get())
39 << " in contributor map.";
40 continue;
41 }
42 size_t spaces_remaining = max_entries - num_entries;
43 std::unique_ptr<CommitContribution> contribution =
44 cm_it->second->GetContribution(spaces_remaining);
45 if (contribution) {
46 num_entries += contribution->GetNumEntries();
47 contributions->insert(std::make_pair(it.Get(), std::move(contribution)));
48
49 if (it.Get() == SESSIONS) {
50 UMA_HISTOGRAM_BOOLEAN("Sync.CookieJarMatchOnNavigation",
51 !cookie_jar_mismatch);
52 if (cookie_jar_mismatch) {
53 UMA_HISTOGRAM_BOOLEAN("Sync.CookieJarEmptyOnMismatch",
54 cookie_jar_empty);
55 }
56 }
57 }
58 if (num_entries >= max_entries) {
59 DCHECK_EQ(num_entries, max_entries)
60 << "Number of commit entries exceeeds maximum";
61 break;
62 }
63 }
64 }
65
66 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/commit_processor.h ('k') | sync/engine/commit_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698