|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* vim:set ts=4 sw=4 sts=4 ci et: */ |
|
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 mozilla_LateWriteChecks_h |
|
8 #define mozilla_LateWriteChecks_h |
|
9 |
|
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. |
|
14 |
|
15 namespace mozilla { |
|
16 |
|
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 */ |
|
22 }; |
|
23 |
|
24 /** |
|
25 * Current shutdown check mode. |
|
26 * This variable is defined and initialized in nsAppRunner.cpp |
|
27 */ |
|
28 extern ShutdownChecksMode gShutdownChecks; |
|
29 |
|
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. |
|
34 */ |
|
35 void InitLateWriteChecks(); |
|
36 |
|
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. |
|
41 * |
|
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. |
|
45 * |
|
46 * Note: BeginLateWriteChecks() must have been invoked before this function. |
|
47 */ |
|
48 void BeginLateWriteChecks(); |
|
49 |
|
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. |
|
54 */ |
|
55 void StopLateWriteChecks(); |
|
56 |
|
57 } // mozilla |
|
58 |
|
59 #endif // mozilla_LateWriteChecks_h |