1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/base/nsCycleCollector.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 nsCycleCollector_h__ 1.10 +#define nsCycleCollector_h__ 1.11 + 1.12 +class nsICycleCollectorListener; 1.13 +class nsISupports; 1.14 + 1.15 +#include "nsError.h" 1.16 +#include "nsID.h" 1.17 + 1.18 +namespace mozilla { 1.19 + 1.20 +class CycleCollectedJSRuntime; 1.21 + 1.22 +// See the comments in nsContentUtils.h for explanations of these functions. 1.23 +typedef void* (*DeferredFinalizeAppendFunction)(void* pointers, void* thing); 1.24 +typedef bool (*DeferredFinalizeFunction)(uint32_t slice, void* data); 1.25 + 1.26 +} 1.27 + 1.28 +bool nsCycleCollector_init(); 1.29 + 1.30 +void nsCycleCollector_startup(); 1.31 + 1.32 +typedef void (*CC_BeforeUnlinkCallback)(void); 1.33 +void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB); 1.34 + 1.35 +typedef void (*CC_ForgetSkippableCallback)(void); 1.36 +void nsCycleCollector_setForgetSkippableCallback(CC_ForgetSkippableCallback aCB); 1.37 + 1.38 +void nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes = false, 1.39 + bool aAsyncSnowWhiteFreeing = false); 1.40 + 1.41 +void nsCycleCollector_prepareForGarbageCollection(); 1.42 + 1.43 +void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false); 1.44 +bool nsCycleCollector_doDeferredDeletion(); 1.45 + 1.46 +void nsCycleCollector_collect(nsICycleCollectorListener *aManualListener); 1.47 + 1.48 +// If aSliceTime is negative, the CC will run to completion. If aSliceTime 1.49 +// is 0, only a minimum quantum of work will be done. Otherwise, aSliceTime 1.50 +// will be used as the time budget for the slice, in ms. 1.51 +void nsCycleCollector_collectSlice(int64_t aSliceTime); 1.52 + 1.53 +uint32_t nsCycleCollector_suspectedCount(); 1.54 +void nsCycleCollector_shutdown(); 1.55 + 1.56 +// Helpers for interacting with JS 1.57 +void nsCycleCollector_registerJSRuntime(mozilla::CycleCollectedJSRuntime *aRt); 1.58 +void nsCycleCollector_forgetJSRuntime(); 1.59 + 1.60 +#define NS_CYCLE_COLLECTOR_LOGGER_CID \ 1.61 +{ 0x58be81b4, 0x39d2, 0x437c, \ 1.62 +{ 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } } 1.63 + 1.64 +extern nsresult 1.65 +nsCycleCollectorLoggerConstructor(nsISupports* outer, 1.66 + const nsIID& aIID, 1.67 + void* *aInstancePtr); 1.68 + 1.69 +namespace mozilla { 1.70 +namespace cyclecollector { 1.71 + 1.72 +#ifdef DEBUG 1.73 +bool IsJSHolder(void* aHolder); 1.74 +#endif 1.75 + 1.76 +void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc, 1.77 + DeferredFinalizeFunction aFunc, 1.78 + void* aThing); 1.79 +void DeferredFinalize(nsISupports* aSupports); 1.80 + 1.81 + 1.82 +} // namespace cyclecollector 1.83 +} // namespace mozilla 1.84 + 1.85 +#endif // nsCycleCollector_h__