Bug 1495871 - use C++11 statics in time_win.cc; r=jld

C++11 provides guaranteed thread-safe static initialization, so we can
use that instead of ipc's baroque Singleton class.
This commit is contained in:
Nathan Froyd 2018-10-05 13:43:47 -04:00
Родитель e2d2f91d22
Коммит 04abc48f2b
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -47,7 +47,6 @@
#include "base/basictypes.h"
#include "base/lock.h"
#include "base/logging.h"
#include "base/singleton.h"
#include "mozilla/Casting.h"
using base::Time;
@ -249,6 +248,11 @@ class NowSingleton {
return TimeDelta::FromMilliseconds(now) + rollover_;
}
static NowSingleton& instance() {
static NowSingleton now;
return now;
}
private:
Lock lock_; // To protected last_seen_ and rollover_.
TimeDelta rollover_; // Accumulation of time lost due to rollover.
@ -269,5 +273,5 @@ TimeTicks::TickFunctionType TimeTicks::SetMockTickFunction(
// static
TimeTicks TimeTicks::Now() {
return TimeTicks() + Singleton<NowSingleton>::get()->Now();
return TimeTicks() + NowSingleton::instance().Now();
}