| 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
|
|
|