Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/CompiledScript.h

Issue 2564903002: ScriptController: Expose methods to compile a script and execute a compiled script. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/CompiledScript.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/CompiledScript.h b/third_party/WebKit/Source/bindings/core/v8/CompiledScript.h
new file mode 100644
index 0000000000000000000000000000000000000000..7a05fb5b59bee6ec6e299dd23bab2ede4b4b549b
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/CompiledScript.h
@@ -0,0 +1,49 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CompiledScript_h
+#define CompiledScript_h
+
+#include "bindings/core/v8/ScriptSourceCode.h"
+#include "platform/heap/GarbageCollected.h"
+#include "wtf/Assertions.h"
+#include "wtf/text/TextPosition.h"
+
+#include <v8.h>
+
+namespace blink {
+
+// This wraps a global handle on a V8 object (the compiled script).
+// Because that script may contain further references to other objects, do not
+// keep long-lasting references to this object, as they may induce cycles
+// between V8 and Oilpan.
+class CompiledScript : public GarbageCollectedFinalized<CompiledScript> {
+ public:
+ CompiledScript(v8::Isolate* isolate,
+ v8::Local<v8::Script> script,
+ const ScriptSourceCode& sourceCode)
+ : m_sourceCode(sourceCode), m_script(isolate, script) {
+ DCHECK(!script.IsEmpty());
+ }
+
+ v8::Local<v8::Script> script(v8::Isolate* isolate) const {
+ return m_script.Get(isolate);
+ }
+
+ const ScriptSourceCode& sourceCode() const { return m_sourceCode; }
+ const KURL& url() const { return m_sourceCode.url(); }
+ const TextPosition& startPosition() const {
+ return m_sourceCode.startPosition();
+ }
+
+ DEFINE_INLINE_TRACE() { visitor->trace(m_sourceCode); }
+
+ private:
+ ScriptSourceCode m_sourceCode;
+ v8::Global<v8::Script> m_script;
+};
+
+} // namespace blink
+
+#endif // CompiledScript_h

Powered by Google App Engine
This is Rietveld 408576698