Chromium Code Reviews

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h

Issue 1670743002: Move V8 extra-calling utilities to V8ScriptRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef V8ScriptRunner_h 26 #ifndef V8ScriptRunner_h
27 #define V8ScriptRunner_h 27 #define V8ScriptRunner_h
28 28
29 #include "bindings/core/v8/ScriptState.h"
30 #include "bindings/core/v8/ScriptValue.h"
haraken 2016/02/05 00:56:41 This wouldn't be needed.
31 #include "bindings/core/v8/V8BindingMacros.h"
29 #include "bindings/core/v8/V8CacheOptions.h" 32 #include "bindings/core/v8/V8CacheOptions.h"
30 #include "core/CoreExport.h" 33 #include "core/CoreExport.h"
31 #include "core/fetch/AccessControlStatus.h" 34 #include "core/fetch/AccessControlStatus.h"
32 #include "platform/text/CompressibleString.h" 35 #include "platform/text/CompressibleString.h"
33 #include "wtf/Allocator.h" 36 #include "wtf/Allocator.h"
34 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
35 #include "wtf/text/TextPosition.h" 38 #include "wtf/text/TextPosition.h"
36 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
37 #include <v8.h> 40 #include <v8.h>
38 41
(...skipping 22 matching lines...)
61 static v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::S tring>, v8::Isolate*, const String& = String(), const TextPosition& = TextPositi on()); 64 static v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::S tring>, v8::Isolate*, const String& = String(), const TextPosition& = TextPositi on());
62 static v8::MaybeLocal<v8::Value> runCompiledInternalScript(v8::Isolate*, v8: :Local<v8::Script>); 65 static v8::MaybeLocal<v8::Value> runCompiledInternalScript(v8::Isolate*, v8: :Local<v8::Script>);
63 static v8::MaybeLocal<v8::Value> callInternalFunction(v8::Local<v8::Function >, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[], v8::Iso late*); 66 static v8::MaybeLocal<v8::Value> callInternalFunction(v8::Local<v8::Function >, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[], v8::Iso late*);
64 static v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, Execu tionContext*, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info [], v8::Isolate*); 67 static v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, Execu tionContext*, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info [], v8::Isolate*);
65 static v8::MaybeLocal<v8::Object> instantiateObject(v8::Isolate*, v8::Local< v8::ObjectTemplate>); 68 static v8::MaybeLocal<v8::Object> instantiateObject(v8::Isolate*, v8::Local< v8::ObjectTemplate>);
66 static v8::MaybeLocal<v8::Object> instantiateObject(v8::Isolate*, v8::Local< v8::Function>, int argc = 0, v8::Local<v8::Value> argv[] = 0); 69 static v8::MaybeLocal<v8::Object> instantiateObject(v8::Isolate*, v8::Local< v8::Function>, int argc = 0, v8::Local<v8::Value> argv[] = 0);
67 static v8::MaybeLocal<v8::Object> instantiateObjectInDocument(v8::Isolate*, v8::Local<v8::Function>, ExecutionContext*, int argc = 0, v8::Local<v8::Value> a rgv[] = 0); 70 static v8::MaybeLocal<v8::Object> instantiateObjectInDocument(v8::Isolate*, v8::Local<v8::Function>, ExecutionContext*, int argc = 0, v8::Local<v8::Value> a rgv[] = 0);
68 71
69 static unsigned tagForParserCache(CachedMetadataHandler*); 72 static unsigned tagForParserCache(CachedMetadataHandler*);
70 static unsigned tagForCodeCache(CachedMetadataHandler*); 73 static unsigned tagForCodeCache(CachedMetadataHandler*);
74
75
76 // Utiltiies for calling functions added to the V8 extras binding object.
77
78 template <size_t N>
79 static v8::MaybeLocal<v8::Value> callExtra(ScriptState* scriptState, const c har* name, v8::Local<v8::Value>(&args)[N])
80 {
81 return callExtraHelper(scriptState, name, N, args);
82 }
83
84 template <size_t N>
85 static v8::Local<v8::Value> callExtraOrCrash(ScriptState* scriptState, const char* name, v8::Local<v8::Value>(&args)[N])
86 {
87 return v8CallOrCrash(callExtraHelper(scriptState, name, N, args));
88 }
89
90 private:
91 static v8::MaybeLocal<v8::Value> callExtraHelper(ScriptState* scriptState, c onst char* name, size_t numArgs, v8::Local<v8::Value>* args)
92 {
93 v8::Isolate* isolate = scriptState->isolate();
94 v8::Local<v8::Value> undefined = v8::Undefined(isolate);
95 v8::Local<v8::Value> functionValue = scriptState->getFromExtrasExports(n ame).v8Value();
96 v8::Local<v8::Function> function = functionValue.As<v8::Function>();
97 return V8ScriptRunner::callInternalFunction(function, undefined, numArgs , args, isolate);
98 }
71 }; 99 };
72 100
73 } // namespace blink 101 } // namespace blink
74 102
75 #endif // V8ScriptRunner_h 103 #endif // V8ScriptRunner_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine