smart_lock_metrics_recorder.cc 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright 2018 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. #include "ash/components/proximity_auth/smart_lock_metrics_recorder.h"
  5. #include "base/metrics/histogram_macros.h"
  6. SmartLockMetricsRecorder::UsageRecorder::UsageRecorder() = default;
  7. SmartLockMetricsRecorder::UsageRecorder::~UsageRecorder() = default;
  8. SmartLockMetricsRecorder::SmartLockMetricsRecorder() = default;
  9. SmartLockMetricsRecorder::~SmartLockMetricsRecorder() {}
  10. // static
  11. void SmartLockMetricsRecorder::RecordSmartLockUnlockAuthMethodChoice(
  12. SmartLockAuthMethodChoice auth_method_choice) {
  13. UMA_HISTOGRAM_ENUMERATION("SmartLock.AuthMethodChoice.Unlock",
  14. auth_method_choice);
  15. }
  16. // static
  17. void SmartLockMetricsRecorder::RecordSmartLockSignInAuthMethodChoice(
  18. SmartLockAuthMethodChoice auth_method_choice) {
  19. UMA_HISTOGRAM_ENUMERATION("SmartLock.AuthMethodChoice.SignIn",
  20. auth_method_choice);
  21. }
  22. // static
  23. void SmartLockMetricsRecorder::RecordAuthResultUnlockSuccess(bool success) {
  24. RecordAuthResultSuccess(success);
  25. UMA_HISTOGRAM_BOOLEAN("SmartLock.AuthResult.Unlock", success);
  26. }
  27. // static
  28. void SmartLockMetricsRecorder::RecordAuthResultUnlockFailure(
  29. SmartLockAuthResultFailureReason failure_reason) {
  30. RecordAuthResultUnlockSuccess(false);
  31. UMA_HISTOGRAM_ENUMERATION("SmartLock.AuthResult.Unlock.Failure",
  32. failure_reason);
  33. }
  34. // static
  35. void SmartLockMetricsRecorder::RecordAuthResultSignInSuccess(bool success) {
  36. RecordAuthResultSuccess(success);
  37. UMA_HISTOGRAM_BOOLEAN("SmartLock.AuthResult.SignIn", success);
  38. }
  39. // static
  40. void SmartLockMetricsRecorder::RecordAuthResultSignInFailure(
  41. SmartLockAuthResultFailureReason failure_reason) {
  42. RecordAuthResultSignInSuccess(false);
  43. UMA_HISTOGRAM_ENUMERATION("SmartLock.AuthResult.SignIn.Failure",
  44. failure_reason);
  45. }
  46. // static
  47. void SmartLockMetricsRecorder::RecordAuthMethodChoiceUnlockPasswordState(
  48. SmartLockAuthEventPasswordState password_state) {
  49. UMA_HISTOGRAM_ENUMERATION("SmartLock.AuthMethodChoice.Unlock.PasswordState",
  50. password_state);
  51. }
  52. // static
  53. void SmartLockMetricsRecorder::RecordAuthMethodChoiceSignInPasswordState(
  54. SmartLockAuthEventPasswordState password_state) {
  55. UMA_HISTOGRAM_ENUMERATION("SmartLock.AuthMethodChoice.SignIn.PasswordState",
  56. password_state);
  57. }
  58. // static
  59. void SmartLockMetricsRecorder::SetUsageRecorderInstance(
  60. SmartLockMetricsRecorder::UsageRecorder* usage_recorder) {
  61. SmartLockMetricsRecorder::g_usage_recorder = usage_recorder;
  62. }
  63. // static
  64. void SmartLockMetricsRecorder::RecordAuthResultSuccess(bool success) {
  65. UMA_HISTOGRAM_BOOLEAN("SmartLock.AuthResult", success);
  66. if (SmartLockMetricsRecorder::g_usage_recorder) {
  67. SmartLockMetricsRecorder::g_usage_recorder->RecordUsage(success);
  68. }
  69. }
  70. SmartLockMetricsRecorder::UsageRecorder*
  71. SmartLockMetricsRecorder::g_usage_recorder = nullptr;