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

Side by Side Diff: chrome/browser/password_manager/password_manager_metrics_util.cc

Issue 23140005: Added of new UMA signals in order to be able to discover early if the "save password" feature gets … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor changes Created 7 years, 3 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
(Empty)
1 // Copyright 2013 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 "chrome/browser/password_manager/password_manager_metrics_util.h"
6
7 #include "base/basictypes.h"
8 #include "base/metrics/histogram.h"
9 #include "base/process/process_handle.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h"
12 #include "base/time/time.h"
13 #include "url/gurl.h"
14
15 namespace password_manager_metrics_util {
16
17 std::string IsDomainNameMonitored(const std::string& url_host) {
18 // This array contains each monitored websites together with all id of
19 // buckets which contain the website.
20 const struct MonitoredWebsiteInfos kInfos[] = {
vabr (Chromium) 2013/09/10 08:46:53 This should be also "static", otherwise I believe
jdomingos 2013/09/10 16:49:13 Done.
21 {"google.com", {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}},
22 {"yahoo.com", {1, 2, 3, 4, 5, 11, 12, 13, 14, 15}},
23 {"baidu.com", {1, 2, 3, 4, 6, 7, 11, 12, 16, 17}},
24 {"wikipedia.org", {1, 2, 3, 4, 5, 6, 11, 12, 16, 18}},
25 {"linkedin.com", {1, 6, 8, 11, 13, 14, 15, 16, 17, 19}},
26 {"twitter.com", {5, 6, 7, 8, 9, 11, 13, 17, 19, 20}},
27 {"live.com", {7, 8, 9, 10, 13, 14, 16, 17, 18, 20}},
28 {"amazon.com", {2, 5, 9, 10, 12, 14, 15, 18, 19, 20}},
29 {"ebay.com", {13, 7, 9, 10, 14, 15, 17, 18, 19, 20}},
30 {"tumblr.com", {4, 8, 10, 12, 13, 15, 16, 18, 19, 20}},
31 };
32 const size_t kInfosLength = arraysize(kInfos);
33
34 GURL url(url_host);
35 for (size_t i = 0; i < kInfosLength; ++i) {
36 std::string domain = kInfos[i].domain_name;
37 // For each session, the user uses only one bucket for each website.
38 if (url.DomainIs(domain.c_str())) {
39 return "_bucket" +
40 base::IntToString(
41 kInfos[i].bucketsID[base::GetCurrentProcId() % kInfosLength]);
vabr (Chromium) 2013/09/10 08:46:53 Please do not use |kInfosLength| here! The fact th
vabr (Chromium) 2013/09/10 08:46:53 Using GetCurrentProcId() should also have a commen
jdomingos 2013/09/10 16:49:13 Done.
jdomingos 2013/09/10 16:49:13 Done.
42 }
43 }
44 return std::string();
45 }
46
47 void LogUMAHistogramEnumeration(const std::string& name,
vabr (Chromium) 2013/09/10 08:46:53 (Dear OWNERS, any guidance on the following?) Loo
Ilya Sherman 2013/09/10 22:33:47 The most appropriate place for these would be in b
48 int sample,
49 int boundary_value) {
50 DCHECK_LT(sample, boundary_value);
51
52 // Note: This leaks memory, which is expected behavior.
53 base::HistogramBase* histogram =
54 base::LinearHistogram::FactoryGet(
55 name,
56 1,
57 boundary_value,
58 boundary_value + 1,
59 base::HistogramBase::kUmaTargetedHistogramFlag);
60 histogram->Add(sample);
61 }
62
63 void LogUMAHistogramTimes(const std::string& name,
64 const base::TimeDelta& duration) {
65 // Note: This leaks memory, which is expected behavior.
66 base::HistogramBase* histogram =
67 base::Histogram::FactoryTimeGet(
68 name,
69 base::TimeDelta::FromMilliseconds(1),
70 base::TimeDelta::FromSeconds(10),
71 50,
72 base::HistogramBase::kUmaTargetedHistogramFlag);
73 histogram->AddTime(duration);
74 }
75
76 void LogUMAHistogramCount(const std::string& name, int sample) {
77 // Note: This leaks memory, which is expected behavior.
78 base::HistogramBase* histogram =
79 base::Histogram::FactoryGet(
80 name,
81 1,
82 1000000,
83 50,
84 base::HistogramBase::kUmaTargetedHistogramFlag);
85 histogram->Add(sample);
86 }
87
88 void LogUMAHistogramBoolean(const std::string& name, bool sample) {
89 // Note: This leaks memory, which is expected behavior.
90 base::HistogramBase* histogram =
91 base::BooleanHistogram::FactoryGet(
92 name,
93 base::Histogram::kNoFlags);
94 histogram->AddBoolean(sample);
95 }
96
97 } // namespace password_manager_metrics_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698