1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsCycleCollectionTraversalCallback_h__
8 #define nsCycleCollectionTraversalCallback_h__
13 class nsCycleCollectionParticipant
;
21 class NS_NO_VTABLE nsCycleCollectionTraversalCallback
{
23 // You must call DescribeRefCountedNode() with an accurate
24 // refcount, otherwise cycle collection will fail, and probably crash.
25 // If the callback cares about objname, it should put
26 // WANT_DEBUG_INFO in mFlags.
28 DescribeRefCountedNode(nsrefcnt aRefcount
, const char* aObjName
) = 0;
29 // Note, aCompartmentAddress is 0 if it is unknown.
31 DescribeGCedNode(bool aIsMarked
, const char* aObjName
,
32 uint64_t aCompartmentAddress
= 0) = 0;
34 NS_IMETHOD_(void) NoteXPCOMChild(nsISupports
* aChild
) = 0;
35 NS_IMETHOD_(void) NoteJSChild(JS::GCCellPtr aThing
) = 0;
37 NoteNativeChild(void* aChild
, nsCycleCollectionParticipant
* aHelper
) = 0;
40 NoteWeakMapping(JSObject
* aKey
, nsISupports
* aVal
,
41 nsCycleCollectionParticipant
* aValParticipant
) = 0;
43 // Give a name to the edge associated with the next call to
44 // NoteXPCOMChild, NoteJSObject, NoteJSScript, or NoteNativeChild.
45 // Callbacks who care about this should set WANT_DEBUG_INFO in the
47 NS_IMETHOD_(void) NoteNextEdgeName(const char* aName
) = 0;
52 // Caller should call NoteNextEdgeName and pass useful objName
53 // to DescribeRefCountedNode and DescribeGCedNode.
54 WANT_DEBUG_INFO
= (1 << 0),
56 // Caller should not skip objects that we know will be
58 WANT_ALL_TRACES
= (1 << 1)
60 uint32_t Flags() const { return mFlags
; }
61 bool WantDebugInfo() const { return (mFlags
& WANT_DEBUG_INFO
) != 0; }
62 bool WantAllTraces() const { return (mFlags
& WANT_ALL_TRACES
) != 0; }
65 nsCycleCollectionTraversalCallback() : mFlags(0) {}
70 #endif // nsCycleCollectionTraversalCallback_h__