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

Unified 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: Review 5 Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_manager_metrics_util.cc
diff --git a/chrome/browser/password_manager/password_manager_metrics_util.cc b/chrome/browser/password_manager/password_manager_metrics_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..70b3bcd59f38736140df930fe3aee03083794925
--- /dev/null
+++ b/chrome/browser/password_manager/password_manager_metrics_util.cc
@@ -0,0 +1,88 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/password_manager/password_manager_metrics_util.h"
+
+#include "base/strings/string_util.h"
+
+namespace password_manager_metrics_util {
+
+std::string IsDomainNameMonitored(const std::string& url_host) {
+ const char* kMonitoredDomainName[] = {
Ilya Sherman 2013/08/30 22:34:42 nit: "const char* const"
jdomingos 2013/09/02 09:58:45 Hi Ilya, I am wondering if the const you want me
Ilya Sherman 2013/09/03 22:25:21 The second const prevents you from writing code li
+ "google.com",
+ "yahoo.com",
+ "baidu.com",
+ "wikipedia.org",
+ "linkedin.com",
+ "twitter.com",
+ "live.com",
+ "amazon.com",
+ };
+ const size_t kMonitoredDomainNameLength = arraysize(kMonitoredDomainName);
+
+ std::string domain_name;
+ for (std::string::size_type i = 0; i < kMonitoredDomainNameLength; ++i) {
+ size_t point_position =
+ url_host.size() - strlen(kMonitoredDomainName[i]) - 1;
+ if (url_host == kMonitoredDomainName[i] ||
+ (EndsWith(url_host, kMonitoredDomainName[i], true) &&
+ url_host[point_position] == '.')) {
+ domain_name = kMonitoredDomainName[i];
+ return domain_name;
+ }
+ }
+ return domain_name;
Ilya Sherman 2013/08/30 22:34:42 Please write this as: GURL url(url_host); for (si
jdomingos 2013/09/02 09:58:45 Done.
+}
+
+void LogUMAHistogramEnumeration(const std::string& name,
+ int sample,
+ int boundary_value) {
+ DCHECK_LT(sample, boundary_value);
+
+ // Note: This leaks memory, which is expected behavior.
+ base::HistogramBase* histogram =
+ base::LinearHistogram::FactoryGet(
+ name,
+ 1,
+ boundary_value,
+ boundary_value + 1,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ histogram->Add(sample);
+}
+
+void LogUMAHistogramTimes(const std::string& name,
+ const base::TimeDelta& duration) {
+ // Note: This leaks memory, which is expected behavior.
+ base::HistogramBase* histogram =
+ base::Histogram::FactoryTimeGet(
+ name,
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromSeconds(10),
+ 50,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ histogram->AddTime(duration);
+}
+
+void LogUMAHistogramCount(const std::string& name, int sample) {
+ // Note: This leaks memory, which is expected behavior.
+ base::HistogramBase* histogram =
+ base::Histogram::FactoryGet(
+ name,
+ 1,
+ 1000000,
+ 50,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ histogram->Add(sample);
+}
+
+void LogUMAHistogramBoolean(const std::string& name, bool sample) {
+ // Note: This leaks memory, which is expected behavior.
+ base::HistogramBase* histogram =
+ base::BooleanHistogram::FactoryGet(
+ name,
+ base::Histogram::kNoFlags);
+ histogram->AddBoolean(sample);
+}
+
+} // namespace password_manager_metrics_util

Powered by Google App Engine
This is Rietveld 408576698