cycle_super_neg.h revision effb81e5f8246d0db0270817048dc992db66e9fb
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. 4 5#ifndef CYCLE_SUPER_NEG_H_ 6#define CYCLE_SUPER_NEG_H_ 7 8#include "heap/stubs.h" 9 10namespace WebCore { 11 12class C; 13 14// The chain: 15// C -per-> B -sup-> A -sub-> D -ref-> C 16// is not a leaking cycle, because the super-class relationship 17// should not transitively imply sub-class relationships. 18// I.e. B -/-> D 19 20class A : public GarbageCollectedFinalized<A> { 21public: 22 virtual void trace(Visitor*) {} 23}; 24 25class B : public A { 26public: 27 virtual void trace(Visitor*); 28}; 29 30class C : public RefCounted<C> { 31private: 32 Persistent<B> m_b; 33}; 34 35class D : public A { 36public: 37 virtual void trace(Visitor*); 38private: 39 RefPtr<C> m_c; 40}; 41 42} 43 44#endif 45