xpcom/glue/nsCycleCollectionTraversalCallback.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/glue/nsCycleCollectionTraversalCallback.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsCycleCollectionTraversalCallback_h__
    1.10 +#define nsCycleCollectionTraversalCallback_h__
    1.11 +
    1.12 +#include "nsISupports.h"
    1.13 +
    1.14 +class nsCycleCollectionParticipant;
    1.15 +
    1.16 +class NS_NO_VTABLE nsCycleCollectionTraversalCallback
    1.17 +{
    1.18 +public:
    1.19 +  // You must call DescribeRefCountedNode() with an accurate
    1.20 +  // refcount, otherwise cycle collection will fail, and probably crash.
    1.21 +  // If the callback cares about objname, it should put
    1.22 +  // WANT_DEBUG_INFO in mFlags.
    1.23 +  NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refcount,
    1.24 +                                           const char* objname) = 0;
    1.25 +  // Note, aCompartmentAddress is 0 if it is unknown.
    1.26 +  NS_IMETHOD_(void) DescribeGCedNode(bool ismarked,
    1.27 +                                     const char* objname,
    1.28 +                                     uint64_t aCompartmentAddress = 0) = 0;
    1.29 +
    1.30 +  NS_IMETHOD_(void) NoteXPCOMChild(nsISupports *child) = 0;
    1.31 +  NS_IMETHOD_(void) NoteJSChild(void *child) = 0;
    1.32 +  NS_IMETHOD_(void) NoteNativeChild(void *child,
    1.33 +                                    nsCycleCollectionParticipant *helper) = 0;
    1.34 +
    1.35 +  // Give a name to the edge associated with the next call to
    1.36 +  // NoteXPCOMChild, NoteJSChild, or NoteNativeChild.
    1.37 +  // Callbacks who care about this should set WANT_DEBUG_INFO in the
    1.38 +  // flags.
    1.39 +  NS_IMETHOD_(void) NoteNextEdgeName(const char* name) = 0;
    1.40 +
    1.41 +  enum {
    1.42 +    // Values for flags:
    1.43 +
    1.44 +    // Caller should call NoteNextEdgeName and pass useful objName
    1.45 +    // to DescribeRefCountedNode and DescribeGCedNode.
    1.46 +    WANT_DEBUG_INFO = (1<<0),
    1.47 +
    1.48 +    // Caller should not skip objects that we know will be
    1.49 +    // uncollectable.
    1.50 +    WANT_ALL_TRACES = (1<<1)
    1.51 +  };
    1.52 +  uint32_t Flags() const { return mFlags; }
    1.53 +  bool WantDebugInfo() const { return (mFlags & WANT_DEBUG_INFO) != 0; }
    1.54 +  bool WantAllTraces() const { return (mFlags & WANT_ALL_TRACES) != 0; }
    1.55 +protected:
    1.56 +  nsCycleCollectionTraversalCallback() : mFlags(0) {}
    1.57 +
    1.58 +  uint32_t mFlags;
    1.59 +};
    1.60 +
    1.61 +#endif // nsCycleCollectionTraversalCallback_h__

mercurial