Bug 1795082 - Part 2/2: Drop post-processing from getURL() r=zombie
[gecko.git] / xpcom / base / nsCycleCollector.h
blob2881a53d81c7dbb3b82d3cc3313a01f5b4272990
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsCycleCollector_h__
8 #define nsCycleCollector_h__
10 class nsICycleCollectorListener;
11 class nsICycleCollectorLogSink;
12 class nsISupports;
13 template <class T>
14 struct already_AddRefed;
16 #include <cstdint>
17 #include "mozilla/Attributes.h"
18 #include "mozilla/TimeStamp.h"
19 #include "nsCycleCollectionParticipant.h"
21 namespace JS {
22 class SliceBudget;
25 namespace mozilla {
26 class CycleCollectedJSContext;
27 } // namespace mozilla
29 bool nsCycleCollector_init();
31 void nsCycleCollector_startup();
33 typedef void (*CC_BeforeUnlinkCallback)(void);
34 void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB);
36 typedef void (*CC_ForgetSkippableCallback)(void);
37 void nsCycleCollector_setForgetSkippableCallback(
38 CC_ForgetSkippableCallback aCB);
40 void nsCycleCollector_forgetSkippable(mozilla::TimeStamp aStartTime,
41 JS::SliceBudget& aBudget, bool aInIdle,
42 bool aRemoveChildlessNodes = false,
43 bool aAsyncSnowWhiteFreeing = false);
45 void nsCycleCollector_prepareForGarbageCollection();
47 // If an incremental cycle collection is in progress, finish it.
48 void nsCycleCollector_finishAnyCurrentCollection();
50 void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false,
51 bool aPurge = false);
52 bool nsCycleCollector_doDeferredDeletion();
53 bool nsCycleCollector_doDeferredDeletionWithBudget(JS::SliceBudget& aBudget);
55 already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink(
56 bool aLogGC);
57 already_AddRefed<nsICycleCollectorListener> nsCycleCollector_createLogger();
59 // Run a cycle collection and return whether anything was collected.
60 bool nsCycleCollector_collect(mozilla::CCReason aReason,
61 nsICycleCollectorListener* aManualListener);
63 void nsCycleCollector_collectSlice(JS::SliceBudget& budget,
64 mozilla::CCReason aReason,
65 bool aPreferShorterSlices = false);
67 uint32_t nsCycleCollector_suspectedCount();
69 // If aDoCollect is true, then run the GC and CC a few times before
70 // shutting down the CC completely.
71 MOZ_CAN_RUN_SCRIPT
72 void nsCycleCollector_shutdown(bool aDoCollect = true);
74 // Helpers for interacting with JS
75 void nsCycleCollector_registerJSContext(mozilla::CycleCollectedJSContext* aCx);
76 void nsCycleCollector_forgetJSContext();
78 #endif // nsCycleCollector_h__