1 // Copyright 2015 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 TRACEIMPL_DEPENDENT_SCOPE_H_ 6 #define TRACEIMPL_DEPENDENT_SCOPE_H_ 7 8 #include "heap/stubs.h" 9 10 namespace blink { 11 12 class X : public GarbageCollected<X> { 13 public: Trace(Visitor *)14 virtual void Trace(Visitor*) {} 15 }; 16 17 template <typename T> 18 class Base : public GarbageCollected<Base<T> > { 19 public: Trace(Visitor * visitor)20 virtual void Trace(Visitor* visitor) { TraceImpl(visitor); } Trace(InlinedGlobalMarkingVisitor visitor)21 virtual void Trace(InlinedGlobalMarkingVisitor visitor) { 22 TraceImpl(visitor); 23 } 24 25 private: 26 template <typename VisitorDispatcher> TraceImpl(VisitorDispatcher visitor)27 void TraceImpl(VisitorDispatcher visitor) {} 28 }; 29 30 template <typename T> 31 class Derived : public Base<T> { 32 public: Trace(Visitor * visitor)33 void Trace(Visitor* visitor) override { TraceImpl(visitor); } Trace(InlinedGlobalMarkingVisitor visitor)34 void Trace(InlinedGlobalMarkingVisitor visitor) override { 35 TraceImpl(visitor); 36 } 37 38 private: 39 template <typename VisitorDispatcher> TraceImpl(VisitorDispatcher visitor)40 void TraceImpl(VisitorDispatcher visitor) { 41 Base<T>::Trace(visitor); 42 } 43 }; 44 45 template <typename T> 46 class DerivedMissingTrace : public Base<T> { 47 public: Trace(Visitor * visitor)48 void Trace(Visitor* visitor) override { TraceImpl(visitor); } Trace(InlinedGlobalMarkingVisitor visitor)49 void Trace(InlinedGlobalMarkingVisitor visitor) override { 50 TraceImpl(visitor); 51 } 52 53 private: 54 template <typename VisitorDispatcher> TraceImpl(VisitorDispatcher visitor)55 void TraceImpl(VisitorDispatcher visitor) { 56 // Missing Base<T>::Trace(visitor). 57 } 58 }; 59 60 } 61 62 #endif // TRACEIMPL_DEPENDENT_SCOPE_H_ 63