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

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

Issue 2618143002: cros: Remove some OS platform ifdefs from ash (Closed)
Patch Set: rebase Created 3 years, 11 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
« no previous file with comments | « ash/metrics/user_metrics_recorder.h ('k') | ash/mus/bridge/wm_shell_mus.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/metrics/pointer_metrics_recorder.h"
7 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/shelf_delegate.h" 9 #include "ash/common/shelf/shelf_delegate.h"
9 #include "ash/common/shelf/shelf_item_types.h" 10 #include "ash/common/shelf/shelf_item_types.h"
10 #include "ash/common/shelf/shelf_model.h" 11 #include "ash/common/shelf/shelf_model.h"
11 #include "ash/common/shelf/shelf_view.h" 12 #include "ash/common/shelf/shelf_view.h"
12 #include "ash/common/shelf/wm_shelf.h" 13 #include "ash/common/shelf/wm_shelf.h"
13 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
14 #include "ash/common/wm/window_state.h" 15 #include "ash/common/wm/window_state.h"
15 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
16 #include "ash/common/wm_window.h" 17 #include "ash/common/wm_window.h"
17 #include "ash/metrics/desktop_task_switch_metric_recorder.h" 18 #include "ash/metrics/desktop_task_switch_metric_recorder.h"
18 #include "ash/public/cpp/shell_window_ids.h" 19 #include "ash/public/cpp/shell_window_ids.h"
19 #include "ash/shell.h" 20 #include "ash/shell.h"
20 #include "ash/wm/window_state_aura.h" 21 #include "ash/wm/window_state_aura.h"
21 #include "base/memory/ptr_util.h" 22 #include "base/memory/ptr_util.h"
22 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
23 #include "base/metrics/user_metrics.h" 24 #include "base/metrics/user_metrics.h"
24 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
25 26
26 #if defined(OS_CHROMEOS)
27 #include "ash/common/metrics/pointer_metrics_recorder.h"
28 #endif
29
30 namespace ash { 27 namespace ash {
31 28
32 namespace { 29 namespace {
33 30
34 // Time in seconds between calls to "RecordPeriodicMetrics". 31 // Time in seconds between calls to "RecordPeriodicMetrics".
35 const int kAshPeriodicMetricsTimeInSeconds = 30 * 60; 32 const int kAshPeriodicMetricsTimeInSeconds = 30 * 60;
36 33
37 enum ActiveWindowStateType { 34 enum ActiveWindowStateType {
38 ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW, 35 ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW,
39 ACTIVE_WINDOW_STATE_TYPE_OTHER, 36 ACTIVE_WINDOW_STATE_TYPE_OTHER,
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 594 }
598 } 595 }
599 596
600 void UserMetricsRecorder::OnShellInitialized() { 597 void UserMetricsRecorder::OnShellInitialized() {
601 // Lazy creation of the DesktopTaskSwitchMetricRecorder because it accesses 598 // Lazy creation of the DesktopTaskSwitchMetricRecorder because it accesses
602 // Shell::GetInstance() which is not available when |this| is instantiated. 599 // Shell::GetInstance() which is not available when |this| is instantiated.
603 if (!desktop_task_switch_metric_recorder_) { 600 if (!desktop_task_switch_metric_recorder_) {
604 desktop_task_switch_metric_recorder_.reset( 601 desktop_task_switch_metric_recorder_.reset(
605 new DesktopTaskSwitchMetricRecorder()); 602 new DesktopTaskSwitchMetricRecorder());
606 } 603 }
607 #if defined(OS_CHROMEOS)
608 pointer_metrics_recorder_ = base::MakeUnique<PointerMetricsRecorder>(); 604 pointer_metrics_recorder_ = base::MakeUnique<PointerMetricsRecorder>();
609 #endif
610 } 605 }
611 606
612 void UserMetricsRecorder::OnShellShuttingDown() { 607 void UserMetricsRecorder::OnShellShuttingDown() {
613 desktop_task_switch_metric_recorder_.reset(); 608 desktop_task_switch_metric_recorder_.reset();
614 609
615 #if defined(OS_CHROMEOS)
616 // To clean up pointer_metrics_recorder_ properly, a valid shell instance is 610 // To clean up pointer_metrics_recorder_ properly, a valid shell instance is
617 // required, so explicitly delete it before the shell instance becomes 611 // required, so explicitly delete it before the shell instance becomes
618 // invalid. 612 // invalid.
619 pointer_metrics_recorder_.reset(); 613 pointer_metrics_recorder_.reset();
620 #endif
621 } 614 }
622 615
623 void UserMetricsRecorder::RecordPeriodicMetrics() { 616 void UserMetricsRecorder::RecordPeriodicMetrics() {
624 WmShelf* shelf = WmShelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow()); 617 WmShelf* shelf = WmShelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow());
625 // TODO(bruthig): Investigating whether the check for |manager| is necessary 618 // TODO(bruthig): Investigating whether the check for |manager| is necessary
626 // and add tests if it is. 619 // and add tests if it is.
627 if (shelf) { 620 if (shelf) {
628 // TODO(bruthig): Consider tracking the time spent in each alignment. 621 // TODO(bruthig): Consider tracking the time spent in each alignment.
629 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime", 622 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
630 shelf->SelectValueForShelfAlignment( 623 shelf->SelectValueForShelfAlignment(
(...skipping 22 matching lines...) Expand all
653 return IsUserActive() && !IsKioskModeActive() && !IsArcKioskModeActive(); 646 return IsUserActive() && !IsKioskModeActive() && !IsArcKioskModeActive();
654 } 647 }
655 648
656 void UserMetricsRecorder::StartTimer() { 649 void UserMetricsRecorder::StartTimer() {
657 timer_.Start(FROM_HERE, 650 timer_.Start(FROM_HERE,
658 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), 651 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
659 this, &UserMetricsRecorder::RecordPeriodicMetrics); 652 this, &UserMetricsRecorder::RecordPeriodicMetrics);
660 } 653 }
661 654
662 } // namespace ash 655 } // namespace ash
OLDNEW
« no previous file with comments | « ash/metrics/user_metrics_recorder.h ('k') | ash/mus/bridge/wm_shell_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698