Commit c01ff49a authored by ap@webkit.org's avatar ap@webkit.org

Reviewed by Darin Adler.

        https://bugs.webkit.org/show_bug.cgi?id=23207
        Moved currentTime() to from WebCore to WTF.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39784 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c1ff8e5b
2009-01-11 Dmitry Titov <dimich@chromium.org>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=23207
Moved currentTime() to from WebCore to WTF.
* GNUmakefile.am:
* JavaScriptCore.exp: added export for WTF::currentTime()
* JavaScriptCore.pri:
* JavaScriptCore.scons:
* JavaScriptCore.vcproj/WTF/WTF.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* JavaScriptCoreSources.bkl:
* runtime/DateMath.cpp:
(JSC::getCurrentUTCTimeWithMicroseconds): This function had another implementation of currentTime(), essentially. Now uses WTF version.
* wtf/CurrentTime.cpp: Added.
(WTF::currentTime):
(WTF::highResUpTime):
(WTF::lowResUTCTime):
(WTF::qpcAvailable):
* wtf/CurrentTime.h: Added.
2009-01-09 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -192,6 +192,8 @@ javascriptcore_sources += \
JavaScriptCore/wtf/AlwaysInline.h \
JavaScriptCore/wtf/Assertions.cpp \
JavaScriptCore/wtf/Assertions.h \
JavaScriptCore/wtf/CurrentTime.cpp \
JavaScriptCore/wtf/CurrentTime.h \
JavaScriptCore/wtf/Deque.h \
JavaScriptCore/wtf/DisallowCType.h \
JavaScriptCore/wtf/Forward.h \
......
......@@ -268,6 +268,7 @@ __ZN3JSCgtERKNS_7UStringES2_
__ZN3JSCltERKNS_7UStringES2_
__ZN3WTF10fastCallocEmm
__ZN3WTF10fastMallocEm
__ZN3WTF11currentTimeEv
__ZN3WTF11fastReallocEPvm
__ZN3WTF12createThreadEPFPvS0_ES0_
__ZN3WTF12createThreadEPFPvS0_ES0_PKc
......
......@@ -110,6 +110,7 @@ SOURCES += \
runtime/Collector.cpp \
runtime/CommonIdentifiers.cpp \
runtime/ConstructData.cpp \
wtf/CurrentTime.cpp \
runtime/DateConstructor.cpp \
runtime/DateInstance.cpp \
runtime/DateMath.cpp \
......
......@@ -142,6 +142,7 @@ sources['wrec'] = [
]
sources['wtf'] = [
'wtf/Assertions.cpp',
'wtf/CurrentTime.cpp',
'wtf/FastMalloc.cpp',
'wtf/HashTable.cpp',
'wtf/RandomNumber.cpp',
......
......@@ -242,6 +242,14 @@
RelativePath="..\..\wtf\unicode\icu\CollatorICU.cpp"
>
</File>
<File
RelativePath="..\..\wtf\CurrentTime.cpp"
>
</File>
<File
RelativePath="..\..\wtf\CurrentTime.h"
>
</File>
<File
RelativePath="..\..\wtf\Deque.h"
>
......
......@@ -88,6 +88,8 @@
14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */; };
14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */; };
14F3488F0E95EF8A003648BC /* CollectorHeapIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F3488E0E95EF8A003648BC /* CollectorHeapIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
180B9B080F16D94F009BDBC5 /* CurrentTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 180B9AF00F16C569009BDBC5 /* CurrentTime.h */; settings = {ATTRIBUTES = (Private, ); }; };
180B9BFE0F16E94D009BDBC5 /* CurrentTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 180B9AEF0F16C569009BDBC5 /* CurrentTime.cpp */; };
1C61516C0EBAC7A00031376F /* ProfilerServer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C61516A0EBAC7A00031376F /* ProfilerServer.mm */; settings = {COMPILER_FLAGS = "-fno-strict-aliasing"; }; };
1C61516D0EBAC7A00031376F /* ProfilerServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C61516B0EBAC7A00031376F /* ProfilerServer.h */; };
5D53726F0E1C54880021E549 /* Tracing.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D53726E0E1C54880021E549 /* Tracing.h */; };
......@@ -497,6 +499,8 @@
14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalObject.cpp; sourceTree = "<group>"; };
14F252560D08DD8D004ECFFF /* JSVariableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVariableObject.h; sourceTree = "<group>"; };
14F3488E0E95EF8A003648BC /* CollectorHeapIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectorHeapIterator.h; sourceTree = "<group>"; };
180B9AEF0F16C569009BDBC5 /* CurrentTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CurrentTime.cpp; sourceTree = "<group>"; };
180B9AF00F16C569009BDBC5 /* CurrentTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CurrentTime.h; sourceTree = "<group>"; };
1C61516A0EBAC7A00031376F /* ProfilerServer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ProfilerServer.mm; path = profiler/ProfilerServer.mm; sourceTree = "<group>"; };
1C61516B0EBAC7A00031376F /* ProfilerServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProfilerServer.h; path = profiler/ProfilerServer.h; sourceTree = "<group>"; };
1C9051420BA9E8A70081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
......@@ -1079,6 +1083,8 @@
93AA4F770957251F0084B3A7 /* AlwaysInline.h */,
65E217B808E7EECC0023E5F6 /* Assertions.cpp */,
65E217B708E7EECC0023E5F6 /* Assertions.h */,
180B9AEF0F16C569009BDBC5 /* CurrentTime.cpp */,
180B9AF00F16C569009BDBC5 /* CurrentTime.h */,
5186111D0CC824830081412B /* Deque.h */,
938C4F6B0CA06BCE00D9310A /* DisallowCType.h */,
65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */,
......@@ -1508,6 +1514,7 @@
BC18C3F30E16F5CD00B34460 /* CommonIdentifiers.h in Headers */,
BC18C3F40E16F5CD00B34460 /* Completion.h in Headers */,
BC18C3F60E16F5CD00B34460 /* ConstructData.h in Headers */,
180B9B080F16D94F009BDBC5 /* CurrentTime.h in Headers */,
BCD2034A0E17135E002C7E82 /* DateConstructor.h in Headers */,
BC1166020E1997B4008066DD /* DateInstance.h in Headers */,
BC18C3F90E16F5CD00B34460 /* DateMath.h in Headers */,
......@@ -1985,6 +1992,7 @@
969A07960ED1D3AE00F1F681 /* CodeBlock.cpp in Sources */,
E1A862D60D7F2B5C001EC6AA /* CollatorDefault.cpp in Sources */,
E1A862A90D7EBB76001EC6AA /* CollatorICU.cpp in Sources */,
180B9BFE0F16E94D009BDBC5 /* CurrentTime.cpp in Sources */,
149559EE0DDCDDF700648087 /* DebuggerCallFrame.cpp in Sources */,
1429D8780ED21ACD00B89619 /* ExceptionHelpers.cpp in Sources */,
A7B48F490EE8936F00DCBDB6 /* ExecutableAllocator.cpp in Sources */,
......
......@@ -159,6 +159,7 @@ Source files for JSCore.
</set>
<set append="1" var="JSCORE_WTF_SOURCES">
wtf/Assertions.cpp
wtf/CurrentTime.cpp
wtf/FastMalloc.cpp
wtf/HashTable.cpp
wtf/MainThread.cpp
......
......@@ -48,6 +48,7 @@
#include <time.h>
#include <wtf/ASCIICType.h>
#include <wtf/Assertions.h>
#include <wtf/CurrentTime.h>
#include <wtf/MathExtras.h>
#include <wtf/StringExtras.h>
......@@ -291,139 +292,10 @@ double getCurrentUTCTime()
return floor(getCurrentUTCTimeWithMicroseconds());
}
#if PLATFORM(WIN_OS)
static LARGE_INTEGER qpcFrequency;
static bool syncedTime;
static double highResUpTime()
{
// We use QPC, but only after sanity checking its result, due to bugs:
// http://support.microsoft.com/kb/274323
// http://support.microsoft.com/kb/895980
// http://msdn.microsoft.com/en-us/library/ms644904.aspx ("...you can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL)."
static LARGE_INTEGER qpcLast;
static DWORD tickCountLast;
static bool inited;
LARGE_INTEGER qpc;
QueryPerformanceCounter(&qpc);
DWORD tickCount = GetTickCount();
if (inited) {
__int64 qpcElapsed = ((qpc.QuadPart - qpcLast.QuadPart) * 1000) / qpcFrequency.QuadPart;
__int64 tickCountElapsed;
if (tickCount >= tickCountLast)
tickCountElapsed = (tickCount - tickCountLast);
else {
#if COMPILER(MINGW)
__int64 tickCountLarge = tickCount + 0x100000000ULL;
#else
__int64 tickCountLarge = tickCount + 0x100000000I64;
#endif
tickCountElapsed = tickCountLarge - tickCountLast;
}
// force a re-sync if QueryPerformanceCounter differs from GetTickCount by more than 500ms.
// (500ms value is from http://support.microsoft.com/kb/274323)
__int64 diff = tickCountElapsed - qpcElapsed;
if (diff > 500 || diff < -500)
syncedTime = false;
} else
inited = true;
qpcLast = qpc;
tickCountLast = tickCount;
return (1000.0 * qpc.QuadPart) / static_cast<double>(qpcFrequency.QuadPart);;
}
static double lowResUTCTime()
{
#if PLATFORM(WIN_CE)
SYSTEMTIME systemTime;
GetSystemTime(&systemTime);
struct tm tmtime;
tmtime.tm_year = systemTime.wYear - 1900;
tmtime.tm_mon = systemTime.wMonth - 1;
tmtime.tm_mday = systemTime.wDay;
tmtime.tm_wday = systemTime.wDayOfWeek;
tmtime.tm_hour = systemTime.wHour;
tmtime.tm_min = systemTime.wMinute;
tmtime.tm_sec = systemTime.wSecond;
time_t timet = mktime(&tmtime);
return timet * msPerSecond + systemTime.wMilliseconds;
#else
struct _timeb timebuffer;
_ftime(&timebuffer);
return timebuffer.time * msPerSecond + timebuffer.millitm;
#endif
}
static bool qpcAvailable()
{
static bool available;
static bool checked;
if (checked)
return available;
available = QueryPerformanceFrequency(&qpcFrequency);
checked = true;
return available;
}
#endif
// Returns current time in milliseconds since 1 Jan 1970.
double getCurrentUTCTimeWithMicroseconds()
{
#if PLATFORM(WIN_OS)
// Use a combination of ftime and QueryPerformanceCounter.
// ftime returns the information we want, but doesn't have sufficient resolution.
// QueryPerformanceCounter has high resolution, but is only usable to measure time intervals.
// To combine them, we call ftime and QueryPerformanceCounter initially. Later calls will use QueryPerformanceCounter
// by itself, adding the delta to the saved ftime. We periodically re-sync to correct for drift.
static bool started;
static double syncLowResUTCTime;
static double syncHighResUpTime;
static double lastUTCTime;
double lowResTime = lowResUTCTime();
if (!qpcAvailable())
return lowResTime;
double highResTime = highResUpTime();
if (!syncedTime) {
timeBeginPeriod(1); // increase time resolution around low-res time getter
syncLowResUTCTime = lowResTime = lowResUTCTime();
timeEndPeriod(1); // restore time resolution
syncHighResUpTime = highResTime;
syncedTime = true;
}
double highResElapsed = highResTime - syncHighResUpTime;
double utc = syncLowResUTCTime + highResElapsed;
// force a clock re-sync if we've drifted
double lowResElapsed = lowResTime - syncLowResUTCTime;
const double maximumAllowedDriftMsec = 15.625 * 2.0; // 2x the typical low-res accuracy
if (fabs(highResElapsed - lowResElapsed) > maximumAllowedDriftMsec)
syncedTime = false;
// make sure time doesn't run backwards (only correct if difference is < 2 seconds, since DST or clock changes could occur)
const double backwardTimeLimit = 2000.0;
if (utc < lastUTCTime && (lastUTCTime - utc) < backwardTimeLimit)
return lastUTCTime;
lastUTCTime = utc;
#else
struct timeval tv;
gettimeofday(&tv, 0);
double utc = tv.tv_sec * msPerSecond + tv.tv_usec / 1000.0;
#endif
return utc;
return currentTime() * 1000.0;
}
void getLocalTime(const time_t* localTime, struct tm* localTM)
......
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2008 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "CurrentTime.h"
#if PLATFORM(MAC)
#include <CoreFoundation/CFDate.h>
#elif PLATFORM(WIN)
#include <windows.h>
#include <math.h>
#include <stdint.h>
#include <time.h>
#elif PLATFORM(GTK)
#include <glib.h>
#elif PLATFORM(WX)
#include <wx/datetime.h>
#else // Posix systems relying on the gettimeofday()
#include <sys/time.h>
#endif
namespace WTF {
#if PLATFORM(MAC)
double currentTime()
{
return CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970;
}
#elif PLATFORM(WIN)
static LARGE_INTEGER qpcFrequency;
static bool syncedTime;
static double highResUpTime()
{
// We use QPC, but only after sanity checking its result, due to bugs:
// http://support.microsoft.com/kb/274323
// http://support.microsoft.com/kb/895980
// http://msdn.microsoft.com/en-us/library/ms644904.aspx ("...you can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL)."
static LARGE_INTEGER qpcLast;
static DWORD tickCountLast;
static bool inited;
LARGE_INTEGER qpc;
QueryPerformanceCounter(&qpc);
DWORD tickCount = GetTickCount();
if (inited) {
__int64 qpcElapsed = ((qpc.QuadPart - qpcLast.QuadPart) * 1000) / qpcFrequency.QuadPart;
__int64 tickCountElapsed;
if (tickCount >= tickCountLast)
tickCountElapsed = (tickCount - tickCountLast);
else {
#if COMPILER(MINGW)
__int64 tickCountLarge = tickCount + 0x100000000ULL;
#else
__int64 tickCountLarge = tickCount + 0x100000000I64;
#endif
tickCountElapsed = tickCountLarge - tickCountLast;
}
// force a re-sync if QueryPerformanceCounter differs from GetTickCount by more than 500ms.
// (500ms value is from http://support.microsoft.com/kb/274323)
__int64 diff = tickCountElapsed - qpcElapsed;
if (diff > 500 || diff < -500)
syncedTime = false;
} else
inited = true;
qpcLast = qpc;
tickCountLast = tickCount;
return (1000.0 * qpc.QuadPart) / static_cast<double>(qpcFrequency.QuadPart);
}
static double lowResUTCTime()
{
#if PLATFORM(WIN_CE)
SYSTEMTIME systemTime;
GetSystemTime(&systemTime);
struct tm tmtime;
tmtime.tm_year = systemTime.wYear - 1900;
tmtime.tm_mon = systemTime.wMonth - 1;
tmtime.tm_mday = systemTime.wDay;
tmtime.tm_wday = systemTime.wDayOfWeek;
tmtime.tm_hour = systemTime.wHour;
tmtime.tm_min = systemTime.wMinute;
tmtime.tm_sec = systemTime.wSecond;
time_t timet = mktime(&tmtime);
return timet * msPerSecond + systemTime.wMilliseconds;
#else // PLATFORM(WIN_CE)
struct _timeb timebuffer;
_ftime(&timebuffer);
return timebuffer.time * msPerSecond + timebuffer.millitm;
#endif // PLATFORM(WIN_CE)
}
static bool qpcAvailable()
{
static bool available;
static bool checked;
if (checked)
return available;
available = QueryPerformanceFrequency(&qpcFrequency);
checked = true;
return available;
}
double currentTime()
{
// Use a combination of ftime and QueryPerformanceCounter.
// ftime returns the information we want, but doesn't have sufficient resolution.
// QueryPerformanceCounter has high resolution, but is only usable to measure time intervals.
// To combine them, we call ftime and QueryPerformanceCounter initially. Later calls will use QueryPerformanceCounter
// by itself, adding the delta to the saved ftime. We periodically re-sync to correct for drift.
static bool started;
static double syncLowResUTCTime;
static double syncHighResUpTime;
static double lastUTCTime;
double lowResTime = lowResUTCTime();
if (!qpcAvailable())
return lowResTime;
double highResTime = highResUpTime();
if (!syncedTime) {
timeBeginPeriod(1); // increase time resolution around low-res time getter
syncLowResUTCTime = lowResTime = lowResUTCTime();
timeEndPeriod(1); // restore time resolution
syncHighResUpTime = highResTime;
syncedTime = true;
}
double highResElapsed = highResTime - syncHighResUpTime;
double utc = syncLowResUTCTime + highResElapsed;
// force a clock re-sync if we've drifted
double lowResElapsed = lowResTime - syncLowResUTCTime;
const double maximumAllowedDriftMsec = 15.625 * 2.0; // 2x the typical low-res accuracy
if (fabs(highResElapsed - lowResElapsed) > maximumAllowedDriftMsec)
syncedTime = false;
// make sure time doesn't run backwards (only correct if difference is < 2 seconds, since DST or clock changes could occur)
const double backwardTimeLimit = 2000.0;
if (utc < lastUTCTime && (lastUTCTime - utc) < backwardTimeLimit)
return lastUTCTime;
lastUTCTime = utc;
return utc / 1000.0;
}
#elif PLATFORM(GTK)
// Note: GTK on Windows will pick up the PLATFORM(WIN) implementation above which provides
// better accuracy compared with Windows implementation of g_get_current_time:
// (http://www.google.com/codesearch/p?hl=en#HHnNRjks1t0/glib-2.5.2/glib/gmain.c&q=g_get_current_time).
// Non-Windows GTK builds could use gettimeofday() directly but for the sake of consistency lets use GTK function.
double currentTime()
{
GTimeVal now;
g_get_current_time(&now);
return static_cast<double>(now.tv_sec) + static_cast<double>(now.tv_usec / 1000000.0);
}
#elif PLATFORM(WX)
double currentTime()
{
wxDateTime now = wxDateTime::UNow();
return (double)now.GetTicks() + (double)(now.GetMillisecond() / 1000.0);
}
#else // Other Posix systems rely on the gettimeofday().
double currentTime()
{
struct timeval now;
struct timezone zone;
gettimeofday(&now, &zone);
return static_cast<double>(now.tv_sec) + (double)(now.tv_usec / 1000000.0);
}
#endif
} // namespace WTF
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2008 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CurrentTime_h
#define CurrentTime_h
namespace WTF {
// Returns the current system (UTC) time in seconds, starting January 1, 1970.
// Precision varies depending on a platform but usually is as good or better
// then a millisecond.
double currentTime();
} // namespace WTF
using WTF::currentTime;
#endif // CurrentTime_h
2009-01-11 Dmitry Titov <dimich@chromium.org>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=23207
Moved currentTime() to from WebCore to WTF.
Most of these files only have a different header file included.
Various build files reflect removal of SystemTimeGtk, Wx, Qt and Linux
which were removed since they only implemented currentTime().
* ForwardingHeaders/wtf/CurrentTime.h: Added.
* GNUmakefile.am:
* WebCore.base.exp:
* WebCore.pro:
* dom/ContainerNode.cpp:
* dom/Document.cpp:
* dom/Event.cpp:
* history/CachedPage.cpp:
* history/PageCache.cpp:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::load):
(WebCore::HTMLMediaElement::progressEventTimerFired):
* html/HTMLTokenizer.cpp:
* html/PreloadScanner.cpp:
* inspector/InspectorController.cpp:
* loader/Cache.cpp:
(WebCore::Cache::pruneLiveResources):
* loader/CachedImage.cpp:
* loader/CachedResource.cpp:
* loader/FrameLoader.cpp:
* loader/ProgressTracker.cpp:
* loader/icon/IconDatabase.cpp:
* loader/icon/IconRecord.cpp:
* page/DragController.cpp:
* page/Frame.cpp:
* page/FrameView.cpp:
* page/animation/AnimationBase.cpp:
* page/animation/AnimationController.cpp:
* page/animation/KeyframeAnimation.cpp:
* platform/SystemTime.h:
* platform/Timer.cpp:
* platform/graphics/BitmapImage.cpp:
* platform/gtk/MouseEventGtk.cpp:
* platform/gtk/SharedTimerGtk.cpp:
* platform/gtk/SystemTimeGtk.cpp: Removed.
* platform/gtk/SystemTimeLinux.cpp: Removed.
* platform/mac/SystemTimeMac.cpp:
* platform/qt/PlatformMouseEventQt.cpp:
(WebCore::PlatformMouseEvent::PlatformMouseEvent):
* platform/qt/SharedTimerQt.cpp:
* platform/qt/SharedTimerQt.h:
* platform/qt/SystemTimeQt.cpp: Removed.
* platform/win/SharedTimerWin.cpp:
* platform/win/SystemTimeWin.cpp:
* platform/wx/MouseEventWx.cpp:
(WebCore::PlatformMouseEvent::PlatformMouseEvent):
* platform/wx/SharedTimerWx.cpp:
* platform/wx/SystemTimeWx.cpp: Removed.
* rendering/RenderImage.cpp:
* rendering/RenderMedia.cpp:
* svg/animation/SMILTimeContainer.cpp:
* webcore-wx.bkl:
* xml/XMLHttpRequest.cpp:
2009-01-11 Dmitry Titov <dimich@chromium.org>
Reviewed by Darin Adler.
#include <JavaScriptCore/CurrentTime.h>
......@@ -1731,7 +1731,6 @@ webcoregtk_sources += \
WebCore/platform/gtk/SharedBufferGtk.cpp \
WebCore/platform/gtk/SharedTimerGtk.cpp \
WebCore/platform/gtk/SoundGtk.cpp \
WebCore/platform/gtk/SystemTimeGtk.cpp \
WebCore/platform/gtk/TemporaryLinkStubs.cpp \
WebCore/platform/gtk/WheelEventGtk.cpp \
WebCore/platform/gtk/WidgetGtk.cpp \
......
......@@ -203,7 +203,6 @@ __ZN7WebCore11IconFetcher6createEPNS_5FrameEPNS_17IconFetcherClientE
__ZN7WebCore11RenderLayer18gAlignCenterAlwaysE
__ZN7WebCore11RenderLayer19scrollRectToVisibleERKNS_7IntRectEbRKNS0_15ScrollAlignmentES6_
__ZN7WebCore11RenderLayer20gAlignToEdgeIfNeededE
__ZN7WebCore11currentTimeEv
__ZN7WebCore11globalPointERK8_NSPointP8NSWindow
__ZN7WebCore11toUserSpaceERK7_NSRectP8NSWindow
__ZN7WebCore12AtomicString3addEPKc
......
......@@ -1153,9 +1153,6 @@ SOURCES += \
../WebKit/qt/Api/qwebdatabase.cpp
win32-*|wince*: SOURCES += platform/win/SystemTimeWin.cpp
else: SOURCES += platform/qt/SystemTimeQt.cpp
mac {
SOURCES += \
platform/text/cf/StringCF.cpp \
......
......@@ -36,7 +36,7 @@
#include "MutationEvent.h"
#include "RenderTheme.h"
#include "RootInlineBox.h"
#include "SystemTime.h"
#include <wtf/CurrentTime.h>
#include <wtf/Vector.h>
namespace WebCore {
......