OLD | NEW |
---|---|
(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/strings/string_util.h" | |
10 #include "base/time/time.h" | |
11 #include "url/gurl.h" | |
12 | |
13 namespace password_manager_metrics_util { | |
14 | |
15 std::string IsDomainNameMonitored(const std::string& url_host) { | |
16 const char* const kMonitoredDomainName[] = { | |
17 "google.com", | |
18 "yahoo.com", | |
19 "baidu.com", | |
20 "wikipedia.org", | |
21 "linkedin.com", | |
22 "twitter.com", | |
23 "live.com", | |
24 "amazon.com", | |
25 }; | |
26 const size_t kMonitoredDomainNameLength = arraysize(kMonitoredDomainName); | |
27 | |
28 DLOG(INFO) << url_host; | |
Ilya Sherman
2013/09/03 22:25:21
Please remove this logging code prior to committin
| |
29 GURL url(url_host); | |
30 for (size_t i = 0; i < kMonitoredDomainNameLength; ++i) { | |
31 std::string domain = kMonitoredDomainName[i]; | |
32 if (url.DomainIs(domain.c_str())) | |
33 return domain; | |
34 } | |
35 return std::string(); | |
36 } | |
37 | |
38 void LogUMAHistogramEnumeration(const std::string& name, | |
39 int sample, | |
40 int boundary_value) { | |
41 DCHECK_LT(sample, boundary_value); | |
42 | |
43 // Note: This leaks memory, which is expected behavior. | |
44 base::HistogramBase* histogram = | |
45 base::LinearHistogram::FactoryGet( | |
46 name, | |
47 1, | |
48 boundary_value, | |
49 boundary_value + 1, | |
50 base::HistogramBase::kUmaTargetedHistogramFlag); | |
51 histogram->Add(sample); | |
52 } | |
53 | |
54 void LogUMAHistogramTimes(const std::string& name, | |
55 const base::TimeDelta& duration) { | |
56 // Note: This leaks memory, which is expected behavior. | |
57 base::HistogramBase* histogram = | |
58 base::Histogram::FactoryTimeGet( | |
59 name, | |
60 base::TimeDelta::FromMilliseconds(1), | |
61 base::TimeDelta::FromSeconds(10), | |
62 50, | |
63 base::HistogramBase::kUmaTargetedHistogramFlag); | |
64 histogram->AddTime(duration); | |
65 } | |
66 | |
67 void LogUMAHistogramCount(const std::string& name, int sample) { | |
68 // Note: This leaks memory, which is expected behavior. | |
69 base::HistogramBase* histogram = | |
70 base::Histogram::FactoryGet( | |
71 name, | |
72 1, | |
73 1000000, | |
74 50, | |
75 base::HistogramBase::kUmaTargetedHistogramFlag); | |
76 histogram->Add(sample); | |
77 } | |
78 | |
79 void LogUMAHistogramBoolean(const std::string& name, bool sample) { | |
80 // Note: This leaks memory, which is expected behavior. | |
81 base::HistogramBase* histogram = | |
82 base::BooleanHistogram::FactoryGet( | |
83 name, | |
84 base::Histogram::kNoFlags); | |
85 histogram->AddBoolean(sample); | |
86 } | |
87 | |
88 } // namespace password_manager_metrics_util | |
OLD | NEW |