• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_OVERLOADED_H_
6 #define TRACEIMPL_OVERLOADED_H_
7 
8 #include "heap/stubs.h"
9 
10 namespace blink {
11 
12 class X : public GarbageCollected<X> {
13  public:
Trace(Visitor *)14   void Trace(Visitor*) {}
Trace(InlinedGlobalMarkingVisitor)15   void Trace(InlinedGlobalMarkingVisitor) {}
16 };
17 
18 class InlinedBase : public GarbageCollected<InlinedBase> {
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) { visitor->Trace(x_base_); }
28 
29   Member<X> x_base_;
30 };
31 
32 class InlinedDerived : public InlinedBase {
33  public:
Trace(Visitor * visitor)34   void Trace(Visitor* visitor) override { TraceImpl(visitor); }
Trace(InlinedGlobalMarkingVisitor visitor)35   void Trace(InlinedGlobalMarkingVisitor visitor) override {
36     TraceImpl(visitor);
37   }
38 
39  private:
40   template <typename VisitorDispatcher>
TraceImpl(VisitorDispatcher visitor)41   void TraceImpl(VisitorDispatcher visitor) {
42     visitor->Trace(x_derived_);
43     InlinedBase::Trace(visitor);
44   }
45 
46   Member<X> x_derived_;
47 };
48 
49 class ExternBase : public GarbageCollected<ExternBase> {
50  public:
51   virtual void Trace(Visitor*);
52   virtual void Trace(InlinedGlobalMarkingVisitor);
53 
54  private:
55   template <typename VisitorDispatcher>
56   void TraceImpl(VisitorDispatcher);
57 
58   Member<X> x_base_;
59 };
60 
61 class ExternDerived : public ExternBase {
62  public:
63   void Trace(Visitor*) override;
64   void Trace(InlinedGlobalMarkingVisitor) override;
65 
66  private:
67   template <typename VisitorDispatcher>
68   void TraceImpl(VisitorDispatcher);
69 
70   Member<X> x_derived_;
71 };
72 
73 }
74 
75 #endif  // TRACEIMPL_OVERLOADED_H_
76