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_OMITTED_TRACE_H_ | 5 #ifndef TRACEIMPL_OMITTED_TRACE_H_ |
6 #define TRACEIMPL_OMITTED_TRACE_H_ | 6 #define TRACEIMPL_OMITTED_TRACE_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 A : public GarbageCollected<A> { | 12 class A : public GarbageCollected<A> { |
13 public: | 13 public: |
14 virtual void Trace(Visitor* visitor) { TraceImpl(visitor); } | 14 virtual void Trace(Visitor* visitor) {} |
15 virtual void Trace(InlinedGlobalMarkingVisitor visitor) { | |
16 TraceImpl(visitor); | |
17 } | |
18 | |
19 private: | |
20 template <typename VisitorDispatcher> | |
21 void TraceImpl(VisitorDispatcher visitor) {} | |
22 }; | 15 }; |
23 | 16 |
24 class B : public A { | 17 class B : public A { |
25 // Trace() isn't necessary because we've got nothing to trace here. | 18 // Trace() isn't necessary because we've got nothing to trace here. |
26 }; | 19 }; |
27 | 20 |
28 class C : public B { | 21 class C : public B { |
29 public: | 22 public: |
30 void Trace(Visitor* visitor) override { TraceImpl(visitor); } | 23 void Trace(Visitor* visitor) override { |
31 void Trace(InlinedGlobalMarkingVisitor visitor) override { | |
32 TraceImpl(visitor); | |
33 } | |
34 | |
35 private: | |
36 template <typename VisitorDispatcher> | |
37 void TraceImpl(VisitorDispatcher visitor) { | |
38 // B::Trace() is actually A::Trace(), and in certain cases we only get | 24 // B::Trace() is actually A::Trace(), and in certain cases we only get |
39 // limited information like "there is a function call that will be resolved | 25 // limited information like "there is a function call that will be resolved |
40 // to A::Trace()". We still want to mark B as Traced. | 26 // to A::Trace()". We still want to mark B as Traced. |
41 B::Trace(visitor); | 27 B::Trace(visitor); |
42 } | 28 } |
43 }; | 29 }; |
44 | 30 |
45 } | 31 } |
46 | 32 |
47 #endif // TRACEIMPL_OMITTED_TRACE_H_ | 33 #endif // TRACEIMPL_OMITTED_TRACE_H_ |
OLD | NEW |