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