| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright 2016 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 #ifndef CompiledScript_h | 
 |   6 #define CompiledScript_h | 
 |   7  | 
 |   8 #include "bindings/core/v8/ScriptSourceCode.h" | 
 |   9 #include "core/CoreExport.h" | 
 |  10 #include "core/dom/ContextLifecycleObserver.h" | 
 |  11 #include "platform/heap/GarbageCollected.h" | 
 |  12 #include "wtf/Assertions.h" | 
 |  13 #include "wtf/text/TextPosition.h" | 
 |  14  | 
 |  15 #include <v8.h> | 
 |  16  | 
 |  17 namespace blink { | 
 |  18  | 
 |  19 // This wraps a global handle on a V8 object (the compiled script). | 
 |  20 // It is tied to a particular ExecutionContext, and will clear the reference to | 
 |  21 // avoid long-lasting references which may induce cycles between V8 and Oilpan. | 
 |  22 class CORE_EXPORT CompiledScript final | 
 |  23     : public GarbageCollectedFinalized<CompiledScript>, | 
 |  24       public ContextLifecycleObserver { | 
 |  25   USING_GARBAGE_COLLECTED_MIXIN(CompiledScript); | 
 |  26  | 
 |  27  public: | 
 |  28   CompiledScript(ExecutionContext*, | 
 |  29                  v8::Local<v8::Script>, | 
 |  30                  const ScriptSourceCode&); | 
 |  31   ~CompiledScript(); | 
 |  32  | 
 |  33   // Callers must accept that this could return an empty handle. | 
 |  34   // For instance, the compiled script may have been destroyed due to context | 
 |  35   // shutdown, or the execution context may not match the one this is compiled | 
 |  36   // for. | 
 |  37   v8::Local<v8::Script> getScript(ExecutionContext*) const; | 
 |  38  | 
 |  39   const ScriptSourceCode& sourceCode() const { return m_sourceCode; } | 
 |  40   const KURL& url() const { return m_sourceCode.url(); } | 
 |  41   const TextPosition& startPosition() const { | 
 |  42     return m_sourceCode.startPosition(); | 
 |  43   } | 
 |  44  | 
 |  45   DEFINE_INLINE_TRACE() { | 
 |  46     ContextLifecycleObserver::trace(visitor); | 
 |  47     visitor->trace(m_sourceCode); | 
 |  48   } | 
 |  49  | 
 |  50   // ContextLifecycleObserver | 
 |  51   void contextDestroyed(ExecutionContext*) override; | 
 |  52  | 
 |  53  private: | 
 |  54   ScriptSourceCode m_sourceCode; | 
 |  55   v8::Global<v8::Script> m_script; | 
 |  56 }; | 
 |  57  | 
 |  58 }  // namespace blink | 
 |  59  | 
 |  60 #endif  // CompiledScript_h | 
| OLD | NEW |