Chromium Code Reviews| 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 ScriptWrappableHeapTracer_h | |
| 6 #define ScriptWrappableHeapTracer_h | |
| 7 | |
| 8 #include "bindings/core/v8/DOMWrapperWorld.h" | |
| 9 #include <v8.h> | |
| 10 #include <vector> | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 class HeapObjectHeader; | |
| 15 | |
| 16 /** | |
| 17 * When this heap tracer is set to the v8::Isolate, the V8 will call it during | |
| 18 * its garbage collection. At the beginning, it will call TraceRoots, then | |
| 19 * repeatedly (as v8 discovers more wrappers) it will call TraceWrappableFrom, | |
| 20 * and at the end it will call ClearTracingMarks. | |
| 21 */ | |
| 22 class ScriptWrappableHeapTracer : public v8::EmbedderHeapTracer { | |
| 23 public: | |
| 24 ~ScriptWrappableHeapTracer() override; | |
| 25 void TraceRoots(v8::Isolate*) override; | |
| 26 void TraceWrappableFrom(v8::Isolate*, const std::vector<std::pair<void*, voi d*>>& internalFieldsOfPotentialWrappers) override; | |
| 27 void TraceWrappableFrom(v8::Isolate*, v8::Persistent<v8::Object>* wrapper); | |
| 28 void AddHeaderToUnmark(HeapObjectHeader*); | |
| 29 void ClearTracingMarks(v8::Isolate*) override; | |
| 30 static void markWrapper(const ScriptWrappable*, v8::Isolate*); | |
| 31 static void markWrapper(const v8::Persistent<v8::Object>& handle, v8::Isolat e*); | |
| 32 private: | |
| 33 class ExternalReferenceRegisteringVisitor : public DOMWrapperWorldVisitor { | |
| 34 STACK_ALLOCATED(); | |
| 35 public: | |
| 36 ExternalReferenceRegisteringVisitor(ScriptWrappable* scriptWrappable, v8 ::Isolate* isolate) | |
| 37 : m_scriptWrappable(scriptWrappable) | |
| 38 , m_isolate(isolate) | |
| 39 {} | |
| 40 void visit(DOMWrapperWorld&) override; | |
| 41 private: | |
| 42 ScriptWrappable* m_scriptWrappable; | |
| 43 v8::Isolate* m_isolate; | |
| 44 }; | |
| 45 void TraceWrappableFrom(v8::Isolate*, std::pair<void*, void*> internalFields ); | |
| 46 bool m_tracingInProgress = false; | |
| 47 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.
| |
| 48 }; | |
| 49 | |
| 50 } // namespace blink | |
| 51 | |
| 52 #endif // ScriptWrappableHeapTracer_h | |
| OLD | NEW |