|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsCycleCollectionTraversalCallback_h__ |
|
7 #define nsCycleCollectionTraversalCallback_h__ |
|
8 |
|
9 #include "nsISupports.h" |
|
10 |
|
11 class nsCycleCollectionParticipant; |
|
12 |
|
13 class NS_NO_VTABLE nsCycleCollectionTraversalCallback |
|
14 { |
|
15 public: |
|
16 // You must call DescribeRefCountedNode() with an accurate |
|
17 // refcount, otherwise cycle collection will fail, and probably crash. |
|
18 // If the callback cares about objname, it should put |
|
19 // WANT_DEBUG_INFO in mFlags. |
|
20 NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refcount, |
|
21 const char* objname) = 0; |
|
22 // Note, aCompartmentAddress is 0 if it is unknown. |
|
23 NS_IMETHOD_(void) DescribeGCedNode(bool ismarked, |
|
24 const char* objname, |
|
25 uint64_t aCompartmentAddress = 0) = 0; |
|
26 |
|
27 NS_IMETHOD_(void) NoteXPCOMChild(nsISupports *child) = 0; |
|
28 NS_IMETHOD_(void) NoteJSChild(void *child) = 0; |
|
29 NS_IMETHOD_(void) NoteNativeChild(void *child, |
|
30 nsCycleCollectionParticipant *helper) = 0; |
|
31 |
|
32 // Give a name to the edge associated with the next call to |
|
33 // NoteXPCOMChild, NoteJSChild, or NoteNativeChild. |
|
34 // Callbacks who care about this should set WANT_DEBUG_INFO in the |
|
35 // flags. |
|
36 NS_IMETHOD_(void) NoteNextEdgeName(const char* name) = 0; |
|
37 |
|
38 enum { |
|
39 // Values for flags: |
|
40 |
|
41 // Caller should call NoteNextEdgeName and pass useful objName |
|
42 // to DescribeRefCountedNode and DescribeGCedNode. |
|
43 WANT_DEBUG_INFO = (1<<0), |
|
44 |
|
45 // Caller should not skip objects that we know will be |
|
46 // uncollectable. |
|
47 WANT_ALL_TRACES = (1<<1) |
|
48 }; |
|
49 uint32_t Flags() const { return mFlags; } |
|
50 bool WantDebugInfo() const { return (mFlags & WANT_DEBUG_INFO) != 0; } |
|
51 bool WantAllTraces() const { return (mFlags & WANT_ALL_TRACES) != 0; } |
|
52 protected: |
|
53 nsCycleCollectionTraversalCallback() : mFlags(0) {} |
|
54 |
|
55 uint32_t mFlags; |
|
56 }; |
|
57 |
|
58 #endif // nsCycleCollectionTraversalCallback_h__ |