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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScopedPersistent.h

Issue 2474693002: [wrapper-tracing] Support for incrementally tracing ScopedPersistent (Closed)
Patch Set: Added bailout for tests when the flag is off Created 4 years, 1 month 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptWrappable.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/ScopedPersistent.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScopedPersistent.h b/third_party/WebKit/Source/bindings/core/v8/ScopedPersistent.h
index 25333d7e640018e81a364407ee05d57f084327d6..844f5ba5057da806a31cba6e12e1da3a96d61fe0 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScopedPersistent.h
+++ b/third_party/WebKit/Source/bindings/core/v8/ScopedPersistent.h
@@ -31,6 +31,7 @@
#ifndef ScopedPersistent_h
#define ScopedPersistent_h
+#include "bindings/core/v8/ScriptWrappableVisitor.h"
#include "wtf/Allocator.h"
#include "wtf/Noncopyable.h"
#include <memory>
@@ -55,7 +56,7 @@ class ScopedPersistent {
m_handle.Reset(isolate, local);
}
- ~ScopedPersistent() { clear(); }
+ virtual ~ScopedPersistent() { clear(); }
ALWAYS_INLINE v8::Local<T> newLocal(v8::Isolate* isolate) const {
return v8::Local<T>::New(isolate, m_handle);
@@ -79,7 +80,7 @@ class ScopedPersistent {
bool isEmpty() const { return m_handle.IsEmpty(); }
bool isWeak() const { return m_handle.IsWeak(); }
- void set(v8::Isolate* isolate, v8::Local<T> handle) {
+ virtual void set(v8::Isolate* isolate, v8::Local<T> handle) {
m_handle.Reset(isolate, handle);
}
@@ -112,6 +113,42 @@ class ScopedPersistent {
v8::Persistent<T> m_handle;
};
+/**
+ * TraceWrapperV8Reference is used to trace from Blink to V8.
+ *
+ * TODO(mlippautz): Once shipped, create a separate type with a more
+ * appropriate handle type than v8::Persistent. The handle should have regular
+ * tracing semantics, i.e., only hold strongly on to an object if reached
+ * through tracing.
+ */
+template <typename T>
+class TraceWrapperV8Reference : public ScopedPersistent<T> {
+ public:
+ explicit TraceWrapperV8Reference(void* parent)
+ : ScopedPersistent<T>(), m_parent(parent) {}
+
+ TraceWrapperV8Reference(v8::Isolate* isolate,
+ void* parent,
+ v8::Local<T> handle)
+ : ScopedPersistent<T>(isolate, handle), m_parent(parent) {
+ ScriptWrappableVisitor::writeBarrier(m_parent, &cast<v8::Value>());
+ }
+
+ void set(v8::Isolate* isolate, v8::Local<T> handle) override {
+ ScopedPersistent<T>::set(isolate, handle);
+ ScriptWrappableVisitor::writeBarrier(m_parent, &cast<v8::Value>());
+ }
+
+ template <typename S>
+ const TraceWrapperV8Reference<S>& cast() const {
+ return reinterpret_cast<const TraceWrapperV8Reference<S>&>(
+ const_cast<const TraceWrapperV8Reference<T>&>(*this));
+ }
+
+ private:
+ void* m_parent;
+};
+
} // namespace blink
#endif // ScopedPersistent_h
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptWrappable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698