Android: add UMA instrumentation for inertial sensors.
[chromium-blink-merge.git] / ash / periodic_metrics_recorder.cc
bloba1eb927a08c43e0e57e96e5778d10dac05eed5ff
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
3 // found in the LICENSE file.
5 #include "ash/periodic_metrics_recorder.h"
7 #include "ash/shelf/shelf_layout_manager.h"
8 #include "ash/shelf/shelf_view.h"
9 #include "ash/shelf/shelf_widget.h"
10 #include "ash/shell.h"
11 #include "base/metrics/histogram.h"
13 namespace ash {
15 // Time in seconds between calls to "RecordMetrics".
16 const int kAshPeriodicMetricsTimeInSeconds = 30 * 60;
18 PeriodicMetricsRecorder::PeriodicMetricsRecorder() {
19 timer_.Start(FROM_HERE,
20 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
21 this,
22 &PeriodicMetricsRecorder::RecordMetrics);
25 PeriodicMetricsRecorder::~PeriodicMetricsRecorder() {
26 timer_.Stop();
29 void PeriodicMetricsRecorder::RecordMetrics() {
30 internal::ShelfLayoutManager* manager =
31 internal::ShelfLayoutManager::ForLauncher(Shell::GetPrimaryRootWindow());
32 if (manager) {
33 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
34 manager->SelectValueForShelfAlignment(
35 internal::SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
36 internal::SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
37 internal::SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT,
38 -1),
39 internal::SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
43 } // namespace ash