tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SampleTime.cpp (2061B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "SampleTime.h"
      8 
      9 namespace mozilla {
     10 namespace layers {
     11 
     12 SampleTime::SampleTime() : mType(eNull) {}
     13 
     14 /*static*/
     15 SampleTime SampleTime::FromVsync(const TimeStamp& aTime) {
     16  MOZ_ASSERT(!aTime.IsNull());
     17  return SampleTime(eVsync, aTime);
     18 }
     19 
     20 /*static*/
     21 SampleTime SampleTime::FromNow() { return SampleTime(eNow, TimeStamp::Now()); }
     22 
     23 /*static*/
     24 SampleTime SampleTime::FromTest(const TimeStamp& aTime) {
     25  MOZ_ASSERT(!aTime.IsNull());
     26  return SampleTime(eTest, aTime);
     27 }
     28 
     29 bool SampleTime::IsNull() const { return mType == eNull; }
     30 
     31 SampleTime::TimeType SampleTime::Type() const { return mType; }
     32 
     33 const TimeStamp& SampleTime::Time() const { return mTime; }
     34 
     35 bool SampleTime::operator==(const SampleTime& aOther) const {
     36  return mTime == aOther.mTime;
     37 }
     38 
     39 bool SampleTime::operator!=(const SampleTime& aOther) const {
     40  return !(*this == aOther);
     41 }
     42 
     43 bool SampleTime::operator<(const SampleTime& aOther) const {
     44  return mTime < aOther.mTime;
     45 }
     46 
     47 bool SampleTime::operator<=(const SampleTime& aOther) const {
     48  return mTime <= aOther.mTime;
     49 }
     50 
     51 bool SampleTime::operator>(const SampleTime& aOther) const {
     52  return mTime > aOther.mTime;
     53 }
     54 
     55 bool SampleTime::operator>=(const SampleTime& aOther) const {
     56  return mTime >= aOther.mTime;
     57 }
     58 
     59 SampleTime SampleTime::operator+(const TimeDuration& aDuration) const {
     60  return SampleTime(mType, mTime + aDuration);
     61 }
     62 
     63 SampleTime SampleTime::operator-(const TimeDuration& aDuration) const {
     64  return SampleTime(mType, mTime - aDuration);
     65 }
     66 
     67 TimeDuration SampleTime::operator-(const SampleTime& aOther) const {
     68  return mTime - aOther.mTime;
     69 }
     70 
     71 SampleTime::SampleTime(TimeType aType, const TimeStamp& aTime)
     72    : mType(aType), mTime(aTime) {}
     73 
     74 }  // namespace layers
     75 }  // namespace mozilla