Title: [88199] trunk/Source
- Revision
- 88199
- Author
- [email protected]
- Date
- 2011-06-06 16:04:58 -0700 (Mon, 06 Jun 2011)
Log Message
2011-06-06 James Simonsen <[email protected]>
Reviewed by James Robinson.
Add monotonicallyIncreasingTime() to get monotonically increasing time
https://bugs.webkit.org/show_bug.cgi?id=37743
* wtf/CurrentTime.cpp: Add monotonicallyIncreasingTime() for mac and a fallback implementation that just wraps currentTime().
(WTF::monotonicallyIncreasingTime):
* wtf/CurrentTime.h: Add monotonicallyIncreasingTime().
2011-06-06 James Simonsen <[email protected]>
Reviewed by James Robinson.
Add monotonicallyIncreasingTime() to get monotonically increasing time
https://bugs.webkit.org/show_bug.cgi?id=37743
* platform/chromium/SystemTimeChromium.cpp:
(WebCore::monotonicallyIncreasingTime): Add primitive monotonicallyIncreasingTime() which just wraps currentTime().
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (88198 => 88199)
--- trunk/Source/_javascript_Core/ChangeLog 2011-06-06 23:01:25 UTC (rev 88198)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-06-06 23:04:58 UTC (rev 88199)
@@ -1,3 +1,14 @@
+2011-06-06 James Simonsen <[email protected]>
+
+ Reviewed by James Robinson.
+
+ Add monotonicallyIncreasingTime() to get monotonically increasing time
+ https://bugs.webkit.org/show_bug.cgi?id=37743
+
+ * wtf/CurrentTime.cpp: Add monotonicallyIncreasingTime() for mac and a fallback implementation that just wraps currentTime().
+ (WTF::monotonicallyIncreasingTime):
+ * wtf/CurrentTime.h: Add monotonicallyIncreasingTime().
+
2011-06-06 Alexandru Chiculita <[email protected]>
Reviewed by Kent Tamura.
Modified: trunk/Source/_javascript_Core/wtf/CurrentTime.cpp (88198 => 88199)
--- trunk/Source/_javascript_Core/wtf/CurrentTime.cpp 2011-06-06 23:01:25 UTC (rev 88198)
+++ trunk/Source/_javascript_Core/wtf/CurrentTime.cpp 2011-06-06 23:04:58 UTC (rev 88199)
@@ -33,7 +33,10 @@
#include "config.h"
#include "CurrentTime.h"
-#if OS(WINDOWS)
+#if PLATFORM(MAC)
+#include <mach/mach_time.h>
+#include <sys/time.h>
+#elif OS(WINDOWS)
// Windows is first since we want to use hires timers, despite USE(CF)
// being defined.
@@ -294,4 +297,31 @@
#endif
+#if PLATFORM(MAC)
+
+double monotonicallyIncreasingTime()
+{
+ // Based on listing #2 from Apple QA 1398.
+ static mach_timebase_info_data_t timebaseInfo;
+ if (!timebaseInfo.denom) {
+ kern_return_t kr = mach_timebase_info(&timebaseInfo);
+ ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
+ }
+ return (mach_absolute_time() * timebaseInfo.numer) / (1.0e9 * timebaseInfo.denom);
+}
+
+#else
+
+double monotonicallyIncreasingTime()
+{
+ static double lastTime = 0;
+ double currentTimeNow = currentTime();
+ if (currentTimeNow < lastTime)
+ return lastTime;
+ lastTime = currentTimeNow;
+ return currentTimeNow;
+}
+
+#endif
+
} // namespace WTF
Modified: trunk/Source/_javascript_Core/wtf/CurrentTime.h (88198 => 88199)
--- trunk/Source/_javascript_Core/wtf/CurrentTime.h 2011-06-06 23:01:25 UTC (rev 88198)
+++ trunk/Source/_javascript_Core/wtf/CurrentTime.h 2011-06-06 23:04:58 UTC (rev 88199)
@@ -58,11 +58,15 @@
#endif
}
+// Provides a monotonically increasing time in seconds since an arbitrary point in the past.
+// On unsupported platforms, this function only guarantees the result will be non-decreasing.
+double monotonicallyIncreasingTime();
+
} // namespace WTF
using WTF::currentTime;
using WTF::currentTimeMS;
using WTF::getLocalTime;
+using WTF::monotonicallyIncreasingTime;
#endif // CurrentTime_h
-
Modified: trunk/Source/WebCore/ChangeLog (88198 => 88199)
--- trunk/Source/WebCore/ChangeLog 2011-06-06 23:01:25 UTC (rev 88198)
+++ trunk/Source/WebCore/ChangeLog 2011-06-06 23:04:58 UTC (rev 88199)
@@ -1,3 +1,13 @@
+2011-06-06 James Simonsen <[email protected]>
+
+ Reviewed by James Robinson.
+
+ Add monotonicallyIncreasingTime() to get monotonically increasing time
+ https://bugs.webkit.org/show_bug.cgi?id=37743
+
+ * platform/chromium/SystemTimeChromium.cpp:
+ (WebCore::monotonicallyIncreasingTime): Add primitive monotonicallyIncreasingTime() which just wraps currentTime().
+
2011-06-06 Emil A Eklund <[email protected]>
Reviewed by Eric Seidel.
Modified: trunk/Source/WebCore/platform/chromium/SystemTimeChromium.cpp (88198 => 88199)
--- trunk/Source/WebCore/platform/chromium/SystemTimeChromium.cpp 2011-06-06 23:01:25 UTC (rev 88198)
+++ trunk/Source/WebCore/platform/chromium/SystemTimeChromium.cpp 2011-06-06 23:04:58 UTC (rev 88199)
@@ -33,6 +33,7 @@
#include "NotImplemented.h"
#include "PlatformBridge.h"
+#include <wtf/CurrentTime.h>
namespace WebCore {
@@ -42,6 +43,16 @@
return PlatformBridge::currentTime();
}
+double monotonicallyIncreasingTime()
+{
+ static double lastTime = 0;
+ double currentTimeNow = currentTime();
+ if (currentTimeNow < lastTime)
+ return lastTime;
+ lastTime = currentTimeNow;
+ return currentTimeNow;
+}
+
float userIdleTime()
{
// Needed for back/forward cache, which we currently have disabled.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes