Logo Search packages:      
Sourcecode: xulrunner version File versions  Download package

nsMutationGuard Class Reference

#include <nsContentUtils.h>

List of all members.

Detailed Description

Class used to detect unexpected mutations. To use the class create an nsMutationGuard on the stack before unexpected mutations could occur. You can then at any time call Mutated to check if any unexpected mutations have occured.

When a guard is instantiated sMutationCount is set to 300. It is then decremented by every mutation (capped at 0). This means that we can only detect 300 mutations during the lifetime of a single guard, however that should be more then we ever care about as we usually only care if more then one mutation has occured.

When the guard goes out of scope it will adjust sMutationCount so that over the lifetime of the guard the guard itself has not affected sMutationCount, while mutations that happened while the guard was alive still will. This allows a guard to be instantiated even if there is another guard higher up on the callstack watching for mutations.

The only thing that has to be avoided is for an outer guard to be used while an inner guard is alive. This can be avoided by only ever instantiating a single guard per scope and only using the guard in the current scope.

Definition at line 1604 of file nsContentUtils.h.

Public Member Functions

PRBool Mutated (PRUint8 aIgnoreCount)

Static Public Member Functions

static void DidMutate ()

Private Types

enum  { eMaxMutations = 300 }

Private Attributes

PRUint32 mDelta

Static Private Attributes

static PRUint32 sMutationCount = 0

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index