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

Unified Diff: components/policy/core/browser/browser_policy_connector.cc

Issue 382813002: Added more policy UMA metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed code format issue. Created 6 years, 5 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: components/policy/core/browser/browser_policy_connector.cc
diff --git a/components/policy/core/browser/browser_policy_connector.cc b/components/policy/core/browser/browser_policy_connector.cc
index ead92324b6ba51131fa46d8aaa7764d45b161251..2317f8b90b6661db3ac705987e745c8ae702aa47 100644
--- a/components/policy/core/browser/browser_policy_connector.cc
+++ b/components/policy/core/browser/browser_policy_connector.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "base/metrics/histogram.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
@@ -40,7 +41,8 @@ bool g_created_policy_service = false;
ConfigurationPolicyProvider* g_testing_provider = NULL;
// Returns true if |domain| matches the regex |pattern|.
-bool MatchDomain(const base::string16& domain, const base::string16& pattern) {
+bool MatchDomain(const base::string16& domain, const base::string16& pattern,
+ size_t index, size_t max) {
UErrorCode status = U_ZERO_ERROR;
const icu::UnicodeString icu_pattern(pattern.data(), pattern.length());
icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status);
@@ -52,8 +54,12 @@ bool MatchDomain(const base::string16& domain, const base::string16& pattern) {
// optimization than crash.
DLOG(ERROR) << "Possible invalid domain pattern: " << pattern
<< " - Error: " << status;
+ UMA_HISTOGRAM_BOOLEAN("Enterprise.DomainWhitelistRegexSuccess", false);
+ UMA_HISTOGRAM_ENUMERATION("Enterprise.DomainWhitelistRegexFailureIndex",
+ index, max);
Joao da Silva 2014/07/11 15:13:47 WDYT of sampling the UErrorCode in "status" with U
Andrew T Wilson (Slow) 2014/07/11 15:46:21 I considered that, but I don't know what UMA_HISTO
Ilya Sherman 2014/07/11 22:54:12 UMA_HISTOGRAM_SPARSE_SLOWLY just uses a map rather
Ilya Sherman 2014/07/11 22:54:12 Hmm, I'm concerned that |max| is being passed in a
Andrew T Wilson (Slow) 2014/07/24 15:25:56 So, what's the right way to use UMA_HISTOGRAM_SPAR
Andrew T Wilson (Slow) 2014/07/24 15:25:56 Done.
Ilya Sherman 2014/07/24 17:29:32 It's up to you what values you list in histograms.
return false;
}
+ UMA_HISTOGRAM_BOOLEAN("Enterprise.DomainWhitelistRegexSuccess", true);
Ilya Sherman 2014/07/11 22:54:12 Please define a wrapper method around emitting to
Andrew T Wilson (Slow) 2014/07/24 15:25:56 Done.
icu::UnicodeString icu_input(domain.data(), domain.length());
matcher.reset(icu_input);
status = U_ZERO_ERROR;
@@ -211,7 +217,7 @@ bool BrowserPolicyConnector::IsNonEnterpriseUser(const std::string& username) {
gaia::ExtractDomainName(gaia::CanonicalizeEmail(username)));
for (size_t i = 0; i < arraysize(kNonManagedDomainPatterns); i++) {
base::string16 pattern = base::WideToUTF16(kNonManagedDomainPatterns[i]);
- if (MatchDomain(domain, pattern))
+ if (MatchDomain(domain, pattern, i, arraysize(kNonManagedDomainPatterns)))
Ilya Sherman 2014/07/11 22:54:12 Hmm, UMA is not intended to be used to track user
Andrew T Wilson (Slow) 2014/07/24 15:25:56 I'm not tracking user navigation. During signin, w
Ilya Sherman 2014/07/24 17:29:32 I'm confused -- the failure is independent of the
return true;
}
return false;

Powered by Google App Engine
This is Rietveld 408576698