OLD | NEW |
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 |
(...skipping 14 matching lines...) Expand all Loading... |
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" | 29 #include "bindings/core/v8/ScriptState.h" |
30 #include "bindings/core/v8/ScriptValue.h" | 30 #include "bindings/core/v8/ScriptValue.h" |
31 #include "bindings/core/v8/V8BindingMacros.h" | 31 #include "bindings/core/v8/V8BindingMacros.h" |
32 #include "bindings/core/v8/V8CacheOptions.h" | 32 #include "bindings/core/v8/V8CacheOptions.h" |
33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
34 #include "core/fetch/AccessControlStatus.h" | 34 #include "core/fetch/AccessControlStatus.h" |
35 #include "platform/text/CompressibleString.h" | |
36 #include "wtf/Allocator.h" | 35 #include "wtf/Allocator.h" |
37 #include "wtf/text/TextPosition.h" | 36 #include "wtf/text/TextPosition.h" |
38 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
39 #include <v8.h> | 38 #include <v8.h> |
40 | 39 |
41 namespace blink { | 40 namespace blink { |
42 | 41 |
43 class CachedMetadataHandler; | 42 class CachedMetadataHandler; |
44 class Resource; | 43 class Resource; |
45 class ScriptResource; | 44 class ScriptResource; |
46 class ScriptSourceCode; | 45 class ScriptSourceCode; |
47 class ExecutionContext; | 46 class ExecutionContext; |
48 class ScriptStreamer; | 47 class ScriptStreamer; |
49 | 48 |
50 class CORE_EXPORT V8ScriptRunner final { | 49 class CORE_EXPORT V8ScriptRunner final { |
51 STATIC_ONLY(V8ScriptRunner); | 50 STATIC_ONLY(V8ScriptRunner); |
52 public: | 51 public: |
53 // For the following methods, the caller sites have to hold | 52 // For the following methods, the caller sites have to hold |
54 // a HandleScope and a ContextScope. | 53 // a HandleScope and a ContextScope. |
55 static v8::MaybeLocal<v8::Script> compileScript(const ScriptSourceCode&, v8:
:Isolate*, AccessControlStatus = SharableCrossOrigin, V8CacheOptions = V8CacheOp
tionsDefault); | 54 static v8::MaybeLocal<v8::Script> compileScript(const ScriptSourceCode&, v8:
:Isolate*, AccessControlStatus = SharableCrossOrigin, V8CacheOptions = V8CacheOp
tionsDefault); |
56 static v8::MaybeLocal<v8::Script> compileScript(const CompressibleString&, c
onst String& fileName, const String& sourceMapUrl, const TextPosition&, v8::Isol
ate*, CachedMetadataHandler* = nullptr, AccessControlStatus = SharableCrossOrigi
n, V8CacheOptions = V8CacheOptionsDefault); | 55 static v8::MaybeLocal<v8::Script> compileScript(const String&, const String&
fileName, const String& sourceMapUrl, const TextPosition&, v8::Isolate*, Cached
MetadataHandler* = nullptr, AccessControlStatus = SharableCrossOrigin, V8CacheOp
tions = V8CacheOptionsDefault); |
57 // CachedMetadataHandler is set when metadata caching is supported. For | 56 // CachedMetadataHandler is set when metadata caching is supported. For |
58 // normal scripe resources, CachedMetadataHandler is from ScriptResource. | 57 // normal scripe resources, CachedMetadataHandler is from ScriptResource. |
59 // For worker script, ScriptResource is null but CachedMetadataHandler may b
e | 58 // For worker script, ScriptResource is null but CachedMetadataHandler may b
e |
60 // set. When ScriptStreamer is set, ScriptResource must be set. | 59 // set. When ScriptStreamer is set, ScriptResource must be set. |
61 static v8::MaybeLocal<v8::Script> compileScript(v8::Local<v8::String>, const
String& fileName, const String& sourceMapUrl, const TextPosition&, v8::Isolate*
, ScriptResource* = nullptr, ScriptStreamer* = nullptr, CachedMetadataHandler* =
nullptr, AccessControlStatus = SharableCrossOrigin, V8CacheOptions = V8CacheOpt
ionsDefault); | 60 static v8::MaybeLocal<v8::Script> compileScript(v8::Local<v8::String>, const
String& fileName, const String& sourceMapUrl, const TextPosition&, v8::Isolate*
, ScriptResource* = nullptr, ScriptStreamer* = nullptr, CachedMetadataHandler* =
nullptr, AccessControlStatus = SharableCrossOrigin, V8CacheOptions = V8CacheOpt
ionsDefault); |
62 static v8::MaybeLocal<v8::Value> runCompiledScript(v8::Isolate*, v8::Local<v
8::Script>, ExecutionContext*); | 61 static v8::MaybeLocal<v8::Value> runCompiledScript(v8::Isolate*, v8::Local<v
8::Script>, ExecutionContext*); |
63 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> compileAndRunInternalScript(v8::Local<v8::S
tring>, v8::Isolate*, const String& = String(), const TextPosition& = TextPositi
on()); |
64 static v8::MaybeLocal<v8::Value> runCompiledInternalScript(v8::Isolate*, v8:
:Local<v8::Script>); | 63 static v8::MaybeLocal<v8::Value> runCompiledInternalScript(v8::Isolate*, v8:
:Local<v8::Script>); |
65 static v8::MaybeLocal<v8::Value> callAsConstructor(v8::Isolate*, v8::Local<v
8::Object>, ExecutionContext*, int argc = 0, v8::Local<v8::Value> argv[] = 0); | 64 static v8::MaybeLocal<v8::Value> callAsConstructor(v8::Isolate*, v8::Local<v
8::Object>, ExecutionContext*, int argc = 0, v8::Local<v8::Value> argv[] = 0); |
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*); | 65 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*); |
(...skipping 30 matching lines...) Expand all Loading... |
97 if (functionValue.IsEmpty()) | 96 if (functionValue.IsEmpty()) |
98 return v8::MaybeLocal<v8::Value>(); | 97 return v8::MaybeLocal<v8::Value>(); |
99 v8::Local<v8::Function> function = functionValue.As<v8::Function>(); | 98 v8::Local<v8::Function> function = functionValue.As<v8::Function>(); |
100 return V8ScriptRunner::callInternalFunction(function, undefined, numArgs
, args, isolate); | 99 return V8ScriptRunner::callInternalFunction(function, undefined, numArgs
, args, isolate); |
101 } | 100 } |
102 }; | 101 }; |
103 | 102 |
104 } // namespace blink | 103 } // namespace blink |
105 | 104 |
106 #endif // V8ScriptRunner_h | 105 #endif // V8ScriptRunner_h |
OLD | NEW |