OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_METRICS_H_ |
| 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_METRICS_H_ |
| 7 |
| 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_manager.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 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 |
| 24 }; |
| 25 |
| 26 enum RegistrationIsDuplicate { |
| 27 REGISTRATION_IS_NOT_DUPLICATE, |
| 28 REGISTRATION_IS_DUPLICATE |
| 29 }; |
| 30 |
| 31 // Records the result of a single sync event firing. |
| 32 static void RecordEventResult(SyncPeriodicity periodicity, bool result); |
| 33 |
| 34 // Records the time spent running a batch of sync events. |
| 35 static void RecordBatchSyncEventHandlingTime(const base::TimeDelta& time); |
| 36 |
| 37 // Records the result of trying to register a sync. |could_fire| indicates |
| 38 // whether the conditions were sufficient for the sync to fire immediately at |
| 39 // the time it was registered. |
| 40 static void CountRegister(SyncPeriodicity periodicity, |
| 41 RegistrationCouldFire could_fire, |
| 42 RegistrationIsDuplicate registration_is_duplicate, |
| 43 BackgroundSyncManager::ErrorType result); |
| 44 |
| 45 // Records the result of trying to unregister a sync. |
| 46 static void CountUnregister(SyncPeriodicity periodicity, |
| 47 BackgroundSyncManager::ErrorType result); |
| 48 |
| 49 private: |
| 50 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundSyncMetrics); |
| 51 }; |
| 52 |
| 53 } // namespace content |
| 54 |
| 55 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_METRICS_H_ |
OLD | NEW |