| Index: ash/periodic_metrics_recorder.cc
|
| diff --git a/ash/periodic_metrics_recorder.cc b/ash/periodic_metrics_recorder.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2bfc89f46ed25eeaa5a4eb0e32cad56b89c43f41
|
| --- /dev/null
|
| +++ b/ash/periodic_metrics_recorder.cc
|
| @@ -0,0 +1,48 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ash/periodic_metrics_recorder.h"
|
| +
|
| +#include "ash/shelf/shelf_layout_manager.h"
|
| +#include "ash/shelf/shelf_widget.h"
|
| +#include "ash/shell.h"
|
| +#include "base/metrics/histogram.h"
|
| +
|
| +namespace ash {
|
| +namespace {
|
| +const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM = 0;
|
| +const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT = 1;
|
| +const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT = 2;
|
| +const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT = 3;
|
| +}
|
| +
|
| +// Time in seconds between calls to "RecordMetrics".
|
| +const int kAshPeriodicMetricsTimeInSeconds = 30 * 60;
|
| +
|
| +AshPeriodicMetricsRecorder::AshPeriodicMetricsRecorder() {
|
| + timer_.Start(FROM_HERE,
|
| + base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
|
| + this,
|
| + &AshPeriodicMetricsRecorder::RecordMetrics);
|
| +}
|
| +
|
| +AshPeriodicMetricsRecorder::~AshPeriodicMetricsRecorder() {
|
| + timer_.Stop();
|
| +}
|
| +
|
| +void AshPeriodicMetricsRecorder::RecordMetrics() {
|
| + internal::ShelfLayoutManager* manager =
|
| + internal::ShelfLayoutManager::ForLauncher(Shell::GetPrimaryRootWindow());
|
| + if (manager) {
|
| + UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
|
| + manager->SelectValueForShelfAlignment(
|
| + SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
|
| + SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
|
| + SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT,
|
| + -1),
|
| + SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
|
| + }
|
| +}
|
| +
|
| +} // namespace ash
|
|
|