1cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)/* 2cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * Copyright (C) 2009 Google Inc. All rights reserved. 3cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * 4cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without 5cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * modification, are permitted provided that the following conditions 6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * are met: 7cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * 1. Redistributions of source code must retain the above copyright 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * notice, this list of conditions and the following disclaimer. 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright 10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * notice, this list of conditions and the following disclaimer in the 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * documentation and/or other materials provided with the distribution. 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * 13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * THE POSSIBILITY OF SUCH DAMAGE. 24cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) */ 25cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 26cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#ifndef V8ScriptRunner_h 27cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define V8ScriptRunner_h 28cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 29cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "bindings/core/v8/V8CacheOptions.h" 30cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "core/fetch/CrossOriginAccessControl.h" 31cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "wtf/PassOwnPtr.h" 32cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "wtf/text/TextPosition.h" 33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "wtf/text/WTFString.h" 34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include <v8.h> 35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace blink { 37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 38cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class ScriptResource; 39cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class ScriptSourceCode; 40cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class ExecutionContext; 41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class ScriptStreamer; 42cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 43cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class V8ScriptRunner { 44cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)public: 45cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // For the following methods, the caller sites have to hold 46cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // a HandleScope and a ContextScope. 47cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Script> compileScript(const ScriptSourceCode&, v8::Isolate*, AccessControlStatus = SharableCrossOrigin, V8CacheOptions = V8CacheOptionsOff); 48cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Script> compileScript(v8::Handle<v8::String>, const String& fileName, const TextPosition&, ScriptResource*, ScriptStreamer*, v8::Isolate*, AccessControlStatus = SharableCrossOrigin, V8CacheOptions = V8CacheOptionsOff); 49cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Value> runCompiledScript(v8::Handle<v8::Script>, ExecutionContext*, v8::Isolate*); 50cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Value> compileAndRunInternalScript(v8::Handle<v8::String>, v8::Isolate*, const String& = String(), const TextPosition& = TextPosition()); 51cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Value> runCompiledInternalScript(v8::Handle<v8::Script>, v8::Isolate*); 52cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Value> callInternalFunction(v8::Handle<v8::Function>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[], v8::Isolate*); 53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, ExecutionContext*, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[], v8::Isolate*); 54cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Value> callAsFunction(v8::Isolate*, v8::Handle<v8::Object>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[]); 55cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Object> instantiateObject(v8::Isolate*, v8::Handle<v8::ObjectTemplate>); 56cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Object> instantiateObject(v8::Isolate*, v8::Handle<v8::Function>, int argc = 0, v8::Handle<v8::Value> argv[] = 0); 57cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static v8::Local<v8::Object> instantiateObjectInDocument(v8::Isolate*, v8::Handle<v8::Function>, ExecutionContext*, int argc = 0, v8::Handle<v8::Value> argv[] = 0); 58cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 59cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static unsigned tagForParserCache(); 60cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static unsigned tagForCodeCache(); 61cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}; 62cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 63cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} // namespace blink 64cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 65cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif // V8ScriptRunner_h 66cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)