OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "bindings/core/v8/CompiledScript.h" |
| 6 |
| 7 #include "bindings/core/v8/V8Binding.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 CompiledScript::CompiledScript(ExecutionContext* context, |
| 12 v8::Local<v8::Script> script, |
| 13 const ScriptSourceCode& sourceCode) |
| 14 : ContextLifecycleObserver(context), |
| 15 m_sourceCode(sourceCode), |
| 16 m_script(toIsolate(context), script) { |
| 17 DCHECK(!script.IsEmpty()); |
| 18 } |
| 19 |
| 20 CompiledScript::~CompiledScript() = default; |
| 21 |
| 22 v8::Local<v8::Script> CompiledScript::getScript( |
| 23 ExecutionContext* executionContext) const { |
| 24 if (executionContext != getExecutionContext()) |
| 25 return v8::Local<v8::Script>(); |
| 26 return m_script.Get(toIsolate(executionContext)); |
| 27 } |
| 28 |
| 29 void CompiledScript::contextDestroyed(ExecutionContext*) { |
| 30 // Dump the persistent handle to the script. This prevents there from being |
| 31 // an ownership cycle that keeps the context alive. |
| 32 m_script.Reset(); |
| 33 } |
| 34 |
| 35 } // namespace blink |
OLD | NEW |