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

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

Issue 1991973002: [Sync] Add histograms for cookie jar state on Sessions commit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 4 years, 7 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/metrics/histogram_macros.h"
11 #include "sync/engine/commit_contribution.h" 12 #include "sync/engine/commit_contribution.h"
12 #include "sync/engine/commit_contributor.h" 13 #include "sync/engine/commit_contributor.h"
13 #include "sync/protocol/sync.pb.h" 14 #include "sync/protocol/sync.pb.h"
14 15
15 namespace syncer { 16 namespace syncer {
16 17
17 typedef std::map<ModelType, size_t> TypeToIndexMap; 18 typedef std::map<ModelType, size_t> TypeToIndexMap;
18 19
19 CommitProcessor::CommitProcessor(CommitContributorMap* commit_contributor_map) 20 CommitProcessor::CommitProcessor(CommitContributorMap* commit_contributor_map)
20 : commit_contributor_map_(commit_contributor_map) {} 21 : commit_contributor_map_(commit_contributor_map) {}
21 22
22 CommitProcessor::~CommitProcessor() {} 23 CommitProcessor::~CommitProcessor() {}
23 24
24 void CommitProcessor::GatherCommitContributions( 25 void CommitProcessor::GatherCommitContributions(
25 ModelTypeSet commit_types, 26 ModelTypeSet commit_types,
26 size_t max_entries, 27 size_t max_entries,
28 bool cookie_jar_mismatch,
29 bool cookie_jar_empty,
27 Commit::ContributionMap* contributions) { 30 Commit::ContributionMap* contributions) {
28 size_t num_entries = 0; 31 size_t num_entries = 0;
29 for (ModelTypeSet::Iterator it = commit_types.First(); 32 for (ModelTypeSet::Iterator it = commit_types.First();
30 it.Good(); it.Inc()) { 33 it.Good(); it.Inc()) {
31 CommitContributorMap::iterator cm_it = 34 CommitContributorMap::iterator cm_it =
32 commit_contributor_map_->find(it.Get()); 35 commit_contributor_map_->find(it.Get());
33 if (cm_it == commit_contributor_map_->end()) { 36 if (cm_it == commit_contributor_map_->end()) {
34 NOTREACHED() 37 NOTREACHED()
35 << "Could not find requested type " << ModelTypeToString(it.Get()) 38 << "Could not find requested type " << ModelTypeToString(it.Get())
36 << " in contributor map."; 39 << " in contributor map.";
37 continue; 40 continue;
38 } 41 }
39 size_t spaces_remaining = max_entries - num_entries; 42 size_t spaces_remaining = max_entries - num_entries;
40 std::unique_ptr<CommitContribution> contribution = 43 std::unique_ptr<CommitContribution> contribution =
41 cm_it->second->GetContribution(spaces_remaining); 44 cm_it->second->GetContribution(spaces_remaining);
42 if (contribution) { 45 if (contribution) {
43 num_entries += contribution->GetNumEntries(); 46 num_entries += contribution->GetNumEntries();
44 contributions->insert(std::make_pair(it.Get(), std::move(contribution))); 47 contributions->insert(std::make_pair(it.Get(), std::move(contribution)));
48
49 if (it.Get() == SESSIONS) {
50 UMA_HISTOGRAM_BOOLEAN("Sync.CookieJarMismatchOnNavigation",
51 cookie_jar_mismatch);
52 if (cookie_jar_mismatch) {
53 UMA_HISTOGRAM_BOOLEAN("Sync.CookieJarEmptyOnMismatch",
54 cookie_jar_empty);
55 }
56 }
45 } 57 }
46 if (num_entries >= max_entries) { 58 if (num_entries >= max_entries) {
47 DCHECK_EQ(num_entries, max_entries) 59 DCHECK_EQ(num_entries, max_entries)
48 << "Number of commit entries exceeeds maximum"; 60 << "Number of commit entries exceeeds maximum";
49 break; 61 break;
50 } 62 }
51 } 63 }
52 } 64 }
53 65
54 } // namespace syncer 66 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698