/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef SystemTimeConverter_h #define SystemTimeConverter_h #include #include "mozilla/TimeStamp.h" #include "mozilla/TypeTraits.h" // GetCurrentTime is defined in winbase.h as zero argument macro forwarding to // GetTickCount(). #ifdef GetCurrentTime # undef GetCurrentTime #endif namespace mozilla { // Utility class that converts time values represented as an unsigned integral // number of milliseconds from one time source (e.g. a native event time) to // corresponding mozilla::TimeStamp objects. // // This class handles wrapping of integer values and skew between the time // source and mozilla::TimeStamp values. // // It does this by using an historical reference time recorded in both time // scales (i.e. both as a numerical time value and as a TimeStamp). // // For performance reasons, this class is careful to minimize calls to the // native "current time" function (e.g. gdk_x11_server_get_time) since this can // be slow. template class SystemTimeConverter { public: SystemTimeConverter() : mReferenceTime(Time(0)), mReferenceTimeStamp() // Initializes to the null timestamp , mLastBackwardsSkewCheck(Time(0)), kTimeRange(std::numeric_limits