chromium/gin/time_clamper.h

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GIN_TIME_CLAMPER_H_
#define GIN_TIME_CLAMPER_H_

#include <algorithm>

#include "base/rand_util.h"
#include "base/time/time.h"
#include "gin/gin_export.h"

namespace gin {

// This class adds some amount of jitter to time. That is, for every
// `kResolutionMicros` microseconds it calculates a threshold (using a hash)
// that once exceeded advances to the next threshold. This is done so that
// time jumps slightly and does not move smoothly.
//
// NOTE: the implementation assumes it's used for servicing calls from JS,
// which uses the unix-epoch at time 0.
// TODO(skyostil): Deduplicate this with the clamper in Blink.
class GIN_EXPORT TimeClamper {};

}  // namespace gin

#endif  // GIN_TIME_CLAMPER_H_