gfe-relnote: (n/a) In QuicTimeAccumulator, change a "static constexpr data member" to a "static constexpr function". No behavior change, not protected. This caused a merge error in Chromium because QuicTimeAccumulator::kNotRunningSentinel does not have a definition. The requirement for a definition has been removed since c++17. I could not think of a clean way to prevent this in presubmit, simply ban "static constexpr QuicTime" seems too restrictive, because some code may want to use it with a definition in .cc. PiperOrigin-RevId: 282603664 Change-Id: Ia677ca93b851725e4509c4960c5e71fdeac5f903
diff --git a/quic/core/quic_time_accumulator.h b/quic/core/quic_time_accumulator.h index 772e5ff..6535d74 100644 --- a/quic/core/quic_time_accumulator.h +++ b/quic/core/quic_time_accumulator.h
@@ -13,11 +13,14 @@ // QuicTimeAccumulator accumulates elapsed times between Start(s) and Stop(s). class QUIC_EXPORT_PRIVATE QuicTimeAccumulator { - static constexpr QuicTime kNotRunningSentinel = QuicTime::Infinite(); + // TODO(wub): Switch to a data member called kNotRunningSentinel after c++17. + static constexpr QuicTime NotRunningSentinel() { + return QuicTime::Infinite(); + } public: // True if Started and not Stopped. - bool IsRunning() const { return last_start_time_ != kNotRunningSentinel; } + bool IsRunning() const { return last_start_time_ != NotRunningSentinel(); } void Start(QuicTime now) { DCHECK(!IsRunning()); @@ -30,7 +33,7 @@ if (now > last_start_time_) { total_elapsed_ = total_elapsed_ + (now - last_start_time_); } - last_start_time_ = kNotRunningSentinel; + last_start_time_ = NotRunningSentinel(); DCHECK(!IsRunning()); } @@ -58,7 +61,7 @@ // | | | | // |___________| + |___________| = |total_elapsed_| QuicTime::Delta total_elapsed_ = QuicTime::Delta::Zero(); - QuicTime last_start_time_ = kNotRunningSentinel; + QuicTime last_start_time_ = NotRunningSentinel(); }; } // namespace quic