Skip to content

Commit

Permalink
Revert "Remove deprecated TimeDelta functions."
Browse files Browse the repository at this point in the history
This reverts commit 15de2eb.

Reason for revert: Compile error on bot
https://ci.chromium.org/ui/p/chromium/builders/ci/lacros-amd64-generic-binary-size-rel/22120/overview

Original change's description:
> Remove deprecated TimeDelta functions.
>
> Bug: 1243777
> Change-Id: I560511a03b2dbac8104876ea4fad88d697abb515
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3202711
> Owners-Override: Peter Kasting <pkasting@chromium.org>
> Reviewed-by: Peter Boström <pbos@chromium.org>
> Commit-Queue: Peter Kasting <pkasting@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#929500}

Bug: 1243777
Change-Id: Ib90ce44e030da24c05742265039a1444539eea87
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211762
Reviewed-by: Yoichi Osato <yoichio@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Noel Gordon <noel@chromium.org>
Auto-Submit: Yoichi Osato <yoichio@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Noel Gordon <noel@chromium.org>
Owners-Override: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#929511}
  • Loading branch information
Yoichi Osato authored and Chromium LUCI CQ committed Oct 8, 2021
1 parent f8b0e20 commit 4b09875
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions base/time/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ class BASE_EXPORT TimeDelta {
public:
constexpr TimeDelta() = default;

// Converts units of time to TimeDeltas.
// These conversions treat minimum argument values as min type values or -inf,
// and maximum ones as max type values or +inf; and their results will produce
// an is_min() or is_max() TimeDelta. WARNING: Floating point arithmetic is
// such that FromXXXD(t.InXXXF()) may not precisely equal |t|. Hence, floating
// point values should not be used for storage.
static constexpr TimeDelta FromDays(int64_t days);
static constexpr TimeDelta FromHours(int64_t hours);
static constexpr TimeDelta FromMinutes(int64_t minutes);
static constexpr TimeDelta FromSecondsD(double secs);
static constexpr TimeDelta FromSeconds(int64_t secs);
static constexpr TimeDelta FromMillisecondsD(double ms);
static constexpr TimeDelta FromMilliseconds(int64_t ms);
static constexpr TimeDelta FromMicrosecondsD(double us);
static constexpr TimeDelta FromMicroseconds(int64_t us);
static constexpr TimeDelta FromNanosecondsD(double ns);
static constexpr TimeDelta FromNanoseconds(int64_t ns);

#if defined(OS_WIN)
static TimeDelta FromQPCValue(LONGLONG qpc_value);
// TODO(crbug.com/989694): Avoid base::TimeDelta factory functions
Expand All @@ -134,6 +152,9 @@ class BASE_EXPORT TimeDelta {
static TimeDelta FromMachTime(uint64_t mach_time);
#endif // defined(OS_MAC)

// Converts a frequency in Hertz (cycles per second) into a period.
static constexpr TimeDelta FromHz(double frequency);

// Converts an integer value representing TimeDelta to a class. This is used
// when deserializing a |TimeDelta| structure, using a value known to be
// compatible. It is not provided as a constructor because the integer type
Expand Down Expand Up @@ -920,6 +941,68 @@ constexpr TimeDelta Hertz(T n) {
saturated_cast<int64_t>(Time::kMicrosecondsPerSecond / n));
}

// Deprecated TimeDelta conversion functions, to be replaced by the above.

// static
constexpr TimeDelta TimeDelta::FromDays(int64_t days) {
return Days(days);
}

// static
constexpr TimeDelta TimeDelta::FromHours(int64_t hours) {
return Hours(hours);
}

// static
constexpr TimeDelta TimeDelta::FromMinutes(int64_t minutes) {
return Minutes(minutes);
}

// static
constexpr TimeDelta TimeDelta::FromSecondsD(double secs) {
return Seconds(secs);
}

// static
constexpr TimeDelta TimeDelta::FromSeconds(int64_t secs) {
return Seconds(secs);
}

// static
constexpr TimeDelta TimeDelta::FromMillisecondsD(double ms) {
return Milliseconds(ms);
}

// static
constexpr TimeDelta TimeDelta::FromMilliseconds(int64_t ms) {
return Milliseconds(ms);
}

// static
constexpr TimeDelta TimeDelta::FromMicrosecondsD(double us) {
return Microseconds(us);
}

// static
constexpr TimeDelta TimeDelta::FromMicroseconds(int64_t us) {
return Microseconds(us);
}

// static
constexpr TimeDelta TimeDelta::FromNanosecondsD(double ns) {
return Nanoseconds(ns);
}

// static
constexpr TimeDelta TimeDelta::FromNanoseconds(int64_t ns) {
return Nanoseconds(ns);
}

// static
constexpr TimeDelta TimeDelta::FromHz(double frequency) {
return Hertz(frequency);
}

// TimeDelta functions that must appear below the declarations of Time/TimeDelta

constexpr double TimeDelta::ToHz() const {
Expand Down

0 comments on commit 4b09875

Please sign in to comment.