michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsCycleCollector_h__ michael@0: #define nsCycleCollector_h__ michael@0: michael@0: class nsICycleCollectorListener; michael@0: class nsISupports; michael@0: michael@0: #include "nsError.h" michael@0: #include "nsID.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class CycleCollectedJSRuntime; michael@0: michael@0: // See the comments in nsContentUtils.h for explanations of these functions. michael@0: typedef void* (*DeferredFinalizeAppendFunction)(void* pointers, void* thing); michael@0: typedef bool (*DeferredFinalizeFunction)(uint32_t slice, void* data); michael@0: michael@0: } michael@0: michael@0: bool nsCycleCollector_init(); michael@0: michael@0: void nsCycleCollector_startup(); michael@0: michael@0: typedef void (*CC_BeforeUnlinkCallback)(void); michael@0: void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB); michael@0: michael@0: typedef void (*CC_ForgetSkippableCallback)(void); michael@0: void nsCycleCollector_setForgetSkippableCallback(CC_ForgetSkippableCallback aCB); michael@0: michael@0: void nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes = false, michael@0: bool aAsyncSnowWhiteFreeing = false); michael@0: michael@0: void nsCycleCollector_prepareForGarbageCollection(); michael@0: michael@0: void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false); michael@0: bool nsCycleCollector_doDeferredDeletion(); michael@0: michael@0: void nsCycleCollector_collect(nsICycleCollectorListener *aManualListener); michael@0: michael@0: // If aSliceTime is negative, the CC will run to completion. If aSliceTime michael@0: // is 0, only a minimum quantum of work will be done. Otherwise, aSliceTime michael@0: // will be used as the time budget for the slice, in ms. michael@0: void nsCycleCollector_collectSlice(int64_t aSliceTime); michael@0: michael@0: uint32_t nsCycleCollector_suspectedCount(); michael@0: void nsCycleCollector_shutdown(); michael@0: michael@0: // Helpers for interacting with JS michael@0: void nsCycleCollector_registerJSRuntime(mozilla::CycleCollectedJSRuntime *aRt); michael@0: void nsCycleCollector_forgetJSRuntime(); michael@0: michael@0: #define NS_CYCLE_COLLECTOR_LOGGER_CID \ michael@0: { 0x58be81b4, 0x39d2, 0x437c, \ michael@0: { 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } } michael@0: michael@0: extern nsresult michael@0: nsCycleCollectorLoggerConstructor(nsISupports* outer, michael@0: const nsIID& aIID, michael@0: void* *aInstancePtr); michael@0: michael@0: namespace mozilla { michael@0: namespace cyclecollector { michael@0: michael@0: #ifdef DEBUG michael@0: bool IsJSHolder(void* aHolder); michael@0: #endif michael@0: michael@0: void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc, michael@0: DeferredFinalizeFunction aFunc, michael@0: void* aThing); michael@0: void DeferredFinalize(nsISupports* aSupports); michael@0: michael@0: michael@0: } // namespace cyclecollector michael@0: } // namespace mozilla michael@0: michael@0: #endif // nsCycleCollector_h__