nsCCUncollectableMarker.h (1317B)
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/. */ 6 7 #ifndef nsCCUncollectableMarker_h_ 8 #define nsCCUncollectableMarker_h_ 9 10 #include "js/TracingAPI.h" 11 #include "nsIObserver.h" 12 13 class nsCCUncollectableMarker final : public nsIObserver { 14 NS_DECL_ISUPPORTS 15 NS_DECL_NSIOBSERVER 16 17 /** 18 * Inits a global nsCCUncollectableMarker. Should only be called once. 19 */ 20 static nsresult Init(); 21 22 /** 23 * Checks if we're collecting during a given generation 24 */ 25 static bool InGeneration(uint32_t aGeneration) { 26 return aGeneration && aGeneration == sGeneration; 27 } 28 29 template <class CCCallback> 30 static bool InGeneration(CCCallback& aCb, uint32_t aGeneration) { 31 return InGeneration(aGeneration) && !aCb.WantAllTraces(); 32 } 33 34 static void CleanupForForgetSkippable(); 35 36 static uint32_t sGeneration; 37 38 private: 39 nsCCUncollectableMarker() = default; 40 ~nsCCUncollectableMarker() = default; 41 42 nsresult Cleanup(bool aPrepareForCC); 43 }; 44 45 namespace mozilla::dom { 46 void TraceBlackJS(JSTracer* aTrc); 47 } // namespace mozilla::dom 48 49 #endif