WebCore/bindings/js/ScheduledAction.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  *  Copyright (C) 2000 Harri Porten (porten@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/PassOwnPtr.h>
       
    28 #include <wtf/Vector.h>
       
    29 
       
    30 namespace JSC {
       
    31     class JSGlobalObject;
       
    32 }
       
    33 
       
    34 namespace WebCore {
       
    35 
       
    36     class Document;
       
    37     class ScriptExecutionContext;
       
    38     class WorkerContext;
       
    39 
       
    40    /* An action (either function or string) to be executed after a specified
       
    41     * time interval, either once or repeatedly. Used for window.setTimeout()
       
    42     * and window.setInterval()
       
    43     */
       
    44     class ScheduledAction : public Noncopyable {
       
    45     public:
       
    46         static PassOwnPtr<ScheduledAction> create(JSC::ExecState*, DOMWrapperWorld* isolatedWorld);
       
    47 
       
    48         void execute(ScriptExecutionContext*);
       
    49 
       
    50     private:
       
    51         ScheduledAction(JSC::ExecState*, JSC::JSValue function, DOMWrapperWorld* isolatedWorld);
       
    52         ScheduledAction(const String& code, DOMWrapperWorld* isolatedWorld)
       
    53             : m_code(code)
       
    54             , m_isolatedWorld(isolatedWorld)
       
    55         {
       
    56         }
       
    57 
       
    58         void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue thisValue, ScriptExecutionContext*);
       
    59         void execute(Document*);
       
    60 #if ENABLE(WORKERS)
       
    61         void execute(WorkerContext*);
       
    62 #endif
       
    63 
       
    64         JSC::ProtectedJSValue m_function;
       
    65         Vector<JSC::ProtectedJSValue> m_args;
       
    66         String m_code;
       
    67         RefPtr<DOMWrapperWorld> m_isolatedWorld;
       
    68     };
       
    69 
       
    70 } // namespace WebCore
       
    71 
       
    72 #endif // ScheduledAction_h