#ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_METRICS_H_
#define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_METRICS_H_
#include "base/time/time.h"
#include "content/browser/background_sync/background_sync.pb.h"
#include "content/browser/background_sync/background_sync_status.h"
#include "content/common/content_export.h"
#include "third_party/blink/public/mojom/background_sync/background_sync.mojom.h"
namespace content {
class CONTENT_EXPORT BackgroundSyncMetrics {
public:
enum ResultPattern {
RESULT_PATTERN_SUCCESS_FOREGROUND = 0,
RESULT_PATTERN_SUCCESS_BACKGROUND = 1,
RESULT_PATTERN_FAILED_FOREGROUND = 2,
RESULT_PATTERN_FAILED_BACKGROUND = 3,
RESULT_PATTERN_MAX = RESULT_PATTERN_FAILED_BACKGROUND,
};
enum RegistrationCouldFire {
REGISTRATION_COULD_NOT_FIRE,
REGISTRATION_COULD_FIRE
};
enum RegistrationIsDuplicate {
REGISTRATION_IS_NOT_DUPLICATE,
REGISTRATION_IS_DUPLICATE
};
BackgroundSyncMetrics() = delete;
BackgroundSyncMetrics(const BackgroundSyncMetrics&) = delete;
BackgroundSyncMetrics& operator=(const BackgroundSyncMetrics&) = delete;
static void RecordEventStarted(blink::mojom::BackgroundSyncType sync_type,
bool startedin_foreground);
static void RecordEventResult(blink::mojom::BackgroundSyncType sync_type,
bool result,
bool finished_in_foreground);
static void RecordRegistrationComplete(bool event_succeeded,
int num_attempts_required);
static void RecordBatchSyncEventComplete(
blink::mojom::BackgroundSyncType sync_type,
const base::TimeDelta& time,
bool from_wakeup_task,
int number_of_batched_sync_events);
static void CountRegisterSuccess(
blink::mojom::BackgroundSyncType sync_type,
int64_t min_interval_ms,
RegistrationCouldFire could_fire,
RegistrationIsDuplicate registration_is_duplicate);
static void CountRegisterFailure(blink::mojom::BackgroundSyncType sync_type,
BackgroundSyncStatus status);
static void CountUnregisterPeriodicSync(BackgroundSyncStatus status);
static void RecordEventsFiredFromWakeupTask(
blink::mojom::BackgroundSyncType sync_type,
bool fired_events);
};
}
#endif