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

Side by Side Diff: chrome/browser/chromeos/login/reauth_stats.cc

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "chrome/browser/chromeos/login/reauth_stats.h" 5 #include "chrome/browser/chromeos/login/reauth_stats.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "components/user_manager/known_user.h" 8 #include "components/user_manager/known_user.h"
9 9
10 namespace chromeos { 10 namespace chromeos {
11 11
12 void RecordReauthReason(const AccountId& account_id, ReauthReason reason) { 12 void RecordReauthReason(const AccountId& account_id, ReauthReason reason) {
13 int old_reason; 13 int old_reason;
14 // We record only the first value, skipping everything else, except "none" 14 // We record only the first value, skipping everything else, except "none"
15 // value, which is used to reset the current state. 15 // value, which is used to reset the current state.
16 if (!user_manager::known_user::FindReauthReason(account_id, &old_reason) || 16 if (!user_manager::known_user::FindReauthReason(account_id, &old_reason) ||
17 (static_cast<ReauthReason>(old_reason) == ReauthReason::NONE && 17 (static_cast<ReauthReason>(old_reason) == ReauthReason::NONE &&
18 reason != ReauthReason::NONE)) { 18 reason != ReauthReason::NONE)) {
19 user_manager::known_user::UpdateReauthReason(account_id, 19 user_manager::known_user::UpdateReauthReason(account_id,
20 static_cast<int>(reason)); 20 static_cast<int>(reason));
21 } 21 }
22 } 22 }
23 23
24 void SendReauthReason(const AccountId& account_id) { 24 void SendReauthReason(const AccountId& account_id) {
25 int reauth_reason; 25 int reauth_reason_int;
26 if (user_manager::known_user::FindReauthReason(account_id, &reauth_reason) && 26 if (!user_manager::known_user::FindReauthReason(account_id,
27 static_cast<ReauthReason>(reauth_reason) != ReauthReason::NONE) { 27 &reauth_reason_int))
28 return;
29 ReauthReason reauth_reason = static_cast<ReauthReason>(reauth_reason_int);
30 if (reauth_reason != ReauthReason::NONE) {
28 UMA_HISTOGRAM_ENUMERATION("Login.ReauthReason", reauth_reason, 31 UMA_HISTOGRAM_ENUMERATION("Login.ReauthReason", reauth_reason,
29 NUM_REAUTH_FLOW_REASONS); 32 NUM_REAUTH_FLOW_REASONS);
30 user_manager::known_user::UpdateReauthReason( 33 user_manager::known_user::UpdateReauthReason(
31 account_id, static_cast<int>(ReauthReason::NONE)); 34 account_id, static_cast<int>(ReauthReason::NONE));
32 } 35 }
33 } 36 }
34 37
35 } // namespace chromeos 38 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/app_mode/kiosk_app_launch_error.cc ('k') | chrome/browser/chromeos/login/screens/reset_screen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698