Commit 0ed8d24b authored by Toby Huang's avatar Toby Huang Committed by Commit Bot

Add DCHECK for kInitiated enum in Add Supervision dialog

Add DCHECK to ensure that user is not enrolled in supervision at the
start of the Add Supervision process. Avoids future errors where the
Add Supervision dialog is somehow launched despite the user already
being enrolled in supervision.

Bug: 977336
Change-Id: I0469fd4e11441176ecf79282ff12ff9a0dd707a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1789272Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Commit-Queue: Toby Huang <tobyhuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694346}
parent e4e8e70b
......@@ -21,6 +21,9 @@ void AddSupervisionMetricsRecorder::RecordAddSupervisionEnrollment(
base::UmaHistogramEnumeration("AddSupervisionDialog.Enrollment", action);
switch (action) {
case EnrollmentState::kInitiated:
DCHECK(!EnrollmentCompleted())
<< "The user should not be enrolled in supervision at the start of "
"the Add Supervision process.";
base::RecordAction(
base::UserMetricsAction("AddSupervisionDialog_Launched"));
start_time_ = clock_->NowTicks();
......
......@@ -20,13 +20,14 @@ class AddSupervisionMetricsRecorder {
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class EnrollmentState {
// Recorded when user initiates Add Supervision dialog.
// Recorded when user opens Add Supervision dialog.
kInitiated = 0,
// Recorded when user successfully enrolls in supervision.
kCompleted = 1,
// Recorded when user clicks "Sign out".
// Recorded when user clicks "Sign out" after enrollment in the dialog.
kSignedOut = 2,
// Recorded when user closes the Add Supervison dialog except sign out.
// Recorded when user closes the dialog without enrollment, excluding sign
// out.
kClosed = 3,
// Add future entries above this comment, in sync with enums.xml.
// Update kMaxValue to the last value.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment