Bug 1910362 - Create new Nimbus helper r=aaronmt,ohorvath
[gecko.git] / xpcom / base / nsCycleCollectionTraversalCallback.h
blob9317a5e23a4a195a486d909b74fad4a0e48d9fd3
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__
10 #include <cstdint>
11 #include "nscore.h"
13 class nsCycleCollectionParticipant;
14 class nsISupports;
15 class JSObject;
17 namespace JS {
18 class GCCellPtr;
21 class NS_NO_VTABLE nsCycleCollectionTraversalCallback {
22 public:
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.
27 NS_IMETHOD_(void)
28 DescribeRefCountedNode(nsrefcnt aRefcount, const char* aObjName) = 0;
29 // Note, aCompartmentAddress is 0 if it is unknown.
30 NS_IMETHOD_(void)
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;
36 NS_IMETHOD_(void)
37 NoteNativeChild(void* aChild, nsCycleCollectionParticipant* aHelper) = 0;
39 NS_IMETHOD_(void)
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
46 // flags.
47 NS_IMETHOD_(void) NoteNextEdgeName(const char* aName) = 0;
49 enum {
50 // Values for flags:
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
57 // uncollectable.
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; }
64 protected:
65 nsCycleCollectionTraversalCallback() : mFlags(0) {}
67 uint32_t mFlags;
70 #endif // nsCycleCollectionTraversalCallback_h__