| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef TRACEIMPL_OVERLOADED_H_ | 5 #ifndef TRACEIMPL_OVERLOADED_H_ |
| 6 #define TRACEIMPL_OVERLOADED_H_ | 6 #define TRACEIMPL_OVERLOADED_H_ |
| 7 | 7 |
| 8 #include "heap/stubs.h" | 8 #include "heap/stubs.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 class X : public GarbageCollected<X> { | 12 class X : public GarbageCollected<X> { |
| 13 public: | 13 public: |
| 14 void Trace(Visitor*) {} | 14 void Trace(Visitor*) {} |
| 15 void Trace(InlinedGlobalMarkingVisitor) {} | |
| 16 }; | 15 }; |
| 17 | 16 |
| 18 class InlinedBase : public GarbageCollected<InlinedBase> { | 17 class InlinedBase : public GarbageCollected<InlinedBase> { |
| 19 public: | 18 public: |
| 20 virtual void Trace(Visitor* visitor) { TraceImpl(visitor); } | 19 virtual void Trace(Visitor* visitor) { visitor->Trace(x_base_); } |
| 21 virtual void Trace(InlinedGlobalMarkingVisitor visitor) { | |
| 22 TraceImpl(visitor); | |
| 23 } | |
| 24 | 20 |
| 25 private: | 21 private: |
| 26 template <typename VisitorDispatcher> | |
| 27 void TraceImpl(VisitorDispatcher visitor) { visitor->Trace(x_base_); } | |
| 28 | |
| 29 Member<X> x_base_; | 22 Member<X> x_base_; |
| 30 }; | 23 }; |
| 31 | 24 |
| 32 class InlinedDerived : public InlinedBase { | 25 class InlinedDerived : public InlinedBase { |
| 33 public: | 26 public: |
| 34 void Trace(Visitor* visitor) override { TraceImpl(visitor); } | 27 void Trace(Visitor* visitor) override { |
| 35 void Trace(InlinedGlobalMarkingVisitor visitor) override { | |
| 36 TraceImpl(visitor); | |
| 37 } | |
| 38 | |
| 39 private: | |
| 40 template <typename VisitorDispatcher> | |
| 41 void TraceImpl(VisitorDispatcher visitor) { | |
| 42 visitor->Trace(x_derived_); | 28 visitor->Trace(x_derived_); |
| 43 InlinedBase::Trace(visitor); | 29 InlinedBase::Trace(visitor); |
| 44 } | 30 } |
| 45 | 31 |
| 46 Member<X> x_derived_; | 32 Member<X> x_derived_; |
| 47 }; | 33 }; |
| 48 | 34 |
| 49 class ExternBase : public GarbageCollected<ExternBase> { | 35 class ExternBase : public GarbageCollected<ExternBase> { |
| 50 public: | 36 public: |
| 51 virtual void Trace(Visitor*); | 37 virtual void Trace(Visitor*); |
| 52 virtual void Trace(InlinedGlobalMarkingVisitor); | |
| 53 | 38 |
| 54 private: | 39 private: |
| 55 template <typename VisitorDispatcher> | |
| 56 void TraceImpl(VisitorDispatcher); | |
| 57 | |
| 58 Member<X> x_base_; | 40 Member<X> x_base_; |
| 59 }; | 41 }; |
| 60 | 42 |
| 61 class ExternDerived : public ExternBase { | 43 class ExternDerived : public ExternBase { |
| 62 public: | 44 public: |
| 63 void Trace(Visitor*) override; | 45 void Trace(Visitor*) override; |
| 64 void Trace(InlinedGlobalMarkingVisitor) override; | |
| 65 | 46 |
| 66 private: | 47 private: |
| 67 template <typename VisitorDispatcher> | |
| 68 void TraceImpl(VisitorDispatcher); | |
| 69 | |
| 70 Member<X> x_derived_; | 48 Member<X> x_derived_; |
| 71 }; | 49 }; |
| 72 | 50 |
| 73 } | 51 } |
| 74 | 52 |
| 75 #endif // TRACEIMPL_OVERLOADED_H_ | 53 #endif // TRACEIMPL_OVERLOADED_H_ |
| OLD | NEW |