Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.h |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.h b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f1ee9ed49c04413376abab1326439e842e440740 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.h |
| @@ -0,0 +1,52 @@ |
| +// 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 ScriptWrappableHeapTracer_h |
| +#define ScriptWrappableHeapTracer_h |
| + |
| +#include "bindings/core/v8/DOMWrapperWorld.h" |
| +#include <v8.h> |
| +#include <vector> |
| + |
| +namespace blink { |
| + |
| +class HeapObjectHeader; |
| + |
| +/** |
| + * When this heap tracer is set to the v8::Isolate, the V8 will call it during |
| + * its garbage collection. At the beginning, it will call TraceRoots, then |
| + * repeatedly (as v8 discovers more wrappers) it will call TraceWrappableFrom, |
| + * and at the end it will call ClearTracingMarks. |
| + */ |
| +class ScriptWrappableHeapTracer : public v8::EmbedderHeapTracer { |
| +public: |
| + ~ScriptWrappableHeapTracer() override; |
| + void TraceRoots(v8::Isolate*) override; |
| + void TraceWrappableFrom(v8::Isolate*, const std::vector<std::pair<void*, void*>>& internalFieldsOfPotentialWrappers) override; |
| + void TraceWrappableFrom(v8::Isolate*, v8::Persistent<v8::Object>* wrapper); |
| + void AddHeaderToUnmark(HeapObjectHeader*); |
| + void ClearTracingMarks(v8::Isolate*) override; |
| + static void markWrapper(const ScriptWrappable*, v8::Isolate*); |
| + static void markWrapper(const v8::Persistent<v8::Object>& handle, v8::Isolate*); |
| +private: |
| + class ExternalReferenceRegisteringVisitor : public DOMWrapperWorldVisitor { |
| + STACK_ALLOCATED(); |
| + public: |
| + ExternalReferenceRegisteringVisitor(ScriptWrappable* scriptWrappable, v8::Isolate* isolate) |
| + : m_scriptWrappable(scriptWrappable) |
| + , m_isolate(isolate) |
| + {} |
| + void visit(DOMWrapperWorld&) override; |
| + private: |
| + ScriptWrappable* m_scriptWrappable; |
| + v8::Isolate* m_isolate; |
| + }; |
| + void TraceWrappableFrom(v8::Isolate*, std::pair<void*, void*> internalFields); |
| + bool m_tracingInProgress = false; |
| + std::vector<HeapObjectHeader*> m_headersToUnmark; |
|
haraken
2016/04/18 04:35:42
std::vector is not allowed in Blink. Use WTF::Vect
haraken
2016/04/18 04:35:42
Add a comment why it's safe to hold raw pointers t
Marcel Hlopko
2016/04/18 11:45:35
Done.
|
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // ScriptWrappableHeapTracer_h |