blob: 0eaf7ac795ed0b96890e90e4a5d8b02a98fba928 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "quiche/quic/core/quic_time.h"
#include "quiche/quic/platform/api/quic_export.h"
QuicClock is used by QUIC core to get current time. Its instance is created by
applications and passed into QuicDispatcher and QuicConnectionHelperInterface.
namespace quic {
// Interface for retrieving the current time.
class QUICHE_EXPORT QuicClock {
QuicClock() = default;
virtual ~QuicClock() = default;
QuicClock(const QuicClock&) = delete;
QuicClock& operator=(const QuicClock&) = delete;
// Returns the approximate current time as a QuicTime object.
virtual QuicTime ApproximateNow() const = 0;
// Returns the current time as a QuicTime object.
// Note: this use significant resources please use only if needed.
virtual QuicTime Now() const = 0;
// WallNow returns the current wall-time - a time that is consistent across
// different clocks.
virtual QuicWallTime WallNow() const = 0;
// Creates a new QuicTime using |time_us| as the internal value.
QuicTime CreateTimeFromMicroseconds(uint64_t time_us) const {
return QuicTime(time_us);
} // namespace quic