xpcom/build/LateWriteChecks.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/build/LateWriteChecks.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim:set ts=4 sw=4 sts=4 ci et: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_LateWriteChecks_h
    1.11 +#define mozilla_LateWriteChecks_h
    1.12 +
    1.13 +// This file, along with LateWriteChecks.cpp, serves to check for and report
    1.14 +// late writes. The idea is discover writes to the file system that happens
    1.15 +// during shutdown such that these maybe be moved forward and the process may be
    1.16 +// killed without waiting for static destructors.
    1.17 +
    1.18 +namespace mozilla {
    1.19 +
    1.20 +/** Different shutdown check modes */
    1.21 +enum ShutdownChecksMode {
    1.22 +  SCM_CRASH,      /** Crash on shutdown check failure */
    1.23 +  SCM_RECORD,     /** Record shutdown check violations */
    1.24 +  SCM_NOTHING     /** Don't attempt any shutdown checks */
    1.25 +};
    1.26 +
    1.27 +/**
    1.28 + * Current shutdown check mode.
    1.29 + * This variable is defined and initialized in nsAppRunner.cpp
    1.30 + */
    1.31 +extern ShutdownChecksMode gShutdownChecks;
    1.32 +
    1.33 +/**
    1.34 + * Allocate structures and acquire information from XPCOM necessary to do late
    1.35 + * write checks. This function must be invoked before BeginLateWriteChecks()
    1.36 + * and before XPCOM has stopped working.
    1.37 + */
    1.38 +void InitLateWriteChecks();
    1.39 +
    1.40 +/**
    1.41 + * Begin recording all writes as late-writes. This function should be called
    1.42 + * when all legitimate writes have occurred. This function does not rely on
    1.43 + * XPCOM as it is designed to be invoked during XPCOM shutdown.
    1.44 + *
    1.45 + * For late-write checks to work you must initialize one or more backends that
    1.46 + * reports IO through the IOInterposer API. PoisonIOInterposer would probably
    1.47 + * be the backend of choice in this case.
    1.48 + *
    1.49 + * Note: BeginLateWriteChecks() must have been invoked before this function.
    1.50 + */
    1.51 +void BeginLateWriteChecks();
    1.52 +
    1.53 +/**
    1.54 + * Stop recording all writes as late-writes, call this function when you want
    1.55 + * late-write checks to stop. I.e. exception handling, or the special case on
    1.56 + * Mac described in bug 826029.
    1.57 + */
    1.58 +void StopLateWriteChecks();
    1.59 +
    1.60 +} // mozilla
    1.61 +
    1.62 +#endif // mozilla_LateWriteChecks_h

mercurial