Chromium Code Reviews| Index: content/browser/background_sync/background_sync_metrics.cc |
| diff --git a/content/browser/background_sync/background_sync_metrics.cc b/content/browser/background_sync/background_sync_metrics.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a91f9fa95493729409b6f7f0ac7c5165b2f2b2ec |
| --- /dev/null |
| +++ b/content/browser/background_sync/background_sync_metrics.cc |
| @@ -0,0 +1,77 @@ |
| +// Copyright 2015 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 "content/browser/background_sync/background_sync_metrics.h" |
| + |
| +#include "base/metrics/histogram_macros.h" |
| +#include "base/metrics/user_metrics_action.h" |
| + |
| +namespace content { |
| + |
| +void BackgroundSyncMetrics::RecordEventResult(SyncPeriodicity periodicity, |
| + bool success) { |
| + switch (periodicity) { |
| + case SYNC_ONE_SHOT: |
| + UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Event.OneShotResult", success); |
| + return; |
| + case SYNC_PERIODIC: |
| + UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Event.PeriodicResult", success); |
| + return; |
| + } |
| + NOTREACHED(); |
| +} |
| + |
| +void BackgroundSyncMetrics::RecordSyncEventHandlingTime( |
| + const base::TimeDelta& time) { |
| + // The total event handling time should be under 5 minutes; we'll record up to |
| + // 6 minutes, to be safe. |
| + UMA_HISTOGRAM_CUSTOM_TIMES("BackgroundSync.Event.Time", time, |
| + base::TimeDelta::FromMilliseconds(10), |
| + base::TimeDelta::FromMinutes(6), 50); |
| +} |
| + |
| +void BackgroundSyncMetrics::CountRegistration( |
| + SyncPeriodicity periodicity, |
| + RegistrationCouldFire registration_could_fire, |
| + RegistrationIsDuplicate registration_is_duplicate, |
| + BackgroundSyncManager::ErrorType result) { |
| + switch (periodicity) { |
| + case SYNC_ONE_SHOT: |
| + UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Registration.OneShot", result, |
| + BackgroundSyncManager::ERROR_TYPE_MAX + 1); |
| + UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Registration.OneShot.CouldFire", |
| + registration_could_fire); |
| + UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Registration.OneShot.IsDuplicate", |
| + registration_is_duplicate); |
| + return; |
| + case SYNC_PERIODIC: |
| + UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Registration.Periodic", result, |
| + BackgroundSyncManager::ERROR_TYPE_MAX + 1); |
| + UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Registration.Periodic.CouldFire", |
|
jkarlin
2015/07/14 21:56:22
These should either be made proper booleans or use
iclelland
2015/07/15 14:22:25
Done.
|
| + registration_could_fire); |
| + UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Registration.Periodic.IsDuplicate", |
| + registration_is_duplicate); |
| + return; |
| + } |
| + NOTREACHED(); |
| +} |
| + |
| +void BackgroundSyncMetrics::CountUnregistration( |
| + SyncPeriodicity periodicity, |
| + BackgroundSyncManager::ErrorType result) { |
| + switch (periodicity) { |
| + case SYNC_ONE_SHOT: |
| + UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Unregistration.OneShot", result, |
| + BackgroundSyncManager::ERROR_TYPE_MAX + 1); |
| + return; |
| + case SYNC_PERIODIC: |
| + UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Unregistration.Periodic", |
| + result, |
| + BackgroundSyncManager::ERROR_TYPE_MAX + 1); |
| + return; |
| + } |
| + NOTREACHED(); |
| +} |
| + |
| +} // namespace content |