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

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

Issue 2695713015: WIP: Reland CompiledScript, prototype compiling in a separate task.
Patch Set: allow fetchFinished to finish when there is no frame Created 3 years, 10 months 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.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/CompiledScript.cpp b/third_party/WebKit/Source/bindings/core/v8/CompiledScript.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3c03b0eac2fa1359f25e49024d97987f07529d02
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/CompiledScript.cpp
@@ -0,0 +1,35 @@
+// Copyright 2017 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.
+
+#include "bindings/core/v8/CompiledScript.h"
+
+#include "bindings/core/v8/V8Binding.h"
+
+namespace blink {
+
+CompiledScript::CompiledScript(ExecutionContext* context,
+ v8::Local<v8::Script> script,
+ const ScriptSourceCode& sourceCode)
+ : ContextLifecycleObserver(context),
+ m_sourceCode(sourceCode),
+ m_script(toIsolate(context), script) {
+ DCHECK(!script.IsEmpty());
+}
+
+CompiledScript::~CompiledScript() = default;
+
+v8::Local<v8::Script> CompiledScript::getScript(
+ ExecutionContext* executionContext) const {
+ if (executionContext != getExecutionContext())
+ return v8::Local<v8::Script>();
+ return m_script.Get(toIsolate(executionContext));
+}
+
+void CompiledScript::contextDestroyed(ExecutionContext*) {
+ // Dump the persistent handle to the script. This prevents there from being
+ // an ownership cycle that keeps the context alive.
+ m_script.Reset();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698