1 // Copyright 2014 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 FINALIZE_AFTER_DISPATCH_H_ 6 #define FINALIZE_AFTER_DISPATCH_H_ 7 8 #include "heap/stubs.h" 9 10 namespace blink { 11 12 class NeedsFinalize : public GarbageCollectedFinalized<NeedsFinalize> { 13 public: 14 void Trace(Visitor*); 15 void TraceAfterDispatch(Visitor*); 16 // Needs a FinalizeGarbageCollectedObject method. 17 }; 18 19 class NeedsDispatch : public GarbageCollectedFinalized<NeedsDispatch> { 20 public: 21 void Trace(Visitor*); 22 // Needs a TraceAfterDispatch method. FinalizeGarbageCollectedObject()23 void FinalizeGarbageCollectedObject() { }; 24 }; 25 26 class NeedsFinalizedBase : public GarbageCollected<NeedsFinalizedBase> { 27 public: Trace(Visitor *)28 void Trace(Visitor*) { }; TraceAfterDispatch(Visitor *)29 void TraceAfterDispatch(Visitor*) { }; FinalizeGarbageCollectedObject()30 void FinalizeGarbageCollectedObject() { }; 31 }; 32 33 class A : GarbageCollectedFinalized<A> { 34 public: 35 void Trace(Visitor*); 36 void TraceAfterDispatch(Visitor*); 37 void FinalizeGarbageCollectedObject(); 38 protected: 39 enum Type { TB, TC, TD }; A(Type type)40 A(Type type) : m_type(type) { } 41 private: 42 Type m_type; 43 }; 44 45 class B : public A { 46 public: B()47 B() : A(TB) { } ~B()48 ~B() { } 49 void TraceAfterDispatch(Visitor*); 50 private: 51 Member<A> m_a; 52 }; 53 54 class C : public A { 55 public: C()56 C() : A(TC) { } 57 void TraceAfterDispatch(Visitor*); 58 private: 59 Member<A> m_a; 60 }; 61 62 // This class is considered abstract does not need to be dispatched to. 63 class Abstract : public A { 64 protected: Abstract(Type type)65 Abstract(Type type) : A(type) { } 66 }; 67 68 class D : public Abstract { 69 public: D()70 D() : Abstract(TD) { } 71 void TraceAfterDispatch(Visitor*); 72 private: 73 Member<A> m_a; 74 }; 75 76 } 77 78 #endif 79