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

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

Issue 494633003: UMA: How often are different network error screens encountered during OOBE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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
5 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
6
7 #include "base/metrics/histogram.h"
8
9 namespace chromeos {
10
11 namespace {
12
13 static const char kOobeErrorScreensCounterPrefix[] = "OOBE.NetworkErrorShown.";
14 static const char kOobeTimeSpentOnErrorScreensPrefix[] =
15 "OOBE.ErrorScreensTime.";
16
17 std::string ErrorToString(ErrorScreen::ErrorState error) {
18 switch (error) {
19 case ErrorScreen::ERROR_STATE_PORTAL:
20 return ".Portal";
21 case ErrorScreen::ERROR_STATE_OFFLINE:
22 return ".Offline";
23 case ErrorScreen::ERROR_STATE_PROXY:
24 return ".Proxy";
25 case ErrorScreen::ERROR_STATE_AUTH_EXT_TIMEOUT:
26 return ".AuthExtTimeout";
27 default:
28 NOTREACHED() << "Invalid ErrorState " << error;
29 return "";
ygorshenin1 2014/08/26 14:33:13 nit: replace "" by std::string().
Roman Sorokin (ftl) 2014/09/04 13:26:47 Done.
30 }
31 }
32
33 } // namespace
34
35 ErrorScreensHistogramHelper::ErrorScreensHistogramHelper(
36 const char* screen_name)
37 : screen_name_(screen_name),
38 was_shown_(false),
39 last_error_shown_(ErrorScreen::ERROR_STATE_NONE) {
40 }
41
42 void ErrorScreensHistogramHelper::OnScreenShow() {
43 was_shown_ = true;
44 }
45
46 void ErrorScreensHistogramHelper::OnErrorShow(ErrorScreen::ErrorState error) {
47 OnErrorShowTime(error, base::Time::Now());
48 }
49
50 void ErrorScreensHistogramHelper::OnErrorShowTime(ErrorScreen::ErrorState error,
51 base::Time now) {
52 last_error_shown_ = error;
53 if (error_screen_start_time.is_null())
54 error_screen_start_time = now;
55 UMA_HISTOGRAM_ENUMERATION(kOobeErrorScreensCounterPrefix + screen_name_,
56 error,
57 ErrorScreen::kHistogramErrorStateNum);
58 }
59
60 void ErrorScreensHistogramHelper::OnErrorHide() {
61 OnErrorHideTime(base::Time::Now());
62 }
63
64 void ErrorScreensHistogramHelper::OnErrorHideTime(base::Time now) {
65 DCHECK(!error_screen_start_time.is_null());
66 time_on_error_screens += now - error_screen_start_time;
67 error_screen_start_time = base::Time();
68 }
69
70 ErrorScreensHistogramHelper::~ErrorScreensHistogramHelper() {
71 if (was_shown_) {
72 if (last_error_shown_ == ErrorScreen::ERROR_STATE_NONE) {
73 UMA_HISTOGRAM_ENUMERATION(kOobeErrorScreensCounterPrefix + screen_name_,
74 ErrorScreen::ERROR_STATE_NONE,
75 ErrorScreen::kHistogramErrorStateNum);
76 } else {
77 if (!error_screen_start_time.is_null()) {
78 time_on_error_screens += base::Time::Now() - error_screen_start_time;
79 error_screen_start_time = base::Time();
80 }
81 UMA_HISTOGRAM_MEDIUM_TIMES(kOobeTimeSpentOnErrorScreensPrefix +
ygorshenin1 2014/08/26 14:33:14 Am I right that if, for example, 30 seconds were s
Roman Sorokin (ftl) 2014/09/04 13:26:47 Yes, we decided with Nikita to report the last err
ygorshenin1 2014/09/04 15:13:03 OK, could you please add an clarification to the h
82 screen_name_ +
83 ErrorToString(last_error_shown_),
84 time_on_error_screens);
85 }
86 }
87 }
88
89 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698