chromium/net/third_party/quiche/src/quiche/quic/core/quic_time.h

// 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.

#ifndef QUICHE_QUIC_CORE_QUIC_TIME_H_
#define QUICHE_QUIC_CORE_QUIC_TIME_H_

#include <cmath>
#include <cstdint>
#include <limits>
#include <ostream>
#include <string>

#include "absl/time/time.h"
#include "quiche/quic/platform/api/quic_export.h"

namespace quic {

class QuicClock;
class QuicTime;

// A 64-bit signed integer type that stores a time duration as
// a number of microseconds. QUIC does not use absl::Duration, since the Abseil
// type is 128-bit, which would adversely affect certain performance-sensitive
// QUIC data structures.
class QUICHE_EXPORT QuicTimeDelta {};

// A microsecond precision timestamp returned by a QuicClock. It is
// usually either a Unix timestamp or a timestamp returned by the
// platform-specific monotonic clock. QuicClock has a method to convert QuicTime
// to the wall time.
class QUICHE_EXPORT QuicTime {};

// A UNIX timestamp.
//
// TODO(vasilvv): evaluate whether this can be replaced with absl::Time.
class QUICHE_EXPORT QuicWallTime {};

// Non-member relational operators for QuicTimeDelta.
inline bool operator==(QuicTimeDelta lhs, QuicTimeDelta rhs) {}
inline bool operator!=(QuicTimeDelta lhs, QuicTimeDelta rhs) {}
inline bool operator<(QuicTimeDelta lhs, QuicTimeDelta rhs) {}
inline bool operator>(QuicTimeDelta lhs, QuicTimeDelta rhs) {}
inline bool operator<=(QuicTimeDelta lhs, QuicTimeDelta rhs) {}
inline bool operator>=(QuicTimeDelta lhs, QuicTimeDelta rhs) {}
inline QuicTimeDelta operator<<(QuicTimeDelta lhs, size_t rhs) {}
inline QuicTimeDelta operator>>(QuicTimeDelta lhs, size_t rhs) {}

// Non-member relational operators for QuicTime.
inline bool operator==(QuicTime lhs, QuicTime rhs) {}
inline bool operator!=(QuicTime lhs, QuicTime rhs) {}
inline bool operator<(QuicTime lhs, QuicTime rhs) {}
inline bool operator>(QuicTime lhs, QuicTime rhs) {}
inline bool operator<=(QuicTime lhs, QuicTime rhs) {}
inline bool operator>=(QuicTime lhs, QuicTime rhs) {}

// Override stream output operator for gtest or QUICHE_CHECK macros.
inline std::ostream& operator<<(std::ostream& output, const QuicTime t) {}

// Non-member arithmetic operators for QuicTimeDelta.
inline constexpr QuicTimeDelta operator+(QuicTimeDelta lhs, QuicTimeDelta rhs) {}
inline constexpr QuicTimeDelta operator-(QuicTimeDelta lhs, QuicTimeDelta rhs) {}
inline constexpr QuicTimeDelta operator*(QuicTimeDelta lhs, int rhs) {}
inline QuicTimeDelta operator*(QuicTimeDelta lhs, double rhs) {}
inline QuicTimeDelta operator*(int lhs, QuicTimeDelta rhs) {}
inline QuicTimeDelta operator*(double lhs, QuicTimeDelta rhs) {}

// Non-member arithmetic operators for QuicTime and QuicTimeDelta.
inline QuicTime operator+(QuicTime lhs, QuicTimeDelta rhs) {}
inline QuicTime operator-(QuicTime lhs, QuicTimeDelta rhs) {}
inline QuicTimeDelta operator-(QuicTime lhs, QuicTime rhs) {}

// Override stream output operator for gtest.
inline std::ostream& operator<<(std::ostream& output,
                                const QuicTimeDelta delta) {}
}  // namespace quic

#endif  // QUICHE_QUIC_CORE_QUIC_TIME_H_