Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / tools / clang / blink_gc_plugin / tests / class_requires_finalization_field.h
blob33f43c20ad57bdea27b98b3b7d8721a4d3dcbb50
1 // Copyright 2014 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 CLASS_REQUIRES_FINALIZATION_H_
6 #define CLASS_REQUIRES_FINALIZATION_H_
8 #include "heap/stubs.h"
10 namespace blink {
12 class A : public GarbageCollected<A> {
13 public:
14 virtual void trace(Visitor*) { }
17 // Has a non-trivial dtor (user-declared).
18 class B {
19 public:
20 ~B() { }
21 void trace(Visitor*) { };
24 // Has a trivial dtor.
25 class C {
26 public:
27 void trace(Visitor*) { };
30 } // blink namespace
32 namespace WTF {
34 template<>
35 struct VectorTraits<blink::C> {
36 static const bool needsDestruction = false;
39 } // WTF namespace
41 namespace blink {
43 // Off-heap vectors always need to be finalized.
44 class NeedsFinalizer : public A, public ScriptWrappable {
45 public:
46 void trace(Visitor*);
47 private:
48 Vector<Member<A> > m_as;
51 // On-heap vectors with inlined objects that need destruction
52 // need to be finalized.
53 class AlsoNeedsFinalizer : public A {
54 public:
55 void trace(Visitor*);
56 private:
57 HeapVector<B, 10> m_bs;
60 // On-heap vectors with no inlined objects never need to be finalized.
61 class DoesNotNeedFinalizer : public A, public ScriptWrappable {
62 public:
63 void trace(Visitor*);
64 private:
65 HeapVector<B> m_bs;
68 // On-heap vectors with inlined objects that don't need destruction
69 // don't need to be finalized.
70 class AlsoDoesNotNeedFinalizer : public A, public ScriptWrappable {
71 public:
72 void trace(Visitor*);
73 private:
74 HeapVector<Member<A>, 10> m_as;
75 HeapVector<C, 10> m_cs;
80 #endif