Line data Source code
1 : #pragma once 2 : 3 : #include <chrono> 4 : 5 : #include "envoy/event/dispatcher.h" 6 : 7 : #include "quiche/quic/core/quic_clock.h" 8 : 9 : namespace Envoy { 10 : namespace Quic { 11 : 12 : class EnvoyQuicClock : public quic::QuicClock { 13 : public: 14 1 : EnvoyQuicClock(Event::Dispatcher& dispatcher) : dispatcher_(dispatcher) {} 15 : 16 : // quic::QuicClock 17 : quic::QuicTime ApproximateNow() const override; 18 : quic::QuicTime Now() const override; 19 : quic::QuicWallTime WallNow() const override; 20 : 21 : private: 22 17348 : template <typename T> int64_t microsecondsSinceEpoch(std::chrono::time_point<T> time) const { 23 17348 : return std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count(); 24 17348 : } 25 : 26 : Event::Dispatcher& dispatcher_; 27 : }; 28 : 29 : } // namespace Quic 30 : } // namespace Envoy