1 /* 2 * Copyright (C) 2000 Harri Porten (porten (at) kde.org) 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reseved. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef ScheduledAction_h 21 #define ScheduledAction_h 22 23 #include "PlatformString.h" 24 #include <JSDOMBinding.h> 25 #include <runtime/JSCell.h> 26 #include <runtime/Protect.h> 27 #include <wtf/Vector.h> 28 29 namespace JSC { 30 class JSGlobalObject; 31 } 32 33 namespace WebCore { 34 35 class Document; 36 class ScriptExecutionContext; 37 class WorkerContext; 38 39 /* An action (either function or string) to be executed after a specified 40 * time interval, either once or repeatedly. Used for window.setTimeout() 41 * and window.setInterval() 42 */ 43 class ScheduledAction : public Noncopyable { 44 public: 45 static ScheduledAction* create(JSC::ExecState*, const JSC::ArgList&, DOMWrapperWorld* isolatedWorld); 46 47 void execute(ScriptExecutionContext*); 48 49 private: 50 ScheduledAction(JSC::JSValue function, const JSC::ArgList&, DOMWrapperWorld* isolatedWorld); 51 ScheduledAction(const String& code, DOMWrapperWorld* isolatedWorld) 52 : m_code(code) 53 , m_isolatedWorld(isolatedWorld) 54 { 55 } 56 57 void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue thisValue); 58 void execute(Document*); 59 #if ENABLE(WORKERS) 60 void execute(WorkerContext*); 61 #endif 62 63 JSC::ProtectedJSValue m_function; 64 Vector<JSC::ProtectedJSValue> m_args; 65 String m_code; 66 RefPtr<DOMWrapperWorld> m_isolatedWorld; 67 }; 68 69 } // namespace WebCore 70 71 #endif // ScheduledAction_h 72