Skip to content

Truly independent web browser

AK+Everywhere: Make MonotonicTime default-constructible

Zaggy10242c6b988a5536
diff --git a/AK/Time.h b/AK/Time.h
index 91a60783b9e..fcf33ecbcc3 100644
--- a/AK/Time.h
+++ b/AK/Time.h
@@ -552,9 +552,10 @@ private:
// Monotonic time represents time returned from the CLOCK_MONOTONIC clock, which has an arbitrary fixed reference point.
class MonotonicTime : private Detail::UnawareTime {
public:
- // Monotonic time does not have a defined reference point.
- // A MonotonicTime at the reference point is therefore meaningless.
- MonotonicTime() = delete;
+ constexpr MonotonicTime()
+ : Detail::UnawareTime(Duration::zero())
+ {
+ }
constexpr MonotonicTime(MonotonicTime const&) = default;
constexpr MonotonicTime(MonotonicTime&&) = default;
constexpr MonotonicTime& operator=(MonotonicTime const&) = default;
diff --git a/Libraries/LibCore/ElapsedTimer.h b/Libraries/LibCore/ElapsedTimer.h
index a68e0432aa4..db49fd69b86 100644
--- a/Libraries/LibCore/ElapsedTimer.h
+++ b/Libraries/LibCore/ElapsedTimer.h
@@ -35,7 +35,7 @@ public:
MonotonicTime const& origin_time() const { return m_origin_time; }
private:
- MonotonicTime m_origin_time { MonotonicTime::now() };
+ MonotonicTime m_origin_time;
TimerType m_timer_type { TimerType::Coarse };
bool m_valid { false };
};
diff --git a/Libraries/LibMedia/IncrementallyPopulatedStream.h b/Libraries/LibMedia/IncrementallyPopulatedStream.h
index b13444f789a..8f37c2a6e22 100644
--- a/Libraries/LibMedia/IncrementallyPopulatedStream.h
+++ b/Libraries/LibMedia/IncrementallyPopulatedStream.h
@@ -86,7 +86,7 @@ public:
Atomic<bool> m_aborted { false };
bool m_blocked { false };
ReadBlockedChangeHandler m_read_blocked_change_handler;
- MonotonicTime m_active_timeout { MonotonicTime::now_coarse() };
+ MonotonicTime m_active_timeout;
// The chunk and stream state that this cursor last chose a request position for. Reads within that chunk are
// skipped until the state changes, since the choice would be the same.
diff --git a/Libraries/LibWebView/FileDownloader.cpp b/Libraries/LibWebView/FileDownloader.cpp
index 7004350663c..1c7209a0e8f 100644
--- a/Libraries/LibWebView/FileDownloader.cpp
+++ b/Libraries/LibWebView/FileDownloader.cpp
@@ -49,7 +49,7 @@ struct FileDownloader::Segment {
bool response_validated { false };
u8 retry_count { 0 };
- MonotonicTime last_activity { MonotonicTime::now() };
+ MonotonicTime last_activity;
u8 stall_restart_count { 0 };
bool is_complete() const { return next_offset > end_offset; }