mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1026803 part 5 - Convert CurrentXXXTimeGetter classes from functors to helper classes; r=karlt
Previously the CurrentX11TimeGetter and CurrentWindowsTimeGetter classes acted as functors with a single operator() method. In preparation for handling clock skew, this patch refactors these two helper classes into regular classes with two named methods: GetCurrentTime which matches the existing operator() method, and GetTimeAsyncForPossibleBackwardsSkew which will be used when possible backwards skew is detected to fetch the current time asynchronously. Some renaming is also included to match the expanded role of these classes. --HG-- extra : rebase_source : 4d46e09bd09cbb0dbffcb0aa46742157384d37e8
This commit is contained in:
parent
1f60d5ca37
commit
9a127183cd
@ -35,14 +35,14 @@ public:
|
||||
static_assert(!IsSigned<Time>::value, "Expected Time to be unsigned");
|
||||
}
|
||||
|
||||
template <typename GetCurrentTimeFunc>
|
||||
template <typename CurrentTimeGetter>
|
||||
mozilla::TimeStamp
|
||||
GetTimeStampFromSystemTime(Time aTime,
|
||||
GetCurrentTimeFunc aGetCurrentTimeFunc) {
|
||||
CurrentTimeGetter& aCurrentTimeGetter) {
|
||||
// If the reference time is not set, use the current time value to fill
|
||||
// it in.
|
||||
if (mReferenceTimeStamp.IsNull()) {
|
||||
UpdateReferenceTime(aTime, aGetCurrentTimeFunc);
|
||||
UpdateReferenceTime(aTime, aCurrentTimeGetter);
|
||||
}
|
||||
TimeStamp roughlyNow = TimeStamp::NowLoRes();
|
||||
|
||||
@ -63,7 +63,7 @@ public:
|
||||
if (timeSinceReference > kTimeHalfRange &&
|
||||
roughlyNow - mReferenceTimeStamp <
|
||||
TimeDuration::FromMilliseconds(kTimeHalfRange)) {
|
||||
UpdateReferenceTime(aTime, aGetCurrentTimeFunc);
|
||||
UpdateReferenceTime(aTime, aCurrentTimeGetter);
|
||||
timeSinceReference = aTime - mReferenceTime;
|
||||
}
|
||||
|
||||
@ -107,11 +107,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename GetCurrentTimeFunc>
|
||||
template <typename CurrentTimeGetter>
|
||||
void
|
||||
UpdateReferenceTime(Time aTime, GetCurrentTimeFunc aGetCurrentTimeFunc) {
|
||||
UpdateReferenceTime(Time aTime,
|
||||
const CurrentTimeGetter& aCurrentTimeGetter) {
|
||||
mReferenceTime = aTime;
|
||||
Time currentTime = aGetCurrentTimeFunc();
|
||||
Time currentTime = aCurrentTimeGetter.GetCurrentTime();
|
||||
TimeStamp currentTimeStamp = TimeStamp::Now();
|
||||
Time timeSinceReference = currentTime - aTime;
|
||||
mReferenceTimeStamp =
|
||||
|
@ -274,10 +274,17 @@ class MOZ_STACK_CLASS CurrentX11TimeGetter
|
||||
{
|
||||
public:
|
||||
CurrentX11TimeGetter(GdkWindow* aWindow) : mWindow(aWindow) { }
|
||||
guint32 operator() () {
|
||||
|
||||
guint32 GetCurrentTime() const
|
||||
{
|
||||
return gdk_x11_get_server_time(mWindow);
|
||||
}
|
||||
|
||||
void GetTimeAsyncForPossibleBackwardsSkew(const TimeStamp& aNow)
|
||||
{
|
||||
// FIXME: Get time async
|
||||
}
|
||||
|
||||
private:
|
||||
GdkWindow* mWindow;
|
||||
};
|
||||
|
@ -252,9 +252,15 @@ namespace mozilla {
|
||||
|
||||
class CurrentWindowsTimeGetter {
|
||||
public:
|
||||
DWORD operator() () {
|
||||
DWORD GetCurrentTime() const
|
||||
{
|
||||
return ::GetTickCount();
|
||||
}
|
||||
|
||||
void GetTimeAsyncForPossibleBackwardsSkew(const TimeStamp& aNow)
|
||||
{
|
||||
// FIXME: Get time async
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user