Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7901c785e37f5b25518baaae4f784d3379bff53b |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h |
| @@ -0,0 +1,55 @@ |
| +// 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 ScriptWrappableVisitor_h |
| +#define ScriptWrappableVisitor_h |
| + |
| +#include "platform/heap/HeapAllocator.h" |
| +#include <v8.h> |
| +#include <vector> |
| + |
| + |
| +namespace blink { |
| + |
| +class HeapObjectHeader; |
| +class ScriptWrappable; |
| +class ScriptWrappableHeapTracer; |
| +class NodeRareData; |
| + |
| +#define DECLARE_VIRTUAL_TRACE_WRAPPERS() \ |
|
haraken
2016/04/13 12:26:22
Add a comment how to use these macros, or add a li
|
| + virtual void traceWrappers(const ScriptWrappableVisitor*) const |
| + |
| +#define DECLARE_NONVIRTUAL_TRACE_WRAPPERS() \ |
| + void traceWrappers(const ScriptWrappableVisitor*) const |
| + |
| +#define OVERRIDE_TRACE_WRAPPERS() \ |
|
haraken
2016/04/13 12:26:22
Can we unify OVERRIDE_TRACE_WRAPPERS with DECLARE_
Marcel Hlopko
2016/04/14 16:39:08
oOn 2016/04/13 at 12:26:22, haraken wrote:
|
| + void traceWrappers(const ScriptWrappableVisitor*) const override; |
| + |
| +#define DEFINE_TRACE_WRAPPERS(T) \ |
| + void T::traceWrappers(const ScriptWrappableVisitor* visitor) const |
| + |
| +/** |
| + * Visitor able to trace through the script wrappable references. It is used |
|
haraken
2016/04/13 12:26:22
Visitor is able to
Marcel Hlopko
2016/04/14 16:39:08
Done.
|
| + * by the ScriptWrappableHeapTracer during V8 garbage collection. |
| + */ |
| +class ScriptWrappableVisitor { |
|
haraken
2016/04/13 12:26:22
Add STACK_ALLOCATED.
Marcel Hlopko
2016/04/14 16:39:08
Done.
|
| +public: |
| + ScriptWrappableVisitor(v8::Isolate* isolate, ScriptWrappableHeapTracer* tracer) |
| + : m_isolate(isolate) |
| + , m_tracer(tracer) |
| + {}; |
| + void trace(const ScriptWrappable* wrappable) const; |
| + void trace(const ScriptWrappable& wrappable) const; |
| + void trace(const NodeRareData* rareData) const; |
| + void mark(const ScriptWrappable* scriptWrappable) const; |
| + void mark(const void* garbageCollected) const; |
|
haraken
2016/04/13 12:26:22
I'd suggest consistently using "traceWrappers" and
Marcel Hlopko
2016/04/14 16:39:08
Done.
|
| + void markHandle(v8::Persistent<v8::Object>& handle) const; |
| +private: |
| + bool isMarked(const void* garbageCollected) const; |
| + v8::Isolate* m_isolate; |
| + ScriptWrappableHeapTracer* m_tracer; |
| +}; |
| + |
| +} |
| +#endif |