michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsCycleCollectionTraversalCallback_h__ michael@0: #define nsCycleCollectionTraversalCallback_h__ michael@0: michael@0: #include "nsISupports.h" michael@0: michael@0: class nsCycleCollectionParticipant; michael@0: michael@0: class NS_NO_VTABLE nsCycleCollectionTraversalCallback michael@0: { michael@0: public: michael@0: // You must call DescribeRefCountedNode() with an accurate michael@0: // refcount, otherwise cycle collection will fail, and probably crash. michael@0: // If the callback cares about objname, it should put michael@0: // WANT_DEBUG_INFO in mFlags. michael@0: NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refcount, michael@0: const char* objname) = 0; michael@0: // Note, aCompartmentAddress is 0 if it is unknown. michael@0: NS_IMETHOD_(void) DescribeGCedNode(bool ismarked, michael@0: const char* objname, michael@0: uint64_t aCompartmentAddress = 0) = 0; michael@0: michael@0: NS_IMETHOD_(void) NoteXPCOMChild(nsISupports *child) = 0; michael@0: NS_IMETHOD_(void) NoteJSChild(void *child) = 0; michael@0: NS_IMETHOD_(void) NoteNativeChild(void *child, michael@0: nsCycleCollectionParticipant *helper) = 0; michael@0: michael@0: // Give a name to the edge associated with the next call to michael@0: // NoteXPCOMChild, NoteJSChild, or NoteNativeChild. michael@0: // Callbacks who care about this should set WANT_DEBUG_INFO in the michael@0: // flags. michael@0: NS_IMETHOD_(void) NoteNextEdgeName(const char* name) = 0; michael@0: michael@0: enum { michael@0: // Values for flags: michael@0: michael@0: // Caller should call NoteNextEdgeName and pass useful objName michael@0: // to DescribeRefCountedNode and DescribeGCedNode. michael@0: WANT_DEBUG_INFO = (1<<0), michael@0: michael@0: // Caller should not skip objects that we know will be michael@0: // uncollectable. michael@0: WANT_ALL_TRACES = (1<<1) michael@0: }; michael@0: uint32_t Flags() const { return mFlags; } michael@0: bool WantDebugInfo() const { return (mFlags & WANT_DEBUG_INFO) != 0; } michael@0: bool WantAllTraces() const { return (mFlags & WANT_ALL_TRACES) != 0; } michael@0: protected: michael@0: nsCycleCollectionTraversalCallback() : mFlags(0) {} michael@0: michael@0: uint32_t mFlags; michael@0: }; michael@0: michael@0: #endif // nsCycleCollectionTraversalCallback_h__