nsCycleCollector.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  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. #ifndef nsCycleCollector_h__
  6. #define nsCycleCollector_h__
  7. class nsICycleCollectorListener;
  8. class nsICycleCollectorLogSink;
  9. class nsISupports;
  10. template<class T> struct already_AddRefed;
  11. #include "nsError.h"
  12. #include "nsID.h"
  13. #include "js/SliceBudget.h"
  14. namespace mozilla {
  15. class CycleCollectedJSContext;
  16. } // namespace mozilla
  17. bool nsCycleCollector_init();
  18. void nsCycleCollector_startup();
  19. typedef void (*CC_BeforeUnlinkCallback)(void);
  20. void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB);
  21. typedef void (*CC_ForgetSkippableCallback)(void);
  22. void nsCycleCollector_setForgetSkippableCallback(CC_ForgetSkippableCallback aCB);
  23. void nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes = false,
  24. bool aAsyncSnowWhiteFreeing = false);
  25. void nsCycleCollector_prepareForGarbageCollection();
  26. // If an incremental cycle collection is in progress, finish it.
  27. void nsCycleCollector_finishAnyCurrentCollection();
  28. void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false,
  29. bool aPurge = false);
  30. bool nsCycleCollector_doDeferredDeletion();
  31. already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink();
  32. void nsCycleCollector_collect(nsICycleCollectorListener* aManualListener);
  33. void nsCycleCollector_collectSlice(js::SliceBudget& budget,
  34. bool aPreferShorterSlices = false);
  35. uint32_t nsCycleCollector_suspectedCount();
  36. // If aDoCollect is true, then run the GC and CC a few times before
  37. // shutting down the CC completely.
  38. void nsCycleCollector_shutdown(bool aDoCollect = true);
  39. // Helpers for interacting with JS
  40. void nsCycleCollector_registerJSContext(mozilla::CycleCollectedJSContext* aCx);
  41. void nsCycleCollector_forgetJSContext();
  42. #define NS_CYCLE_COLLECTOR_LOGGER_CID \
  43. { 0x58be81b4, 0x39d2, 0x437c, \
  44. { 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } }
  45. extern nsresult
  46. nsCycleCollectorLoggerConstructor(nsISupports* aOuter,
  47. const nsIID& aIID,
  48. void** aInstancePtr);
  49. #endif // nsCycleCollector_h__