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

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.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..ff6066015cf2c218d1c51b214aa69e54596fcd63
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/CompiledScript.h
@@ -0,0 +1,60 @@
+// 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 "core/CoreExport.h"
+#include "core/dom/ContextLifecycleObserver.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).
+// It is tied to a particular ExecutionContext, and will clear the reference to
+// avoid long-lasting references which may induce cycles between V8 and Oilpan.
+class CORE_EXPORT CompiledScript final
+ : public GarbageCollectedFinalized<CompiledScript>,
+ public ContextLifecycleObserver {
+ USING_GARBAGE_COLLECTED_MIXIN(CompiledScript);
+
+ public:
+ CompiledScript(ExecutionContext*,
+ v8::Local<v8::Script>,
+ const ScriptSourceCode&);
+ ~CompiledScript();
+
+ // Callers must accept that this could return an empty handle.
+ // For instance, the compiled script may have been destroyed due to context
+ // shutdown, or the execution context may not match the one this is compiled
+ // for.
+ v8::Local<v8::Script> getScript(ExecutionContext*) const;
+
+ 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() {
+ ContextLifecycleObserver::trace(visitor);
+ visitor->trace(m_sourceCode);
+ }
+
+ // ContextLifecycleObserver
+ void contextDestroyed(ExecutionContext*) override;
+
+ private:
+ ScriptSourceCode m_sourceCode;
+ v8::Global<v8::Script> m_script;
+};
+
+} // namespace blink
+
+#endif // CompiledScript_h
« no previous file with comments | « third_party/WebKit/Source/bindings/bindings.gni ('k') | third_party/WebKit/Source/bindings/core/v8/CompiledScript.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698