OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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/kiosk_mode/kiosk_mode_metrics.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 | |
9 namespace { | |
10 | |
11 const char kDemoUserSessionTimeMetric[] = "KioskMode.DemoUserSessionTime"; | |
12 const char kDemoUserAppsLaunchedMetric[] = "KioskMode.DemoUserAppsLaunched"; | |
13 | |
14 } | |
15 | |
16 namespace chromeos { | |
17 | |
18 static KioskModeMetrics* kiosk_mode_settings = NULL; | |
19 | |
20 // static | |
21 KioskModeMetrics* KioskModeMetrics::Get() { | |
22 if (!kiosk_mode_settings) | |
23 kiosk_mode_settings = new KioskModeMetrics(); | |
24 | |
25 return kiosk_mode_settings; | |
26 } | |
27 | |
28 void KioskModeMetrics::SessionStarted() { | |
29 session_started_ = base::Time::Now(); | |
30 } | |
31 | |
32 void KioskModeMetrics::SessionEnded() { | |
33 if (session_started_ == base::Time()) | |
34 return; | |
35 | |
36 // Session ended, time to report our collected metrics. | |
37 UMA_HISTOGRAM_LONG_TIMES(kDemoUserSessionTimeMetric, | |
38 base::Time::Now() - session_started_); | |
39 | |
40 UMA_HISTOGRAM_COUNTS(kDemoUserAppsLaunchedMetric, apps_opened_); | |
41 | |
42 // We've consumed the session times, reset. | |
43 session_started_ = base::Time(); | |
44 } | |
45 | |
46 void KioskModeMetrics::UserOpenedApp() { | |
47 if (session_started_ == base::Time()) | |
48 return; | |
49 ++apps_opened_; | |
50 } | |
51 | |
52 KioskModeMetrics::KioskModeMetrics() | |
53 : session_started_(base::Time()), | |
54 apps_opened_(0) { | |
55 } | |
56 | |
57 KioskModeMetrics::~KioskModeMetrics() { | |
58 } | |
59 | |
60 } // namespace chromeos | |
OLD | NEW |