Migrate "base::TimeDelta::FromX" to "base:X".
All changes were done automatically with git grep, sed, xargs, etc.
No-Presubmit: true
No-Try: true
Bug: 1243777
Change-Id: I7cc197e9027f7837cd36afc67a209079f85ec364
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198824
Commit-Queue: Peter Kasting <[email protected]>
Owners-Override: Peter Kasting <[email protected]>
Reviewed-by: Peter Boström <[email protected]>
Cr-Commit-Position: refs/heads/main@{#927512}
diff --git a/base/allocator/allocator_interception_mac.mm b/base/allocator/allocator_interception_mac.mm
index bd6a61a..9870c844 100644
--- a/base/allocator/allocator_interception_mac.mm
+++ b/base/allocator/allocator_interception_mac.mm
@@ -547,8 +547,8 @@
} // namespace
void PeriodicallyShimNewMallocZones() {
- base::Time end_time = base::Time::Now() + base::TimeDelta::FromMinutes(1);
- base::TimeDelta initial_delay = base::TimeDelta::FromSeconds(1);
+ base::Time end_time = base::Time::Now() + base::Minutes(1);
+ base::TimeDelta initial_delay = base::Seconds(1);
ShimNewMallocZonesAndReschedule(end_time, initial_delay);
}
diff --git a/base/allocator/partition_allocator/partition_alloc_perftest.cc b/base/allocator/partition_allocator/partition_alloc_perftest.cc
index 771f663..4a50ad2 100644
--- a/base/allocator/partition_allocator/partition_alloc_perftest.cc
+++ b/base/allocator/partition_allocator/partition_alloc_perftest.cc
@@ -33,7 +33,7 @@
// Change kTimeLimit to something higher if you need more time to capture a
// trace.
-constexpr base::TimeDelta kTimeLimit = base::TimeDelta::FromSeconds(2);
+constexpr base::TimeDelta kTimeLimit = base::Seconds(2);
constexpr int kWarmupRuns = 10000;
constexpr int kTimeCheckInterval = 100000;
constexpr size_t kAllocSize = 40;
diff --git a/base/android/early_trace_event_binding.cc b/base/android/early_trace_event_binding.cc
index f278025..e9a88174 100644
--- a/base/android/early_trace_event_binding.cc
+++ b/base/android/early_trace_event_binding.cc
@@ -107,7 +107,7 @@
TRACE_EVENT_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP_AND_FLAGS0(
internal::kJavaTraceCategory, name.c_str(), TRACE_ID_LOCAL(id),
- base::TimeTicks() + base::TimeDelta::FromNanoseconds(timestamp_ns),
+ base::TimeTicks() + base::Nanoseconds(timestamp_ns),
TRACE_EVENT_FLAG_JAVA_STRING_LITERALS | TRACE_EVENT_FLAG_COPY);
}
@@ -120,7 +120,7 @@
TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP_AND_FLAGS0(
internal::kJavaTraceCategory, name.c_str(), TRACE_ID_LOCAL(id),
- base::TimeTicks() + base::TimeDelta::FromNanoseconds(timestamp_ns),
+ base::TimeTicks() + base::Nanoseconds(timestamp_ns),
TRACE_EVENT_FLAG_JAVA_STRING_LITERALS | TRACE_EVENT_FLAG_COPY);
}
diff --git a/base/android/jank_metric_uma_recorder.cc b/base/android/jank_metric_uma_recorder.cc
index f550522..ff09dab 100644
--- a/base/android/jank_metric_uma_recorder.cc
+++ b/base/android/jank_metric_uma_recorder.cc
@@ -80,15 +80,13 @@
}
for (const int64_t frame_duration_ns : durations_ns) {
- base::UmaHistogramTimes(
- frame_duration_histogram_name,
- base::TimeDelta::FromNanoseconds(frame_duration_ns));
+ base::UmaHistogramTimes(frame_duration_histogram_name,
+ base::Nanoseconds(frame_duration_ns));
}
for (const int64_t jank_burst_duration_ns : jank_bursts_ns) {
- base::UmaHistogramTimes(
- jank_burst_histogram_name,
- base::TimeDelta::FromNanoseconds(jank_burst_duration_ns));
+ base::UmaHistogramTimes(jank_burst_histogram_name,
+ base::Nanoseconds(jank_burst_duration_ns));
}
base::UmaHistogramCounts1000(missed_frames_histogram_name,
diff --git a/base/android/reached_code_profiler.cc b/base/android/reached_code_profiler.cc
index e64bd9c..4c8a10a 100644
--- a/base/android/reached_code_profiler.cc
+++ b/base/android/reached_code_profiler.cc
@@ -64,9 +64,8 @@
constexpr uint64_t kIterationsBetweenUpdates = 100;
constexpr int kProfilerSignal = SIGWINCH;
-constexpr base::TimeDelta kSamplingInterval =
- base::TimeDelta::FromMilliseconds(10);
-constexpr base::TimeDelta kDumpInterval = base::TimeDelta::FromSeconds(30);
+constexpr base::TimeDelta kSamplingInterval = base::Milliseconds(10);
+constexpr base::TimeDelta kDumpInterval = base::Seconds(30);
void HandleSignal(int signal, siginfo_t* info, void* context) {
if (signal != kProfilerSignal)
@@ -283,7 +282,7 @@
switches::kReachedCodeSamplingIntervalUs),
&interval_us) &&
interval_us > 0) {
- sampling_interval = base::TimeDelta::FromMicroseconds(interval_us);
+ sampling_interval = base::Microseconds(interval_us);
}
ReachedCodeProfiler::GetInstance()->Start(library_process_type,
sampling_interval);
diff --git a/base/debug/stack_trace_perftest.cc b/base/debug/stack_trace_perftest.cc
index 8299a6fb..6414fa7 100644
--- a/base/debug/stack_trace_perftest.cc
+++ b/base/debug/stack_trace_perftest.cc
@@ -16,7 +16,7 @@
// Change kTimeLimit to something higher if you need more time to capture a
// trace.
-constexpr base::TimeDelta kTimeLimit = base::TimeDelta::FromSeconds(3);
+constexpr base::TimeDelta kTimeLimit = base::Seconds(3);
constexpr int kWarmupRuns = 100;
constexpr int kTimeCheckInterval = 1000;
constexpr char kMetricStackTraceDuration[] = ".duration_per_run";
diff --git a/base/files/file_locking_unittest.cc b/base/files/file_locking_unittest.cc
index c2f21f9..3122c412 100644
--- a/base/files/file_locking_unittest.cc
+++ b/base/files/file_locking_unittest.cc
@@ -65,7 +65,7 @@
while (!CheckEvent(signal_dir, signal_file)) {
if (base::Time::Now() > finish_by)
return false;
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
+ base::PlatformThread::Sleep(base::Milliseconds(10));
}
return true;
}
diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc
index 9721fca..1d7b01a 100644
--- a/base/files/file_unittest.cc
+++ b/base/files/file_unittest.cc
@@ -401,7 +401,7 @@
// Add 2 seconds to account for possible rounding errors on
// filesystems that use a 1s or 2s timestamp granularity.
- base::Time now = base::Time::Now() + base::TimeDelta::FromSeconds(2);
+ base::Time now = base::Time::Now() + base::Seconds(2);
EXPECT_EQ(0, info.size);
EXPECT_FALSE(info.is_directory);
EXPECT_FALSE(info.is_symbolic_link);
@@ -420,10 +420,8 @@
// It's best to add values that are multiples of 2 (in seconds)
// to the current last_accessed and last_modified times, because
// FATxx uses a 2s timestamp granularity.
- base::Time new_last_accessed =
- info.last_accessed + base::TimeDelta::FromSeconds(234);
- base::Time new_last_modified =
- info.last_modified + base::TimeDelta::FromMinutes(567);
+ base::Time new_last_accessed = info.last_accessed + base::Seconds(234);
+ base::Time new_last_modified = info.last_modified + base::Minutes(567);
EXPECT_TRUE(file.SetTimes(new_last_accessed, new_last_modified));
diff --git a/base/i18n/time_formatting.cc b/base/i18n/time_formatting.cc
index 7cc1332f..95cd5ef3 100644
--- a/base/i18n/time_formatting.cc
+++ b/base/i18n/time_formatting.cc
@@ -193,7 +193,7 @@
std::u16string* out) {
DCHECK(out);
UErrorCode status = U_ZERO_ERROR;
- const int total_minutes = ClampRound(time / base::TimeDelta::FromMinutes(1));
+ const int total_minutes = ClampRound(time / base::Minutes(1));
const int hours = total_minutes / 60;
const int minutes = total_minutes % 60;
UMeasureFormatWidth u_width = DurationWidthToMeasureWidth(width);
diff --git a/base/lazy_instance_unittest.cc b/base/lazy_instance_unittest.cc
index bc990b0..14bb2891 100644
--- a/base/lazy_instance_unittest.cc
+++ b/base/lazy_instance_unittest.cc
@@ -44,7 +44,7 @@
public:
SlowConstructor() : some_int_(0) {
// Sleep for 1 second to try to cause a race.
- base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
+ base::PlatformThread::Sleep(base::Seconds(1));
++constructed;
some_int_ = 12;
}
@@ -289,7 +289,7 @@
background_getter.Start();
while (!BlockingConstructor::WasConstructorCalled())
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
+ base::PlatformThread::Sleep(base::Milliseconds(1));
// Spin 4 foreground thread per core contending to get the already under
// construction LazyInstance. When they are all running and poking at it :
@@ -316,6 +316,5 @@
// Fail if this test takes more than 5 seconds (it takes 5-10 seconds on a
// Z840 without r527445 but is expected to be fast (~30ms) with the fix).
- EXPECT_LT(base::TimeTicks::Now() - test_begin,
- base::TimeDelta::FromSeconds(5));
+ EXPECT_LT(base::TimeTicks::Now() - test_begin, base::Seconds(5));
}
diff --git a/base/message_loop/fd_watch_controller_posix_unittest.cc b/base/message_loop/fd_watch_controller_posix_unittest.cc
index ee5c3d0..479091e 100644
--- a/base/message_loop/fd_watch_controller_posix_unittest.cc
+++ b/base/message_loop/fd_watch_controller_posix_unittest.cc
@@ -516,8 +516,7 @@
RunLoop timer_run_loop;
env.GetMainThreadTaskRunner()->PostDelayedTask(
- FROM_HERE, timer_run_loop.QuitClosure(),
- base::TimeDelta::FromMilliseconds(10));
+ FROM_HERE, timer_run_loop.QuitClosure(), base::Milliseconds(10));
RunLoop watcher_run_loop;
CallClosureHandler handler(watcher_run_loop.QuitClosure(), OnceClosure());
diff --git a/base/message_loop/message_pump_perftest.cc b/base/message_loop/message_pump_perftest.cc
index e15405c..5afc92b 100644
--- a/base/message_loop/message_pump_perftest.cc
+++ b/base/message_loop/message_pump_perftest.cc
@@ -90,7 +90,7 @@
lastnow = now;
minimum = std::min(minimum, laptime);
maximum = std::max(maximum, laptime);
- } while (now - start < base::TimeDelta::FromSeconds(kTargetTimeSec));
+ } while (now - start < base::Seconds(kTargetTimeSec));
scheduling_times_[index] = now - start;
if (ThreadTicks::IsSupported())
diff --git a/base/message_loop/timer_slack.cc b/base/message_loop/timer_slack.cc
index 5864ca1..d0cc61aa 100644
--- a/base/message_loop/timer_slack.cc
+++ b/base/message_loop/timer_slack.cc
@@ -21,7 +21,7 @@
constexpr base::FeatureParam<base::TimeDelta> kSlackValueMs{
&kLudicrousTimerSlack, "slack_ms",
// 1.5 seconds default slack for this ludicrous experiment.
- base::TimeDelta::FromMilliseconds(1500)};
+ base::Milliseconds(1500)};
} // namespace
} // namespace features
diff --git a/base/message_loop/timer_slack_unittest.cc b/base/message_loop/timer_slack_unittest.cc
index 34adac2..c6adc35 100644
--- a/base/message_loop/timer_slack_unittest.cc
+++ b/base/message_loop/timer_slack_unittest.cc
@@ -48,7 +48,7 @@
TEST(TimerSlackTest, LudicrousTimerSlackDefaultsOff) {
EXPECT_FALSE(IsLudicrousTimerSlackEnabled());
- EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500), GetLudicrousTimerSlack());
+ EXPECT_EQ(base::Milliseconds(1500), GetLudicrousTimerSlack());
#if defined(OS_MAC)
MessagePumpCFRunLoop message_pump_cf_run_loop;
@@ -78,7 +78,7 @@
base::features::kLudicrousTimerSlack);
EXPECT_TRUE(IsLudicrousTimerSlackEnabled());
- EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500), GetLudicrousTimerSlack());
+ EXPECT_EQ(base::Milliseconds(1500), GetLudicrousTimerSlack());
#if defined(OS_MAC)
MessagePumpCFRunLoop message_pump_cf_run_loop;
@@ -180,7 +180,7 @@
scoped_feature_list.InitAndEnableFeatureWithParameters(
base::features::kLudicrousTimerSlack, parameters);
- EXPECT_EQ(base::TimeDelta::FromMilliseconds(12345), GetLudicrousTimerSlack());
+ EXPECT_EQ(base::Milliseconds(12345), GetLudicrousTimerSlack());
}
TEST(TimerSlackTest, LudicrousTimerSlackSlackSuspendResume) {
diff --git a/base/metrics/field_trial_params_unittest.cc b/base/metrics/field_trial_params_unittest.cc
index 6f52ad7..3c21299 100644
--- a/base/metrics/field_trial_params_unittest.cc
+++ b/base/metrics/field_trial_params_unittest.cc
@@ -412,8 +412,8 @@
CreateFeatureWithTrial(kFeature, FeatureList::OVERRIDE_ENABLE_FEATURE,
trial.get());
- EXPECT_EQ(a.Get(), base::TimeDelta::FromSecondsD(1.5));
- EXPECT_EQ(b.Get(), base::TimeDelta::FromMinutes(62));
+ EXPECT_EQ(a.Get(), base::Seconds(1.5));
+ EXPECT_EQ(b.Get(), base::Minutes(62));
EXPECT_EQ(c.Get(), base::TimeDelta()); // invalid
EXPECT_EQ(d.Get(), base::TimeDelta()); // invalid
EXPECT_EQ(e.Get(), base::TimeDelta()); // empty
diff --git a/base/metrics/histogram_macros.h b/base/metrics/histogram_macros.h
index 860bd746..b6a9a1e 100644
--- a/base/metrics/histogram_macros.h
+++ b/base/metrics/histogram_macros.h
@@ -224,25 +224,25 @@
// Short timings - up to 10 seconds. For high-resolution (microseconds) timings,
// see UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES.
-#define UMA_HISTOGRAM_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \
- name, sample, base::TimeDelta::FromMilliseconds(1), \
- base::TimeDelta::FromSeconds(10), 50)
+#define UMA_HISTOGRAM_TIMES(name, sample) \
+ UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, base::Milliseconds(1), \
+ base::Seconds(10), 50)
// Medium timings - up to 3 minutes. Note this starts at 10ms (no good reason,
// but not worth changing).
-#define UMA_HISTOGRAM_MEDIUM_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \
- name, sample, base::TimeDelta::FromMilliseconds(10), \
- base::TimeDelta::FromMinutes(3), 50)
+#define UMA_HISTOGRAM_MEDIUM_TIMES(name, sample) \
+ UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, base::Milliseconds(10), \
+ base::Minutes(3), 50)
// Long timings - up to an hour.
-#define UMA_HISTOGRAM_LONG_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \
- name, sample, base::TimeDelta::FromMilliseconds(1), \
- base::TimeDelta::FromHours(1), 50)
+#define UMA_HISTOGRAM_LONG_TIMES(name, sample) \
+ UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, base::Milliseconds(1), \
+ base::Hours(1), 50)
// Long timings with higher granularity - up to an hour with 100 buckets.
-#define UMA_HISTOGRAM_LONG_TIMES_100(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \
- name, sample, base::TimeDelta::FromMilliseconds(1), \
- base::TimeDelta::FromHours(1), 100)
+#define UMA_HISTOGRAM_LONG_TIMES_100(name, sample) \
+ UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, base::Milliseconds(1), \
+ base::Hours(1), 100)
// This can be used when the default ranges are not sufficient. This macro lets
// the metric developer customize the min and max of the sampled range, as well
@@ -250,7 +250,7 @@
// Sample usage:
// UMA_HISTOGRAM_CUSTOM_TIMES("Very.Long.Timing.Histogram", time_delta,
-// base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100);
+// base::Seconds(1), base::Days(1), 100);
#define UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
STATIC_HISTOGRAM_POINTER_BLOCK( \
name, AddTimeMillisecondsGranularity(sample), \
@@ -268,8 +268,8 @@
// Sample usage:
// UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
// "High.Resolution.TimingMicroseconds.Histogram", time_delta,
-// base::TimeDelta::FromMicroseconds(1),
-// base::TimeDelta::FromMilliseconds(10), 100);
+// base::Microseconds(1),
+// base::Milliseconds(10), 100);
#define UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(name, sample, min, max, \
bucket_count) \
STATIC_HISTOGRAM_POINTER_BLOCK( \
@@ -363,12 +363,11 @@
INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY) \
(name, __VA_ARGS__, base::HistogramBase::kUmaStabilityHistogramFlag)
-#define UMA_STABILITY_HISTOGRAM_LONG_TIMES(name, sample) \
- STATIC_HISTOGRAM_POINTER_BLOCK( \
- name, AddTimeMillisecondsGranularity(sample), \
- base::Histogram::FactoryTimeGet( \
- name, base::TimeDelta::FromMilliseconds(1), \
- base::TimeDelta::FromHours(1), 50, \
+#define UMA_STABILITY_HISTOGRAM_LONG_TIMES(name, sample) \
+ STATIC_HISTOGRAM_POINTER_BLOCK( \
+ name, AddTimeMillisecondsGranularity(sample), \
+ base::Histogram::FactoryTimeGet( \
+ name, base::Milliseconds(1), base::Hours(1), 50, \
base::HistogramBase::kUmaStabilityHistogramFlag))
#define UMA_STABILITY_HISTOGRAM_PERCENTAGE(name, percent_as_int) \
diff --git a/base/metrics/histogram_macros_internal.h b/base/metrics/histogram_macros_internal.h
index 46d44b56..977452e3 100644
--- a/base/metrics/histogram_macros_internal.h
+++ b/base/metrics/histogram_macros_internal.h
@@ -242,29 +242,28 @@
INTERNAL_SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, timing, key)
// This is a helper macro used by other macros and shouldn't be used directly.
-#define INTERNAL_SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, timing, key) \
- class ScopedHistogramTimer##key { \
- public: \
- ScopedHistogramTimer##key() : constructed_(base::TimeTicks::Now()) {} \
- ~ScopedHistogramTimer##key() { \
- base::TimeDelta elapsed = base::TimeTicks::Now() - constructed_; \
- switch (timing) { \
- case ScopedHistogramTiming::kMicrosecondTimes: \
- UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES( \
- name, elapsed, base::TimeDelta::FromMicroseconds(1), \
- base::TimeDelta::FromSeconds(1), 50); \
- break; \
- case ScopedHistogramTiming::kMediumTimes: \
- UMA_HISTOGRAM_TIMES(name, elapsed); \
- break; \
- case ScopedHistogramTiming::kLongTimes: \
- UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \
- break; \
- } \
- } \
- \
- private: \
- base::TimeTicks constructed_; \
+#define INTERNAL_SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, timing, key) \
+ class ScopedHistogramTimer##key { \
+ public: \
+ ScopedHistogramTimer##key() : constructed_(base::TimeTicks::Now()) {} \
+ ~ScopedHistogramTimer##key() { \
+ base::TimeDelta elapsed = base::TimeTicks::Now() - constructed_; \
+ switch (timing) { \
+ case ScopedHistogramTiming::kMicrosecondTimes: \
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES( \
+ name, elapsed, base::Microseconds(1), base::Seconds(1), 50); \
+ break; \
+ case ScopedHistogramTiming::kMediumTimes: \
+ UMA_HISTOGRAM_TIMES(name, elapsed); \
+ break; \
+ case ScopedHistogramTiming::kLongTimes: \
+ UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \
+ break; \
+ } \
+ } \
+ \
+ private: \
+ base::TimeTicks constructed_; \
} scoped_histogram_timer_##key
#endif // BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_
diff --git a/base/metrics/histogram_macros_local.h b/base/metrics/histogram_macros_local.h
index 771b01a0..e41b5ef 100644
--- a/base/metrics/histogram_macros_local.h
+++ b/base/metrics/histogram_macros_local.h
@@ -59,9 +59,9 @@
//
// For usage details, see the equivalents in histogram_macros.h.
-#define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \
- name, sample, base::TimeDelta::FromMilliseconds(1), \
- base::TimeDelta::FromSeconds(10), 50)
+#define LOCAL_HISTOGRAM_TIMES(name, sample) \
+ LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, base::Milliseconds(1), \
+ base::Seconds(10), 50)
#define LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
STATIC_HISTOGRAM_POINTER_BLOCK( \
diff --git a/base/process/process_metrics_unittest.cc b/base/process/process_metrics_unittest.cc
index b2c1ddb..2df96500 100644
--- a/base/process/process_metrics_unittest.cc
+++ b/base/process/process_metrics_unittest.cc
@@ -543,23 +543,19 @@
EXPECT_EQ(time_in_state[0].thread_id, 123);
EXPECT_EQ(time_in_state[0].cluster_core_index, 0u);
EXPECT_EQ(time_in_state[0].core_frequency_khz, 100000u);
- EXPECT_EQ(time_in_state[0].cumulative_cpu_time,
- base::TimeDelta::FromMilliseconds(40));
+ EXPECT_EQ(time_in_state[0].cumulative_cpu_time, base::Milliseconds(40));
EXPECT_EQ(time_in_state[1].thread_id, 123);
EXPECT_EQ(time_in_state[1].cluster_core_index, 0u);
EXPECT_EQ(time_in_state[1].core_frequency_khz, 200000u);
- EXPECT_EQ(time_in_state[1].cumulative_cpu_time,
- base::TimeDelta::FromMilliseconds(50));
+ EXPECT_EQ(time_in_state[1].cumulative_cpu_time, base::Milliseconds(50));
EXPECT_EQ(time_in_state[2].thread_id, 123);
EXPECT_EQ(time_in_state[2].cluster_core_index, 4u);
EXPECT_EQ(time_in_state[2].core_frequency_khz, 400000u);
- EXPECT_EQ(time_in_state[2].cumulative_cpu_time,
- base::TimeDelta::FromMilliseconds(30));
+ EXPECT_EQ(time_in_state[2].cumulative_cpu_time, base::Milliseconds(30));
EXPECT_EQ(time_in_state[3].thread_id, 123);
EXPECT_EQ(time_in_state[3].cluster_core_index, 4u);
EXPECT_EQ(time_in_state[3].core_frequency_khz, 500000u);
- EXPECT_EQ(time_in_state[3].cumulative_cpu_time,
- base::TimeDelta::FromMilliseconds(20));
+ EXPECT_EQ(time_in_state[3].cumulative_cpu_time, base::Milliseconds(20));
// Calling ParseProcTimeInState again adds to the vector.
const char kStatThread456[] =
@@ -573,8 +569,7 @@
EXPECT_EQ(time_in_state[4].thread_id, 456);
EXPECT_EQ(time_in_state[4].cluster_core_index, 0u);
EXPECT_EQ(time_in_state[4].core_frequency_khz, 1000000u);
- EXPECT_EQ(time_in_state[4].cumulative_cpu_time,
- base::TimeDelta::FromMilliseconds(100));
+ EXPECT_EQ(time_in_state[4].cumulative_cpu_time, base::Milliseconds(100));
// Calling ParseProcTimeInState with invalid data returns false.
EXPECT_FALSE(
diff --git a/base/sync_socket_unittest.cc b/base/sync_socket_unittest.cc
index c6c9c0a..fe1ed4e 100644
--- a/base/sync_socket_unittest.cc
+++ b/base/sync_socket_unittest.cc
@@ -14,7 +14,7 @@
namespace {
-constexpr TimeDelta kReceiveTimeout = base::TimeDelta::FromMilliseconds(750);
+constexpr TimeDelta kReceiveTimeout = base::Milliseconds(750);
class HangingReceiveThread : public DelegateSimpleThread::Delegate {
public:
diff --git a/base/sync_socket_win.cc b/base/sync_socket_win.cc
index 4561a76..4634640 100644
--- a/base/sync_socket_win.cc
+++ b/base/sync_socket_win.cc
@@ -136,8 +136,7 @@
TimeTicks current_time, finish_time;
if (timeout_in_ms != INFINITE) {
current_time = TimeTicks::Now();
- finish_time =
- current_time + base::TimeDelta::FromMilliseconds(timeout_in_ms);
+ finish_time = current_time + base::Milliseconds(timeout_in_ms);
}
size_t count = 0;
diff --git a/base/system/sys_info.cc b/base/system/sys_info.cc
index 84a2e7a..4a02b3f 100644
--- a/base/system/sys_info.cc
+++ b/base/system/sys_info.cc
@@ -109,7 +109,7 @@
// its return value happens to coincide with the system uptime value in
// microseconds, on Win/Mac/iOS/Linux/ChromeOS and Android.
int64_t uptime_in_microseconds = TimeTicks::Now().ToInternalValue();
- return base::TimeDelta::FromMicroseconds(uptime_in_microseconds);
+ return base::Microseconds(uptime_in_microseconds);
}
// static
diff --git a/base/task/sequence_manager/sequence_manager_impl_unittest.cc b/base/task/sequence_manager/sequence_manager_impl_unittest.cc
index aeebdd1..42e1195 100644
--- a/base/task/sequence_manager/sequence_manager_impl_unittest.cc
+++ b/base/task/sequence_manager/sequence_manager_impl_unittest.cc
@@ -2669,7 +2669,7 @@
queue->task_runner()->PostDelayedTask(
FROM_HERE,
BindOnce(&CancelableTask::FailTask<>, task.weak_factory_.GetWeakPtr()),
- base::TimeDelta::FromSeconds(1));
+ base::Seconds(1));
// Make sure sweeping away the last task in the queue doesn't end up accessing
// invalid iterators.
@@ -2684,9 +2684,8 @@
auto queue = CreateTaskQueue();
bool did_post = false;
auto on_destroy = BindLambdaForTesting([&] {
- queue->task_runner()->PostDelayedTask(FROM_HERE,
- BindLambdaForTesting([] {}),
- base::TimeDelta::FromSeconds(1));
+ queue->task_runner()->PostDelayedTask(
+ FROM_HERE, BindLambdaForTesting([] {}), base::Seconds(1));
did_post = true;
});
@@ -2697,7 +2696,7 @@
BindOnce(&CancelableTask::FailTask<DestructionCallback>,
task.weak_factory_.GetWeakPtr(),
std::move(destruction_observer)),
- base::TimeDelta::FromSeconds(1));
+ base::Seconds(1));
task.weak_factory_.InvalidateWeakPtrs();
EXPECT_FALSE(did_post);
@@ -2745,7 +2744,7 @@
BindOnce(&CancelableTask::FailTask<DestructionCallback>,
task.weak_factory_.GetWeakPtr(),
std::move(destruction_observer)),
- base::TimeDelta::FromSeconds(1));
+ base::Seconds(1));
task.weak_factory_.InvalidateWeakPtrs();
EXPECT_FALSE(did_shutdown);
@@ -4716,9 +4715,9 @@
FROM_HERE, BindOnce(
[](scoped_refptr<TaskRunner> task_runner,
WaitableEvent* task_posted) {
- task_runner->PostDelayedTask(
- FROM_HERE, BindOnce(&NopTask),
- base::TimeDelta::FromMilliseconds(10));
+ task_runner->PostDelayedTask(FROM_HERE,
+ BindOnce(&NopTask),
+ base::Milliseconds(10));
task_posted->Signal();
},
std::move(task_runner), &task_posted));
@@ -4733,19 +4732,19 @@
void PostTaskA(scoped_refptr<TaskRunner> task_runner) {
task_runner->PostTask(FROM_HERE, BindOnce(&NopTask));
task_runner->PostDelayedTask(FROM_HERE, BindOnce(&NopTask),
- base::TimeDelta::FromMilliseconds(10));
+ base::Milliseconds(10));
}
void PostTaskB(scoped_refptr<TaskRunner> task_runner) {
task_runner->PostTask(FROM_HERE, BindOnce(&NopTask));
task_runner->PostDelayedTask(FROM_HERE, BindOnce(&NopTask),
- base::TimeDelta::FromMilliseconds(20));
+ base::Milliseconds(20));
}
void PostTaskC(scoped_refptr<TaskRunner> task_runner) {
task_runner->PostTask(FROM_HERE, BindOnce(&NopTask));
task_runner->PostDelayedTask(FROM_HERE, BindOnce(&NopTask),
- base::TimeDelta::FromMilliseconds(30));
+ base::Milliseconds(30));
}
} // namespace
diff --git a/base/task/thread_pool/thread_pool_impl.cc b/base/task/thread_pool/thread_pool_impl.cc
index 9beebcf..08ed8a3 100644
--- a/base/task/thread_pool/thread_pool_impl.cc
+++ b/base/task/thread_pool/thread_pool_impl.cc
@@ -212,7 +212,7 @@
const base::TimeDelta suggested_reclaim_time =
FeatureList::IsEnabled(kUseFiveMinutesThreadReclaimTime)
- ? base::TimeDelta::FromMinutes(5)
+ ? base::Minutes(5)
: init_params.suggested_reclaim_time;
#if HAS_NATIVE_THREAD_POOL()
diff --git a/base/task/thread_pool/thread_pool_perftest.cc b/base/task/thread_pool/thread_pool_perftest.cc
index d1b65a0d..d571604 100644
--- a/base/task/thread_pool/thread_pool_perftest.cc
+++ b/base/task/thread_pool/thread_pool_perftest.cc
@@ -261,8 +261,7 @@
StartThreadPool(
4, 4,
BindRepeating(&ThreadPoolPerfTest::ContinuouslyPostBusyWaitTasks,
- Unretained(this), 10000,
- base::TimeDelta::FromMicroseconds(200)));
+ Unretained(this), 10000, base::Microseconds(200)));
Benchmark(kStoryPostRunBusyManyThreads, ExecutionMode::kPostAndRun);
}
diff --git a/base/test/ios/wait_util.mm b/base/test/ios/wait_util.mm
index e11d95e..8ada064 100644
--- a/base/test/ios/wait_util.mm
+++ b/base/test/ios/wait_util.mm
@@ -31,8 +31,7 @@
NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:timeout];
bool success = condition();
while (!success && [[NSDate date] compare:deadline] != NSOrderedDescending) {
- base::test::ios::SpinRunLoopWithMaxDelay(
- base::TimeDelta::FromSecondsD(kSpinDelaySeconds));
+ base::test::ios::SpinRunLoopWithMaxDelay(base::Seconds(kSpinDelaySeconds));
success = condition();
}
return success;
diff --git a/base/test/launcher/test_launcher_unittest.cc b/base/test/launcher/test_launcher_unittest.cc
index 83f1e20..a670740db 100644
--- a/base/test/launcher/test_launcher_unittest.cc
+++ b/base/test/launcher/test_launcher_unittest.cc
@@ -912,7 +912,7 @@
MULTIPROCESS_TEST_MAIN(LeakChildProcess) {
while (true)
- PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
+ PlatformThread::Sleep(base::Seconds(1));
}
TEST(LeakedChildProcessTest, DISABLED_LeakChildProcess) {
diff --git a/base/test/metrics/histogram_tester_unittest.cc b/base/test/metrics/histogram_tester_unittest.cc
index 46f7acac..bedc4a4 100644
--- a/base/test/metrics/histogram_tester_unittest.cc
+++ b/base/test/metrics/histogram_tester_unittest.cc
@@ -73,8 +73,7 @@
UMA_HISTOGRAM_COUNTS_100(kHistogram2, 2);
tester.ExpectUniqueSample(kHistogram2, 2, 3);
- tester.ExpectUniqueTimeSample(kHistogram2,
- base::TimeDelta::FromMilliseconds(2), 3);
+ tester.ExpectUniqueTimeSample(kHistogram2, base::Milliseconds(2), 3);
}
// Verify that the expectation is violated if the bucket contains an incorrect
diff --git a/base/test/spin_wait.h b/base/test/spin_wait.h
index 42b3b35..3f6dce3 100644
--- a/base/test/spin_wait.h
+++ b/base/test/spin_wait.h
@@ -30,9 +30,8 @@
// typically used to get the padding needed on a given test platform to assure
// that the test passes, even if load varies, and external events vary.
-#define SPIN_FOR_1_SECOND_OR_UNTIL_TRUE(expression) \
- SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(base::TimeDelta::FromSeconds(1), \
- (expression))
+#define SPIN_FOR_1_SECOND_OR_UNTIL_TRUE(expression) \
+ SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(base::Seconds(1), (expression))
#define SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(delta, expression) \
do { \
@@ -45,7 +44,7 @@
<< "Timed out"; \
break; \
} \
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50)); \
+ base::PlatformThread::Sleep(base::Milliseconds(50)); \
} \
} while (0)
diff --git a/base/test/task_runner_test_template.h b/base/test/task_runner_test_template.h
index fc23f4b..64c14608 100644
--- a/base/test/task_runner_test_template.h
+++ b/base/test/task_runner_test_template.h
@@ -149,8 +149,7 @@
RepeatingClosure ith_task =
this->task_tracker_->WrapTask(RepeatingClosure(), i);
for (int j = 0; j < i + 1; ++j) {
- task_runner->PostDelayedTask(
- FROM_HERE, ith_task, base::TimeDelta::FromMilliseconds(j));
+ task_runner->PostDelayedTask(FROM_HERE, ith_task, base::Milliseconds(j));
++expected_task_run_counts[i];
++expected_total_tasks;
}
diff --git a/base/test/test_future_unittest.cc b/base/test/test_future_unittest.cc
index bcb724e..094982d 100644
--- a/base/test/test_future_unittest.cc
+++ b/base/test/test_future_unittest.cc
@@ -75,7 +75,7 @@
TestFuture<int> future;
PostDelayedTask(base::BindOnce(future.GetCallback(), expected_value),
- base::TimeDelta::FromMilliseconds(1));
+ base::Milliseconds(1));
future.Wait();
@@ -86,15 +86,14 @@
TestFuture<int> future;
PostDelayedTask(base::BindOnce(future.GetCallback(), kAnyValue),
- base::TimeDelta::FromMilliseconds(1));
+ base::Milliseconds(1));
bool success = future.Wait();
EXPECT_TRUE(success);
}
TEST_F(TestFutureTest, WaitShouldReturnFalseIfTimeoutHappens) {
- base::test::ScopedRunLoopTimeout timeout(
- FROM_HERE, base::TimeDelta::FromMilliseconds(1));
+ base::test::ScopedRunLoopTimeout timeout(FROM_HERE, base::Milliseconds(1));
// |ScopedRunLoopTimeout| will automatically fail the test when a timeout
// happens, so we use EXPECT_FATAL_FAILURE to handle this failure.
@@ -112,7 +111,7 @@
TestFuture<int> future;
PostDelayedTask(base::BindOnce(future.GetCallback(), expected_value),
- base::TimeDelta::FromMilliseconds(1));
+ base::Milliseconds(1));
int actual_value = future.Get();
@@ -120,8 +119,7 @@
}
TEST_F(TestFutureTest, GetShouldDcheckIfTimeoutHappens) {
- base::test::ScopedRunLoopTimeout timeout(
- FROM_HERE, base::TimeDelta::FromMilliseconds(1));
+ base::test::ScopedRunLoopTimeout timeout(FROM_HERE, base::Milliseconds(1));
TestFuture<AnyType> future;
@@ -140,8 +138,7 @@
}
TEST_F(TestFutureTest, TakeShouldDcheckIfTimeoutHappens) {
- base::test::ScopedRunLoopTimeout timeout(
- FROM_HERE, base::TimeDelta::FromMilliseconds(1));
+ base::test::ScopedRunLoopTimeout timeout(FROM_HERE, base::Milliseconds(1));
TestFuture<AnyType> future;
diff --git a/base/test/test_pending_task_unittest.cc b/base/test/test_pending_task_unittest.cc
index 9771e23..b0c205b 100644
--- a/base/test/test_pending_task_unittest.cc
+++ b/base/test/test_pending_task_unittest.cc
@@ -47,9 +47,9 @@
TEST(TestPendingTaskTest, ShouldRunBefore) {
base::TestPendingTask task_first;
- task_first.delay = base::TimeDelta::FromMilliseconds(1);
+ task_first.delay = base::Milliseconds(1);
base::TestPendingTask task_after;
- task_after.delay = base::TimeDelta::FromMilliseconds(2);
+ task_after.delay = base::Milliseconds(2);
EXPECT_FALSE(task_after.ShouldRunBefore(task_first))
<< task_after << ".ShouldRunBefore(" << task_first << ")\n";
diff --git a/base/test/test_reg_util_win.cc b/base/test/test_reg_util_win.cc
index 2498ed57..36bf1d6 100644
--- a/base/test/test_reg_util_win.cc
+++ b/base/test/test_reg_util_win.cc
@@ -53,7 +53,7 @@
base::Time key_time = base::Time::FromInternalValue(key_name_as_number);
base::TimeDelta age = now - key_time;
- if (age > base::TimeDelta::FromHours(24))
+ if (age > base::Hours(24))
test_root_key.DeleteKey(key_name.c_str());
}
}
diff --git a/base/test/test_reg_util_win_unittest.cc b/base/test/test_reg_util_win_unittest.cc
index 12c1d6b9..3e05c39e 100644
--- a/base/test/test_reg_util_win_unittest.cc
+++ b/base/test/test_reg_util_win_unittest.cc
@@ -107,13 +107,12 @@
std::wstring path_garbage = fake_test_key_root_ + L"\\Blah";
std::wstring path_very_stale =
- FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromDays(100));
- std::wstring path_stale =
- FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromDays(5));
+ FakeOverrideManagerPath(kTestTime - base::Days(100));
+ std::wstring path_stale = FakeOverrideManagerPath(kTestTime - base::Days(5));
std::wstring path_current =
- FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromMinutes(1));
+ FakeOverrideManagerPath(kTestTime - base::Minutes(1));
std::wstring path_future =
- FakeOverrideManagerPath(kTestTime + base::TimeDelta::FromMinutes(1));
+ FakeOverrideManagerPath(kTestTime + base::Minutes(1));
ASSERT_NO_FATAL_FAILURE(CreateKey(path_garbage));
ASSERT_NO_FATAL_FAILURE(CreateKey(path_very_stale));
diff --git a/base/test/test_timeouts.cc b/base/test/test_timeouts.cc
index 507c00d..90a79644 100644
--- a/base/test/test_timeouts.cc
+++ b/base/test/test_timeouts.cc
@@ -37,8 +37,7 @@
LOG(FATAL) << "Timeout value \"" << string_value << "\" was parsed as "
<< command_line_timeout_ms;
}
- command_line_timeout =
- base::TimeDelta::FromMilliseconds(command_line_timeout_ms);
+ command_line_timeout = base::Milliseconds(command_line_timeout_ms);
}
#if defined(MEMORY_SANITIZER)
@@ -89,14 +88,10 @@
// The timeout values should increase in the order they appear in this block.
// static
-base::TimeDelta TestTimeouts::tiny_timeout_ =
- base::TimeDelta::FromMilliseconds(100);
-base::TimeDelta TestTimeouts::action_timeout_ =
- base::TimeDelta::FromSeconds(10);
-base::TimeDelta TestTimeouts::action_max_timeout_ =
- base::TimeDelta::FromSeconds(30);
-base::TimeDelta TestTimeouts::test_launcher_timeout_ =
- base::TimeDelta::FromSeconds(45);
+base::TimeDelta TestTimeouts::tiny_timeout_ = base::Milliseconds(100);
+base::TimeDelta TestTimeouts::action_timeout_ = base::Seconds(10);
+base::TimeDelta TestTimeouts::action_max_timeout_ = base::Seconds(30);
+base::TimeDelta TestTimeouts::test_launcher_timeout_ = base::Seconds(45);
// static
void TestTimeouts::Initialize() {
@@ -126,7 +121,7 @@
base::TimeDelta min_ui_test_action_timeout = tiny_timeout_;
if (being_debugged || base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kTestLauncherInteractive)) {
- min_ui_test_action_timeout = base::TimeDelta::FromDays(1);
+ min_ui_test_action_timeout = base::Days(1);
}
InitializeTimeout(switches::kUiTestActionTimeout, min_ui_test_action_timeout,
diff --git a/base/test/trace_event_analyzer_unittest.cc b/base/test/trace_event_analyzer_unittest.cc
index 735a07d..ad3ef32b 100644
--- a/base/test/trace_event_analyzer_unittest.cc
+++ b/base/test/trace_event_analyzer_unittest.cc
@@ -413,7 +413,7 @@
TEST_F(TraceEventAnalyzerTest, BeginEndDuration) {
ManualSetUp();
- const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200);
+ const base::TimeDelta kSleepTime = base::Milliseconds(200);
// We will search for events that have a duration of greater than 90% of the
// sleep time, so that there is no flakiness.
int64_t duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10;
@@ -460,7 +460,7 @@
TEST_F(TraceEventAnalyzerTest, CompleteDuration) {
ManualSetUp();
- const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200);
+ const base::TimeDelta kSleepTime = base::Milliseconds(200);
// We will search for events that have a duration of greater than 90% of the
// sleep time, so that there is no flakiness.
int64_t duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10;
diff --git a/base/threading/hang_watcher.cc b/base/threading/hang_watcher.cc
index 690ac4f..ff39c7e 100644
--- a/base/threading/hang_watcher.cc
+++ b/base/threading/hang_watcher.cc
@@ -114,7 +114,7 @@
// static
const base::TimeDelta WatchHangsInScope::kDefaultHangWatchTime =
- base::TimeDelta::FromSeconds(10);
+ base::Seconds(10);
constexpr const char* kThreadName = "HangWatcher";
@@ -126,7 +126,7 @@
// hangs but present unacceptable overhead. NOTE: If this period is ever changed
// then all metrics that depend on it like
// HangWatcher.IsThreadHung need to be updated.
-constexpr auto kMonitoringPeriod = base::TimeDelta::FromSeconds(10);
+constexpr auto kMonitoringPeriod = base::Seconds(10);
WatchHangsInScope::WatchHangsInScope(TimeDelta timeout) {
internal::HangWatchState* current_hang_watch_state =
@@ -397,8 +397,7 @@
while (true) {
// Amount by which the actual time spent sleeping can deviate from
// the target time and still be considered timely.
- constexpr base::TimeDelta kWaitDriftTolerance =
- base::TimeDelta::FromMilliseconds(100);
+ constexpr base::TimeDelta kWaitDriftTolerance = base::Milliseconds(100);
const base::TimeTicks time_before_wait = tick_clock_->NowTicks();
diff --git a/base/threading/hang_watcher.h b/base/threading/hang_watcher.h
index 63676ef..cc92ab7a 100644
--- a/base/threading/hang_watcher.h
+++ b/base/threading/hang_watcher.h
@@ -45,7 +45,7 @@
// Example usage:
//
// void FooBar(){
-// WatchHangsInScope scope(base::TimeDelta::FromSeconds(5));
+// WatchHangsInScope scope(base::Seconds(5));
// DoWork();
// }
//
diff --git a/base/threading/hang_watcher_unittest.cc b/base/threading/hang_watcher_unittest.cc
index 5adc66c..e5c8e631 100644
--- a/base/threading/hang_watcher_unittest.cc
+++ b/base/threading/hang_watcher_unittest.cc
@@ -45,7 +45,7 @@
// Use this value to mark things very far off in the future. Adding this
// to TimeTicks::Now() gives a point that will never be reached during the
// normal execution of a test.
-constexpr TimeDelta kVeryLongDelta{base::TimeDelta::FromDays(365)};
+constexpr TimeDelta kVeryLongDelta{base::Days(365)};
constexpr uint64_t kArbitraryDeadline = 0x0000C0FFEEC0FFEEu;
constexpr uint64_t kAllOnes = 0xFFFFFFFFFFFFFFFFu;
@@ -108,8 +108,8 @@
class HangWatcherTest : public testing::Test {
public:
- const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(10);
- const base::TimeDelta kHangTime = kTimeout + base::TimeDelta::FromSeconds(1);
+ const base::TimeDelta kTimeout = base::Seconds(10);
+ const base::TimeDelta kHangTime = kTimeout + base::Seconds(1);
HangWatcherTest() {
feature_list_.InitWithFeaturesAndParameters(kFeatureAndParams, {});
@@ -380,12 +380,10 @@
ASSERT_FALSE(current_hang_watch_state->IsOverDeadline());
base::TimeTicks original_deadline = current_hang_watch_state->GetDeadline();
- constexpr base::TimeDelta kFirstTimeout(
- base::TimeDelta::FromMilliseconds(500));
+ constexpr base::TimeDelta kFirstTimeout(base::Milliseconds(500));
base::TimeTicks first_deadline = base::TimeTicks::Now() + kFirstTimeout;
- constexpr base::TimeDelta kSecondTimeout(
- base::TimeDelta::FromMilliseconds(250));
+ constexpr base::TimeDelta kSecondTimeout(base::Milliseconds(250));
base::TimeTicks second_deadline = base::TimeTicks::Now() + kSecondTimeout;
// At this point we have not set any timeouts.
@@ -687,7 +685,7 @@
// Monitor(). Choose a low value so that that successive invocations happens
// fast. This makes tests that wait for monitoring run fast and makes tests that
// expect no monitoring fail fast.
-const base::TimeDelta kMonitoringPeriod = base::TimeDelta::FromMilliseconds(1);
+const base::TimeDelta kMonitoringPeriod = base::Milliseconds(1);
// Test if and how often the HangWatcher periodically monitors for hangs.
class HangWatcherPeriodicMonitoringTest : public testing::Test {
@@ -820,7 +818,7 @@
// Make the HangWatcher tick clock advance so much after waiting that it will
// detect oversleeping every time. This will keep it from monitoring.
- InstallAfterWaitCallback(base::TimeDelta::FromMinutes(1));
+ InstallAfterWaitCallback(base::Minutes(1));
hang_watcher_.Start();
@@ -850,7 +848,7 @@
hang_watcher_.SetOnHangClosureForTesting(base::BindLambdaForTesting([&] {
capture_started_.Signal();
// Simulate capturing that takes a long time.
- PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500));
+ PlatformThread::Sleep(base::Milliseconds(500));
continue_capture_.Wait();
completed_capture_ = true;
@@ -859,7 +857,7 @@
hang_watcher_.SetAfterMonitorClosureForTesting(
base::BindLambdaForTesting([&] {
// Simulate monitoring that takes a long time.
- PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500));
+ PlatformThread::Sleep(base::Milliseconds(500));
completed_monitoring_.Signal();
}));
diff --git a/base/threading/platform_thread_mac.mm b/base/threading/platform_thread_mac.mm
index 2f4c310..2da181b 100644
--- a/base/threading/platform_thread_mac.mm
+++ b/base/threading/platform_thread_mac.mm
@@ -267,12 +267,12 @@
UmaHistogramCustomMicrosecondsTimes(
"PlatformThread.Mac.AttemptedRealtimePeriod", realtime_period,
- base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), 100);
+ base::TimeDelta(), base::Milliseconds(100), 100);
if (result == KERN_SUCCESS) {
UmaHistogramCustomMicrosecondsTimes(
"PlatformThread.Mac.SucceededRealtimePeriod", realtime_period,
- base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), 100);
+ base::TimeDelta(), base::Milliseconds(100), 100);
}
return;
}
diff --git a/base/threading/platform_thread_win_unittest.cc b/base/threading/platform_thread_win_unittest.cc
index fa5f162..9e43610 100644
--- a/base/threading/platform_thread_win_unittest.cc
+++ b/base/threading/platform_thread_win_unittest.cc
@@ -70,7 +70,7 @@
}
internal::AssertMemoryPriority(thread_handle, MEMORY_PRIORITY_VERY_LOW);
- PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
+ PlatformThread::Sleep(base::Seconds(1));
// After 1 second, GetThreadPriority() and memory priority don't change (this
// refutes the hypothesis that it simply takes time before GetThreadPriority()
diff --git a/base/threading/thread_collision_warner_unittest.cc b/base/threading/thread_collision_warner_unittest.cc
index 8391666..e3c61637 100644
--- a/base/threading/thread_collision_warner_unittest.cc
+++ b/base/threading/thread_collision_warner_unittest.cc
@@ -190,7 +190,7 @@
void push(int value) {
DFAKE_SCOPED_LOCK(push_pop_);
- base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(5));
+ base::PlatformThread::Sleep(base::Seconds(5));
}
int pop() {
@@ -248,7 +248,7 @@
void push(int value) {
DFAKE_SCOPED_LOCK(push_pop_);
- base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(2));
+ base::PlatformThread::Sleep(base::Seconds(2));
}
int pop() {
@@ -318,7 +318,7 @@
void push(int) {
DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_);
bar();
- base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(2));
+ base::PlatformThread::Sleep(base::Seconds(2));
}
int pop() {
diff --git a/base/threading/thread_unittest.cc b/base/threading/thread_unittest.cc
index 55b79eb..a9ac358 100644
--- a/base/threading/thread_unittest.cc
+++ b/base/threading/thread_unittest.cc
@@ -59,7 +59,7 @@
~SleepInsideInitThread() override { Stop(); }
void Init() override {
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500));
+ base::PlatformThread::Sleep(base::Milliseconds(500));
init_called_ = true;
}
bool InitCalled() { return init_called_; }
@@ -211,7 +211,7 @@
// Unblock the task and give a bit of extra time to unwind QuitWhenIdle().
block_event.Signal();
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
+ base::PlatformThread::Sleep(base::Milliseconds(20));
// The thread should now have stopped on its own.
EXPECT_FALSE(a->IsRunning());
@@ -231,7 +231,7 @@
a.task_runner()->PostTask(
FROM_HERE, base::BindOnce(static_cast<void (*)(base::TimeDelta)>(
&base::PlatformThread::Sleep),
- base::TimeDelta::FromMilliseconds(20)));
+ base::Milliseconds(20)));
a.task_runner()->PostTask(FROM_HERE,
base::BindOnce(&ToggleValue, &was_invoked));
}
@@ -257,7 +257,7 @@
// Attempt to catch use-after-frees from the non-joinable thread in the
// scope of this test if any.
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
+ base::PlatformThread::Sleep(base::Milliseconds(20));
}
TEST_F(ThreadTest, StopSoon) {
@@ -385,7 +385,7 @@
a->StopSoon();
base::PlatformThread::YieldCurrentThread();
last_task_event.Wait();
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
+ base::PlatformThread::Sleep(base::Milliseconds(20));
// This test assumes that the above was sufficient to let the thread fully
// stop.
@@ -511,8 +511,7 @@
// Flushing a thread with no tasks shouldn't block.
a.FlushForTesting();
- constexpr base::TimeDelta kSleepPerTestTask =
- base::TimeDelta::FromMilliseconds(50);
+ constexpr base::TimeDelta kSleepPerTestTask = base::Milliseconds(50);
constexpr size_t kNumSleepTasks = 5;
const base::TimeTicks ticks_before_post = base::TimeTicks::Now();
diff --git a/base/time/time.h b/base/time/time.h
index 26be838..c939bb1b 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -638,7 +638,7 @@
//
// // Deserialization:
// base::Time last_updated = base::Time::FromDeltaSinceWindowsEpoch(
- // base::TimeDelta::FromMicroseconds(LoadFromDatabase()));
+ // base::Microseconds(LoadFromDatabase()));
//
// Do not use `FromInternalValue()` or `ToInternalValue()` for this purpose.
static Time FromDeltaSinceWindowsEpoch(TimeDelta delta);
diff --git a/base/time/time_mac.mm b/base/time/time_mac.mm
index 20c6d29..4b5e092 100644
--- a/base/time/time_mac.mm
+++ b/base/time/time_mac.mm
@@ -100,10 +100,9 @@
size_t size = sizeof(boottime);
int kr = sysctl(mib, base::size(mib), &boottime, &size, nullptr, 0);
DCHECK_EQ(KERN_SUCCESS, kr);
- base::TimeDelta time_difference =
- base::subtle::TimeNowIgnoringOverride() -
- (base::Time::FromTimeT(boottime.tv_sec) +
- base::TimeDelta::FromMicroseconds(boottime.tv_usec));
+ base::TimeDelta time_difference = base::subtle::TimeNowIgnoringOverride() -
+ (base::Time::FromTimeT(boottime.tv_sec) +
+ base::Microseconds(boottime.tv_usec));
return time_difference.InMicroseconds();
#else
// mach_absolute_time is it when it comes to ticks on the Mac. Other calls
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index 8380ab2..20e3b76 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -1235,7 +1235,7 @@
TEST(TimeTicks, Deltas) {
for (int index = 0; index < 50; index++) {
TimeTicks ticks_start = TimeTicks::Now();
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
+ base::PlatformThread::Sleep(base::Milliseconds(10));
TimeTicks ticks_stop = TimeTicks::Now();
TimeDelta delta = ticks_stop - ticks_start;
// Note: Although we asked for a 10ms sleep, if the
@@ -1411,7 +1411,7 @@
// Make sure that ThreadNow value is non-zero.
EXPECT_GT(begin_thread, ThreadTicks());
// Sleep for 10 milliseconds to get the thread de-scheduled.
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
+ base::PlatformThread::Sleep(base::Milliseconds(10));
ThreadTicks end_thread = ThreadTicks::Now();
TimeTicks end = TimeTicks::Now();
TimeDelta delta = end - begin;
@@ -1426,7 +1426,7 @@
TEST(TimeTicks, SnappedToNextTickBasic) {
base::TimeTicks phase = base::TimeTicks::FromInternalValue(4000);
- base::TimeDelta interval = base::TimeDelta::FromMicroseconds(1000);
+ base::TimeDelta interval = base::Microseconds(1000);
base::TimeTicks timestamp;
// Timestamp in previous interval.
@@ -1469,7 +1469,7 @@
// int(big_timestamp / interval) < 0, so this causes a crash if the number of
// intervals elapsed is attempted to be stored in an int.
base::TimeTicks phase = base::TimeTicks::FromInternalValue(0);
- base::TimeDelta interval = base::TimeDelta::FromMicroseconds(4000);
+ base::TimeDelta interval = base::Microseconds(4000);
base::TimeTicks big_timestamp =
base::TimeTicks::FromInternalValue(8635916564000);
diff --git a/base/timer/lap_timer_unittest.cc b/base/timer/lap_timer_unittest.cc
index a2552d9..422eb66 100644
--- a/base/timer/lap_timer_unittest.cc
+++ b/base/timer/lap_timer_unittest.cc
@@ -19,8 +19,8 @@
namespace {
-constexpr base::TimeDelta kTimeLimit = base::TimeDelta::FromMilliseconds(15);
-constexpr base::TimeDelta kTimeAdvance = base::TimeDelta::FromMilliseconds(1);
+constexpr base::TimeDelta kTimeLimit = base::Milliseconds(15);
+constexpr base::TimeDelta kTimeAdvance = base::Milliseconds(1);
constexpr int kWarmupRuns = 5;
constexpr int kTimeCheckInterval = 10;
diff --git a/base/timer/mock_timer_unittest.cc b/base/timer/mock_timer_unittest.cc
index aa74f333..c864987 100644
--- a/base/timer/mock_timer_unittest.cc
+++ b/base/timer/mock_timer_unittest.cc
@@ -17,7 +17,7 @@
TEST(MockTimerTest, FiresOnce) {
int calls = 0;
base::MockOneShotTimer timer;
- base::TimeDelta delay = base::TimeDelta::FromSeconds(2);
+ base::TimeDelta delay = base::Seconds(2);
timer.Start(FROM_HERE, delay,
base::BindOnce(&CallMeMaybe, base::Unretained(&calls)));
EXPECT_EQ(delay, timer.GetCurrentDelay());
@@ -30,7 +30,7 @@
TEST(MockTimerTest, FiresRepeatedly) {
int calls = 0;
base::MockRepeatingTimer timer;
- base::TimeDelta delay = base::TimeDelta::FromSeconds(2);
+ base::TimeDelta delay = base::Seconds(2);
timer.Start(FROM_HERE, delay,
base::BindRepeating(&CallMeMaybe, base::Unretained(&calls)));
timer.Fire();
@@ -44,7 +44,7 @@
TEST(MockTimerTest, Stops) {
int calls = 0;
base::MockRepeatingTimer timer;
- base::TimeDelta delay = base::TimeDelta::FromSeconds(2);
+ base::TimeDelta delay = base::Seconds(2);
timer.Start(FROM_HERE, delay,
base::BindRepeating(&CallMeMaybe, base::Unretained(&calls)));
EXPECT_TRUE(timer.IsRunning());
@@ -66,7 +66,7 @@
HasWeakPtr *has_weak_ptr = new HasWeakPtr();
base::WeakPtr<HasWeakPtr> weak_ptr(has_weak_ptr->AsWeakPtr());
base::MockOneShotTimer timer;
- base::TimeDelta delay = base::TimeDelta::FromSeconds(2);
+ base::TimeDelta delay = base::Seconds(2);
ASSERT_TRUE(weak_ptr.get());
timer.Start(FROM_HERE, delay,
base::BindOnce([](HasWeakPtr*) {}, base::Owned(has_weak_ptr)));
diff --git a/base/timer/wall_clock_timer_unittest.cc b/base/timer/wall_clock_timer_unittest.cc
index f399d010..c69d27e 100644
--- a/base/timer/wall_clock_timer_unittest.cc
+++ b/base/timer/wall_clock_timer_unittest.cc
@@ -48,7 +48,7 @@
// Set up a WallClockTimer that will fire in one minute.
WallClockTimer wall_clock_timer(&clock_,
task_environment_.GetMockTickClock());
- constexpr auto delay = base::TimeDelta::FromMinutes(1);
+ constexpr auto delay = base::Minutes(1);
const auto start_time = base::Time::Now();
const auto run_time = start_time + delay;
clock_.SetNow(start_time);
@@ -56,7 +56,7 @@
EXPECT_EQ(wall_clock_timer.desired_run_time(), start_time + delay);
// Pretend that time jumps forward 30 seconds while the machine is suspended.
- constexpr auto past_time = base::TimeDelta::FromSeconds(30);
+ constexpr auto past_time = base::Seconds(30);
FastForwardBy(past_time, /*with_power=*/false);
// Ensure that the timer has not yet fired.
::testing::Mock::VerifyAndClearExpectations(&callback);
@@ -81,7 +81,7 @@
// Once it's done, it will invoke |second_callback| after the other minute.
WallClockTimer wall_clock_timer(&clock_,
task_environment_.GetMockTickClock());
- constexpr auto delay = base::TimeDelta::FromMinutes(1);
+ constexpr auto delay = base::Minutes(1);
wall_clock_timer.Start(FROM_HERE, clock_.Now() + delay, first_callback.Get());
EXPECT_CALL(first_callback, Run())
.WillOnce(::testing::InvokeWithoutArgs(
@@ -96,7 +96,7 @@
// When the |wall_clock_time| is used for the second time, it can still handle
// power suspension properly.
- constexpr auto past_time = base::TimeDelta::FromSeconds(30);
+ constexpr auto past_time = base::Seconds(30);
FastForwardBy(past_time, /*with_power=*/false);
::testing::Mock::VerifyAndClearExpectations(&second_callback);
@@ -112,11 +112,11 @@
// Set up a WallClockTimer.
WallClockTimer wall_clock_timer(&clock_,
task_environment_.GetMockTickClock());
- constexpr auto delay = base::TimeDelta::FromMinutes(1);
+ constexpr auto delay = base::Minutes(1);
wall_clock_timer.Start(FROM_HERE, clock_.Now() + delay, callback.Get());
// After 20 seconds, timer is stopped.
- constexpr auto past_time = base::TimeDelta::FromSeconds(20);
+ constexpr auto past_time = base::Seconds(20);
FastForwardBy(past_time);
EXPECT_TRUE(wall_clock_timer.IsRunning());
wall_clock_timer.Stop();
@@ -134,7 +134,7 @@
TEST_F(WallClockTimerTest, RestartRunningTimer) {
::testing::StrictMock<base::MockOnceClosure> first_callback;
::testing::StrictMock<base::MockOnceClosure> second_callback;
- constexpr auto delay = base::TimeDelta::FromMinutes(1);
+ constexpr auto delay = base::Minutes(1);
// Set up a WallClockTimer that will invoke |first_callback| in one minute.
clock_.SetNow(base::Time::Now());
@@ -168,7 +168,7 @@
// Set up a WallClockTimer.
WallClockTimer wall_clock_timer(&clock_,
task_environment_.GetMockTickClock());
- constexpr auto delay = base::TimeDelta::FromMinutes(1);
+ constexpr auto delay = base::Minutes(1);
wall_clock_timer.Start(FROM_HERE, clock_.Now() + delay, callback.Get());
// After 15 seconds, timer is stopped.
@@ -197,7 +197,7 @@
// Set up a WallClockTimer that will fire in one minute.
WallClockTimer wall_clock_timer(&clock_,
task_environment_.GetMockTickClock());
- constexpr auto delay = base::TimeDelta::FromMinutes(1);
+ constexpr auto delay = base::Minutes(1);
const auto start_time = base::Time::Now();
const auto run_time = start_time + delay;
clock_.SetNow(start_time);
@@ -205,7 +205,7 @@
EXPECT_EQ(wall_clock_timer.desired_run_time(), start_time + delay);
// Pretend that time jumps forward 30 seconds while the machine is suspended.
- constexpr auto past_time = base::TimeDelta::FromSeconds(30);
+ constexpr auto past_time = base::Seconds(30);
// Fastword with both clocks even the power is suspended.
fake_power_monitor_source_.Suspend();
@@ -231,7 +231,7 @@
// Set up a WallClockTimer that will fire in one minute.
WallClockTimer wall_clock_timer(&clock_,
task_environment_.GetMockTickClock());
- constexpr auto delay = base::TimeDelta::FromMinutes(1);
+ constexpr auto delay = base::Minutes(1);
const auto start_time = base::Time::Now();
const auto run_time = start_time + delay;
clock_.SetNow(start_time);
@@ -239,7 +239,7 @@
EXPECT_EQ(wall_clock_timer.desired_run_time(), start_time + delay);
// Pretend that time jumps forward 60 seconds while the machine is suspended.
- constexpr auto past_time = base::TimeDelta::FromSeconds(60);
+ constexpr auto past_time = base::Seconds(60);
// Fastword with both clocks even the power is suspended. Timer fires at the
// moment of power resume.
diff --git a/base/trace_event/cpufreq_monitor_android.cc b/base/trace_event/cpufreq_monitor_android.cc
index da7c704..8fff79f 100644
--- a/base/trace_event/cpufreq_monitor_android.cc
+++ b/base/trace_event/cpufreq_monitor_android.cc
@@ -211,7 +211,7 @@
FROM_HERE,
base::BindOnce(&CPUFreqMonitor::Sample, weak_ptr_factory_.GetWeakPtr(),
std::move(fds)),
- base::TimeDelta::FromMilliseconds(kDefaultCPUFreqSampleIntervalMs));
+ base::Milliseconds(kDefaultCPUFreqSampleIntervalMs));
}
bool CPUFreqMonitor::IsEnabledForTesting() {
diff --git a/base/trace_event/traced_value_support_unittest.cc b/base/trace_event/traced_value_support_unittest.cc
index 3eb19de..794149c 100644
--- a/base/trace_event/traced_value_support_unittest.cc
+++ b/base/trace_event/traced_value_support_unittest.cc
@@ -72,15 +72,13 @@
}
TEST(TracedValueSupportTest, Time) {
+ EXPECT_EQ(perfetto::TracedValueToString(base::Microseconds(42)), "42");
EXPECT_EQ(
- perfetto::TracedValueToString(base::TimeDelta::FromMicroseconds(42)),
+ perfetto::TracedValueToString(base::Time() + base::Microseconds(42)),
"42");
- EXPECT_EQ(perfetto::TracedValueToString(
- base::Time() + base::TimeDelta::FromMicroseconds(42)),
- "42");
- EXPECT_EQ(perfetto::TracedValueToString(
- base::TimeTicks() + base::TimeDelta::FromMicroseconds(42)),
- "42");
+ EXPECT_EQ(
+ perfetto::TracedValueToString(base::TimeTicks() + base::Microseconds(42)),
+ "42");
}
TEST(TracedValueSupportTest, UnguessableToken) {
diff --git a/base/tracing/perfetto_task_runner.cc b/base/tracing/perfetto_task_runner.cc
index 36e167b..f2f17b6a 100644
--- a/base/tracing/perfetto_task_runner.cc
+++ b/base/tracing/perfetto_task_runner.cc
@@ -59,7 +59,7 @@
task();
},
task),
- base::TimeDelta::FromMilliseconds(delay_ms));
+ base::Milliseconds(delay_ms));
}
bool PerfettoTaskRunner::RunsTasksOnCurrentThread() const {