diff --git a/engine/platform/testing/RunAllTests.cpp b/engine/platform/testing/RunAllTests.cpp index ad9d0e923bd..7f40d69c4b1 100644 --- a/engine/platform/testing/RunAllTests.cpp +++ b/engine/platform/testing/RunAllTests.cpp @@ -39,11 +39,6 @@ #include "sky/engine/wtf/MainThread.h" #include "sky/engine/wtf/WTF.h" -static double CurrentTime() -{ - return 0.0; -} - static void AlwaysZeroNumberSource(unsigned char* buf, size_t len) { memset(buf, '\0', len); @@ -52,7 +47,7 @@ static void AlwaysZeroNumberSource(unsigned char* buf, size_t len) int main(int argc, char** argv) { WTF::setRandomSource(AlwaysZeroNumberSource); - WTF::initialize(CurrentTime, 0); + WTF::initialize(); WTF::initializeMainThread(); blink::TestingPlatformSupport::Config platformConfig; diff --git a/engine/web/Sky.cpp b/engine/web/Sky.cpp index b95252f0d47..de85c744d42 100644 --- a/engine/web/Sky.cpp +++ b/engine/web/Sky.cpp @@ -132,16 +132,6 @@ v8::Isolate* mainThreadIsolate() return V8PerIsolateData::mainThreadIsolate(); } -static double currentTimeFunction() -{ - return Platform::current()->currentTime(); -} - -static double monotonicallyIncreasingTimeFunction() -{ - return Platform::current()->monotonicallyIncreasingTime(); -} - static void cryptographicallyRandomValues(unsigned char* buffer, size_t length) { base::RandBytes(buffer, length); @@ -156,7 +146,7 @@ void initializeWithoutV8(Platform* platform) Platform::initialize(platform); WTF::setRandomSource(cryptographicallyRandomValues); - WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction); + WTF::initialize(); WTF::initializeMainThread(); DEFINE_STATIC_LOCAL(CoreInitializer, initializer, ()); diff --git a/engine/wtf/CurrentTime.cpp b/engine/wtf/CurrentTime.cpp index b9e9e5e6154..638f4bcb242 100644 --- a/engine/wtf/CurrentTime.cpp +++ b/engine/wtf/CurrentTime.cpp @@ -28,32 +28,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "base/time/time.h" #include "sky/engine/config.h" #include "sky/engine/wtf/CurrentTime.h" namespace WTF { -static TimeFunction currentTimeFunction; -static TimeFunction monotonicallyIncreasingTimeFunction; - -void setCurrentTimeFunction(TimeFunction func) -{ - currentTimeFunction = func; -} - -void setMonotonicallyIncreasingTimeFunction(TimeFunction func) -{ - monotonicallyIncreasingTimeFunction = func; -} - double currentTime() { - return (*currentTimeFunction)(); + return base::Time::Now().ToDoubleT(); } double monotonicallyIncreasingTime() { - return (*monotonicallyIncreasingTimeFunction)(); + return base::TimeTicks::Now().ToInternalValue() / + static_cast(base::Time::kMicrosecondsPerSecond); } } // namespace WTF diff --git a/engine/wtf/CurrentTime.h b/engine/wtf/CurrentTime.h index 9e60c5e2fe4..d387b985f78 100644 --- a/engine/wtf/CurrentTime.h +++ b/engine/wtf/CurrentTime.h @@ -52,9 +52,6 @@ inline double currentTimeMS() WTF_EXPORT double monotonicallyIncreasingTime(); typedef double(*TimeFunction)(void); -void setCurrentTimeFunction(TimeFunction); -void setMonotonicallyIncreasingTimeFunction(TimeFunction); - } // namespace WTF diff --git a/engine/wtf/WTF.cpp b/engine/wtf/WTF.cpp index 0880460895e..902f8b93a01 100644 --- a/engine/wtf/WTF.cpp +++ b/engine/wtf/WTF.cpp @@ -43,7 +43,7 @@ bool s_shutdown; bool Partitions::s_initialized; PartitionAllocatorGeneric Partitions::m_bufferAllocator; -void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncreasingTimeFunction) +void initialize() { // WTF, and Blink in general, cannot handle being re-initialized, even if shutdown first. // Make that explicit here. @@ -51,8 +51,6 @@ void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncr ASSERT(!s_shutdown); s_initialized = true; Partitions::initialize(); - setCurrentTimeFunction(currentTimeFunction); - setMonotonicallyIncreasingTimeFunction(monotonicallyIncreasingTimeFunction); initializeThreading(); } diff --git a/engine/wtf/WTF.h b/engine/wtf/WTF.h index 1371cc748d4..ece7b61e27f 100644 --- a/engine/wtf/WTF.h +++ b/engine/wtf/WTF.h @@ -39,7 +39,7 @@ namespace WTF { // This function must be called exactly once from the main thread before using anything else in WTF. -WTF_EXPORT void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncreasingTimeFunction); +WTF_EXPORT void initialize(); WTF_EXPORT void shutdown(); WTF_EXPORT bool isShutdown(); diff --git a/engine/wtf/testing/RunAllTests.cpp b/engine/wtf/testing/RunAllTests.cpp index 451e00e64b3..a8b1202aa69 100644 --- a/engine/wtf/testing/RunAllTests.cpp +++ b/engine/wtf/testing/RunAllTests.cpp @@ -36,11 +36,6 @@ #include "sky/engine/wtf/MainThread.h" #include "sky/engine/wtf/WTF.h" -static double CurrentTime() -{ - return 0.0; -} - static void AlwaysZeroNumberSource(unsigned char* buf, size_t len) { memset(buf, '\0', len); @@ -49,7 +44,7 @@ static void AlwaysZeroNumberSource(unsigned char* buf, size_t len) int main(int argc, char** argv) { WTF::setRandomSource(AlwaysZeroNumberSource); - WTF::initialize(CurrentTime, 0); + WTF::initialize(); WTF::initializeMainThread(); return base::RunUnitTestsUsingBaseTestSuite(argc, argv); } diff --git a/viewer/platform/platform_impl.cc b/viewer/platform/platform_impl.cc index ace59a38379..5674e54f57d 100644 --- a/viewer/platform/platform_impl.cc +++ b/viewer/platform/platform_impl.cc @@ -59,22 +59,16 @@ blink::WebString PlatformImpl::defaultLocale() { return blink::WebString::fromUTF8("en-US"); } -double PlatformImpl::currentTime() { - return base::Time::Now().ToDoubleT(); -} - -double PlatformImpl::monotonicallyIncreasingTime() { - return base::TimeTicks::Now().ToInternalValue() / - static_cast(base::Time::kMicrosecondsPerSecond); -} - void PlatformImpl::setSharedTimerFiredFunction(void (*func)()) { shared_timer_func_ = func; } void PlatformImpl::setSharedTimerFireInterval( double interval_seconds) { - shared_timer_fire_time_ = interval_seconds + monotonicallyIncreasingTime(); + double now = base::TimeTicks::Now().ToInternalValue() / + static_cast(base::Time::kMicrosecondsPerSecond); + + shared_timer_fire_time_ = interval_seconds + now; if (shared_timer_suspended_) { shared_timer_fire_time_was_set_while_suspended_ = true; return; diff --git a/viewer/platform/platform_impl.h b/viewer/platform/platform_impl.h index ba317caaf46..c0cd133c7e9 100644 --- a/viewer/platform/platform_impl.h +++ b/viewer/platform/platform_impl.h @@ -25,8 +25,6 @@ class PlatformImpl : public blink::Platform { // blink::Platform methods: virtual blink::WebString defaultLocale(); - virtual double currentTime(); - virtual double monotonicallyIncreasingTime(); virtual void setSharedTimerFiredFunction(void (*func)()); virtual void setSharedTimerFireInterval(double interval_seconds); virtual void stopSharedTimer();