Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Unified Diff: third_party/WebKit/WebCore/bindings/js/JSWorkerContextCustom.cpp

Issue 20076: WebKit merge 40500:40539 [WebKit side] (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/WebCore/bindings/js/JSWorkerContextCustom.cpp
===================================================================
--- third_party/WebKit/WebCore/bindings/js/JSWorkerContextCustom.cpp (revision 9118)
+++ third_party/WebKit/WebCore/bindings/js/JSWorkerContextCustom.cpp (working copy)
@@ -31,6 +31,7 @@
#include "JSDOMBinding.h"
#include "JSEventListener.h"
+#include "ScheduledAction.h"
#include "WorkerContext.h"
using namespace JSC;
@@ -93,6 +94,42 @@
return jsUndefined();
}
+static JSValuePtr setTimeoutOrInterval(ExecState* exec, WorkerContext* workerContext, const ArgList& args, bool singleShot)
+{
+ JSValuePtr v = args.at(exec, 0);
+ int delay = args.at(exec, 1).toInt32(exec);
+ if (v.isString())
+ return jsNumber(exec, workerContext->installTimeout(new ScheduledAction(asString(v)->value()), delay, singleShot));
+ CallData callData;
+ if (v.getCallData(callData) == CallTypeNone)
+ return jsUndefined();
+ ArgList argsTail;
+ args.getSlice(2, argsTail);
+ return jsNumber(exec, workerContext->installTimeout(new ScheduledAction(exec, v, argsTail), delay, singleShot));
+}
+
+JSValuePtr JSWorkerContext::setTimeout(ExecState* exec, const ArgList& args)
+{
+ return setTimeoutOrInterval(exec, impl(), args, true);
+}
+
+JSValuePtr JSWorkerContext::clearTimeout(ExecState* exec, const ArgList& args)
+{
+ impl()->removeTimeout(args.at(exec, 0).toInt32(exec));
+ return jsUndefined();
+}
+
+JSValuePtr JSWorkerContext::setInterval(ExecState* exec, const ArgList& args)
+{
+ return setTimeoutOrInterval(exec, impl(), args, false);
+}
+
+JSValuePtr JSWorkerContext::clearInterval(ExecState* exec, const ArgList& args)
+{
+ impl()->removeTimeout(args.at(exec, 0).toInt32(exec));
+ return jsUndefined();
+}
+
} // namespace WebCore
#endif // ENABLE(WORKERS)
« no previous file with comments | « third_party/WebKit/WebCore/bindings/js/JSLocationCustom.cpp ('k') | third_party/WebKit/WebCore/bindings/js/ScriptController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698