Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / background_sync / background_sync_metrics.h
blobd8c26da4677f6195711c07c65ebea70f82206f85
1 // Copyright 2015 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 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_METRICS_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_METRICS_H_
8 #include "base/macros.h"
9 #include "base/time/time.h"
10 #include "content/browser/background_sync/background_sync.pb.h"
11 #include "content/browser/background_sync/background_sync_status.h"
13 namespace content {
15 // This class contains the logic for recording usage metrics for the Background
16 // Sync API. It is stateless, containing only static methods, so it can be used
17 // by any of the Background Sync code, without needing to be instantiated
18 // explicitly.
19 class BackgroundSyncMetrics {
20 public:
21 enum RegistrationCouldFire {
22 REGISTRATION_COULD_NOT_FIRE,
23 REGISTRATION_COULD_FIRE
26 enum RegistrationIsDuplicate {
27 REGISTRATION_IS_NOT_DUPLICATE,
28 REGISTRATION_IS_DUPLICATE
31 // Records the result of a single sync event firing.
32 static void RecordEventResult(SyncPeriodicity periodicity, bool result);
34 // Records the result of running a batch of sync events, including the total
35 // time spent, and the batch size.
36 static void RecordBatchSyncEventComplete(const base::TimeDelta& time,
37 int number_of_batched_sync_events);
39 // Records the result of trying to register a sync. |could_fire| indicates
40 // whether the conditions were sufficient for the sync to fire immediately at
41 // the time it was registered.
42 static void CountRegister(SyncPeriodicity periodicity,
43 RegistrationCouldFire could_fire,
44 RegistrationIsDuplicate registration_is_duplicate,
45 BackgroundSyncStatus result);
47 // Records the result of trying to unregister a sync.
48 static void CountUnregister(SyncPeriodicity periodicity,
49 BackgroundSyncStatus result);
51 private:
52 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundSyncMetrics);
55 } // namespace content
57 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_METRICS_H_