Bug 1883861 - Part 1: Move visitMemoryBarrier into the common CodeGenerator file...
[gecko.git] / xpcom / build / LateWriteChecks.h
blob6c9ee419f960acb40b3c3cdcc05f922daf342c0a
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 mozilla_LateWriteChecks_h
8 #define mozilla_LateWriteChecks_h
10 // This file, along with LateWriteChecks.cpp, serves to check for and report
11 // late writes. The idea is discover writes to the file system that happens
12 // during shutdown such that these maybe be moved forward and the process may be
13 // killed without waiting for static destructors.
15 namespace mozilla {
17 /** Different shutdown check modes */
18 enum ShutdownChecksMode {
19 SCM_CRASH, /** Crash on shutdown check failure */
20 SCM_RECORD, /** Record shutdown check violations */
21 SCM_NOTHING /** Don't attempt any shutdown checks */
24 /**
25 * Current shutdown check mode.
26 * This variable is defined and initialized in nsAppRunner.cpp
28 extern ShutdownChecksMode gShutdownChecks;
30 /**
31 * Allocate structures and acquire information from XPCOM necessary to do late
32 * write checks. This function must be invoked before BeginLateWriteChecks()
33 * and before XPCOM has stopped working.
35 void InitLateWriteChecks();
37 /**
38 * Begin recording all writes as late-writes. This function should be called
39 * when all legitimate writes have occurred. This function does not rely on
40 * XPCOM as it is designed to be invoked during XPCOM shutdown.
42 * For late-write checks to work you must initialize one or more backends that
43 * reports IO through the IOInterposer API. PoisonIOInterposer would probably
44 * be the backend of choice in this case.
46 * Note: BeginLateWriteChecks() must have been invoked before this function.
48 void BeginLateWriteChecks();
50 /**
51 * Stop recording all writes as late-writes, call this function when you want
52 * late-write checks to stop. I.e. exception handling, or the special case on
53 * Mac described in bug 826029.
55 void StopLateWriteChecks();
57 /**
58 * Temporarily suspend late write checks for the current thread. This is useful
59 * if you're about to perform a write, but it would be fine if this write were
60 * interrupted or skipped during a fast shutdown.
62 void PushSuspendLateWriteChecks();
64 /**
65 * Resume late write checks for the current thread, assuming an ancestor in the
66 * call stack hasn't also pushed a suspension.
68 void PopSuspendLateWriteChecks();
70 class MOZ_RAII AutoSuspendLateWriteChecks {
71 public:
72 AutoSuspendLateWriteChecks() { PushSuspendLateWriteChecks(); }
73 ~AutoSuspendLateWriteChecks() { PopSuspendLateWriteChecks(); }
76 } // namespace mozilla
78 #endif // mozilla_LateWriteChecks_h