Roll src/third_party/WebKit d10c917:a1123a1 (svn 198729:198730)
[chromium-blink-merge.git] / tools / clang / blink_gc_plugin / tests / trace_after_dispatch_impl.h
blobfe25279512c636f7c9ece4b45cc8e1fee55d7862
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.
5 #ifndef TRACE_AFTER_DISPATCH_IMPL_H_
6 #define TRACE_AFTER_DISPATCH_IMPL_H_
8 #include "heap/stubs.h"
10 namespace blink {
12 class X : public GarbageCollected<X> {
13 public:
14 void trace(Visitor*) {}
17 enum ClassTag {
18 BASE, DERIVED
21 class TraceAfterDispatchInlinedBase
22 : public GarbageCollected<TraceAfterDispatchInlinedBase> {
23 public:
24 explicit TraceAfterDispatchInlinedBase(ClassTag tag) : tag_(tag) {}
26 void trace(Visitor* visitor) { traceImpl(visitor); }
27 void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); }
29 void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); }
30 void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) {
31 traceAfterDispatchImpl(visitor);
34 private:
35 template <typename VisitorDispatcher>
36 void traceImpl(VisitorDispatcher visitor);
38 template <typename VisitorDispatcher>
39 void traceAfterDispatchImpl(VisitorDispatcher visitor) {
40 visitor->trace(x_base_);
43 ClassTag tag_;
44 Member<X> x_base_;
47 class TraceAfterDispatchInlinedDerived : public TraceAfterDispatchInlinedBase {
48 public:
49 TraceAfterDispatchInlinedDerived() : TraceAfterDispatchInlinedBase(DERIVED) {}
51 void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); }
52 void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) {
53 traceAfterDispatchImpl(visitor);
56 private:
57 template <typename VisitorDispatcher>
58 void traceAfterDispatchImpl(VisitorDispatcher visitor) {
59 visitor->trace(x_derived_);
60 TraceAfterDispatchInlinedBase::traceAfterDispatch(visitor);
63 Member<X> x_derived_;
66 class TraceAfterDispatchExternBase
67 : public GarbageCollected<TraceAfterDispatchExternBase> {
68 public:
69 explicit TraceAfterDispatchExternBase(ClassTag tag) : tag_(tag) {}
71 void trace(Visitor* visitor);
72 void trace(InlinedGlobalMarkingVisitor visitor);
74 void traceAfterDispatch(Visitor* visitor);
75 void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor);
77 private:
78 template <typename VisitorDispatcher>
79 void traceImpl(VisitorDispatcher visitor);
81 template <typename VisitorDispatcher>
82 void traceAfterDispatchImpl(VisitorDispatcher visitor);
84 ClassTag tag_;
85 Member<X> x_base_;
88 class TraceAfterDispatchExternDerived : public TraceAfterDispatchExternBase {
89 public:
90 TraceAfterDispatchExternDerived() : TraceAfterDispatchExternBase(DERIVED) {}
92 void traceAfterDispatch(Visitor* visitor);
93 void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor);
95 private:
96 template <typename VisitorDispatcher>
97 void traceAfterDispatchImpl(VisitorDispatcher visitor);
99 Member<X> x_derived_;
104 #endif // TRACE_AFTER_DISPATCH_IMPL_H_