Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / layout / build / nsLayoutStatics.h
blob984f7c984e423842d09d02beb9e52de2deb552fd
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 nsLayoutStatics_h__
8 #define nsLayoutStatics_h__
10 #include "nscore.h"
11 #include "MainThreadUtils.h"
12 #include "nsISupportsImpl.h"
13 #include "nsDebug.h"
15 // This isn't really a class, it's a namespace for static methods.
16 // Documents and other objects can hold a reference to the layout static
17 // objects so that they last past the xpcom-shutdown notification.
19 class nsLayoutStatics {
20 public:
21 // Called by the layout module constructor. This call performs an AddRef()
22 // internally.
23 static nsresult Initialize();
25 static void AddRef() {
26 NS_ASSERTION(NS_IsMainThread(),
27 "nsLayoutStatics reference counting must be on main thread");
29 NS_ASSERTION(sLayoutStaticRefcnt,
30 "nsLayoutStatics already dropped to zero!");
32 ++sLayoutStaticRefcnt;
33 NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt, "nsLayoutStatics",
34 1);
36 static void Release() {
37 NS_ASSERTION(NS_IsMainThread(),
38 "nsLayoutStatics reference counting must be on main thread");
40 --sLayoutStaticRefcnt;
41 NS_LOG_RELEASE(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
42 "nsLayoutStatics");
44 if (!sLayoutStaticRefcnt) Shutdown();
47 private:
48 // not to be called!
49 nsLayoutStatics();
51 static void Shutdown();
53 static nsrefcnt sLayoutStaticRefcnt;
56 #endif // nsLayoutStatics_h__