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

Side by Side Diff: ash/metrics/user_metrics_recorder.cc

Issue 2331093002: UMA stats for stylus usage (Closed)
Patch Set: rebase Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/metrics/user_metrics_recorder.h" 5 #include "ash/metrics/user_metrics_recorder.h"
6 6
7 #include "ash/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/shelf_delegate.h" 8 #include "ash/common/shelf/shelf_delegate.h"
9 #include "ash/common/shelf/shelf_item_types.h" 9 #include "ash/common/shelf/shelf_item_types.h"
10 #include "ash/common/shelf/shelf_model.h" 10 #include "ash/common/shelf/shelf_model.h"
11 #include "ash/common/shelf/shelf_view.h" 11 #include "ash/common/shelf/shelf_view.h"
12 #include "ash/common/shelf/wm_shelf.h" 12 #include "ash/common/shelf/wm_shelf.h"
13 #include "ash/common/shell_window_ids.h" 13 #include "ash/common/shell_window_ids.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/wm/window_state.h" 15 #include "ash/common/wm/window_state.h"
16 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
17 #include "ash/common/wm_window.h" 17 #include "ash/common/wm_window.h"
18 #include "ash/metrics/desktop_task_switch_metric_recorder.h" 18 #include "ash/metrics/desktop_task_switch_metric_recorder.h"
19 #include "ash/shell.h" 19 #include "ash/shell.h"
20 #include "ash/wm/window_state_aura.h" 20 #include "ash/wm/window_state_aura.h"
21 #include "base/memory/ptr_util.h"
21 #include "base/metrics/histogram.h" 22 #include "base/metrics/histogram.h"
22 #include "base/metrics/user_metrics.h" 23 #include "base/metrics/user_metrics.h"
23 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
24 25
26 #if defined(OS_CHROMEOS)
27 #include "ash/common/metrics/pointer_metrics_recorder.h"
28 #endif
29
25 namespace ash { 30 namespace ash {
26 31
27 namespace { 32 namespace {
28 33
29 // Time in seconds between calls to "RecordPeriodicMetrics". 34 // Time in seconds between calls to "RecordPeriodicMetrics".
30 const int kAshPeriodicMetricsTimeInSeconds = 30 * 60; 35 const int kAshPeriodicMetricsTimeInSeconds = 30 * 60;
31 36
32 enum ActiveWindowStateType { 37 enum ActiveWindowStateType {
33 ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW, 38 ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW,
34 ACTIVE_WINDOW_STATE_TYPE_OTHER, 39 ACTIVE_WINDOW_STATE_TYPE_OTHER,
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 593 }
589 } 594 }
590 595
591 void UserMetricsRecorder::OnShellInitialized() { 596 void UserMetricsRecorder::OnShellInitialized() {
592 // Lazy creation of the DesktopTaskSwitchMetricRecorder because it accesses 597 // Lazy creation of the DesktopTaskSwitchMetricRecorder because it accesses
593 // Shell::GetInstance() which is not available when |this| is instantiated. 598 // Shell::GetInstance() which is not available when |this| is instantiated.
594 if (!desktop_task_switch_metric_recorder_) { 599 if (!desktop_task_switch_metric_recorder_) {
595 desktop_task_switch_metric_recorder_.reset( 600 desktop_task_switch_metric_recorder_.reset(
596 new DesktopTaskSwitchMetricRecorder()); 601 new DesktopTaskSwitchMetricRecorder());
597 } 602 }
603 #if defined(OS_CHROMEOS)
604 pointer_metrics_recorder_ = base::MakeUnique<PointerMetricsRecorder>();
605 #endif
598 } 606 }
599 607
600 void UserMetricsRecorder::OnShellShuttingDown() { 608 void UserMetricsRecorder::OnShellShuttingDown() {
601 desktop_task_switch_metric_recorder_.reset(); 609 desktop_task_switch_metric_recorder_.reset();
610
611 #if defined(OS_CHROMEOS)
612 // To clean up pointer_metrics_recorder_ properly, a valid shell instance is
613 // required. So explicitly delete it before the shell instance becomes
Daniel Erat 2016/09/29 22:58:46 total nit: change ". So" to ", so"
xiaoyinh(OOO Sep 11-29) 2016/09/30 00:25:40 Done.
614 // invalid.
615 pointer_metrics_recorder_.reset();
616 #endif
602 } 617 }
603 618
604 void UserMetricsRecorder::RecordPeriodicMetrics() { 619 void UserMetricsRecorder::RecordPeriodicMetrics() {
605 WmShelf* shelf = WmShelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow()); 620 WmShelf* shelf = WmShelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow());
606 // TODO(bruthig): Investigating whether the check for |manager| is necessary 621 // TODO(bruthig): Investigating whether the check for |manager| is necessary
607 // and add tests if it is. 622 // and add tests if it is.
608 if (shelf) { 623 if (shelf) {
609 // TODO(bruthig): Consider tracking the time spent in each alignment. 624 // TODO(bruthig): Consider tracking the time spent in each alignment.
610 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime", 625 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
611 shelf->SelectValueForShelfAlignment( 626 shelf->SelectValueForShelfAlignment(
(...skipping 22 matching lines...) Expand all
634 return IsUserActive() && !IsKioskModeActive(); 649 return IsUserActive() && !IsKioskModeActive();
635 } 650 }
636 651
637 void UserMetricsRecorder::StartTimer() { 652 void UserMetricsRecorder::StartTimer() {
638 timer_.Start(FROM_HERE, 653 timer_.Start(FROM_HERE,
639 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), 654 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
640 this, &UserMetricsRecorder::RecordPeriodicMetrics); 655 this, &UserMetricsRecorder::RecordPeriodicMetrics);
641 } 656 }
642 657
643 } // namespace ash 658 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698