summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-27 02:37:29 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-27 02:37:29 +0000
commitc5a14d3864b3d648ebde099cd959cbba9203627f (patch)
tree602a4d54017c3f3a7559a58ede838f126466002a /webkit/port
parent4a4f066c6eea2638f5ff24bfee54b9e68e7ba174 (diff)
downloadchromium_src-c5a14d3864b3d648ebde099cd959cbba9203627f.zip
chromium_src-c5a14d3864b3d648ebde099cd959cbba9203627f.tar.gz
chromium_src-c5a14d3864b3d648ebde099cd959cbba9203627f.tar.bz2
Changes to the interval timer:
- move into the window.chromium namespace. - hide the native HiResTime() function. - fixup the stop() mechanics. - Added a layout test. Review URL: http://codereview.chromium.org/28201 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/bindings/v8/extensions/Interval.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/webkit/port/bindings/v8/extensions/Interval.cpp b/webkit/port/bindings/v8/extensions/Interval.cpp
index 6da7f6d..4a5c13d 100644
--- a/webkit/port/bindings/v8/extensions/Interval.cpp
+++ b/webkit/port/bindings/v8/extensions/Interval.cpp
@@ -14,11 +14,15 @@ class IntervalExtensionWrapper : public v8::Extension {
public:
IntervalExtensionWrapper() :
v8::Extension(kIntervalExtensionName,
- "native function HiResTime();"
- "function Interval() {"
+ "var chromium;"
+ "if (!chromium)"
+ " chromium = {};"
+ "chromium.Interval = function() {"
" var start_ = 0;"
" var stop_ = 0;"
+ " native function HiResTime();"
" this.start = function() {"
+ " stop_ = 0;"
" start_ = HiResTime();"
" };"
" this.stop = function() {"
@@ -27,9 +31,10 @@ public:
" stop_ = 0;"
" };"
" this.microseconds = function() {"
- " if (stop_ == 0)"
- " stop();"
- " return Math.ceil((stop_ - start_) * 1000000);"
+ " var stop = stop_;"
+ " if (stop == 0 && start_ != 0)"
+ " stop = HiResTime();"
+ " return Math.ceil((stop - start_) * 1000000);"
" };"
"}") {};