tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ShutdownTracker.h (1407B)


      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 /**
      7 * ShutdownTracker is an imagelib-global service that allows callers to check
      8 * whether shutdown has started.
      9 */
     10 
     11 #ifndef mozilla_image_ShutdownTracker_h
     12 #define mozilla_image_ShutdownTracker_h
     13 
     14 namespace mozilla {
     15 namespace image {
     16 
     17 /**
     18 * ShutdownTracker is an imagelib-global service that allows callers to check
     19 * whether shutdown has started. It exists to avoid the need for registering
     20 * many 'xpcom-will-shutdown' notification observers on short-lived objects,
     21 * which would have an unnecessary performance cost.
     22 */
     23 struct ShutdownTracker {
     24  /**
     25   * Initialize static data. Called during imagelib module initialization.
     26   */
     27  static void Initialize();
     28 
     29  /**
     30   * Check whether shutdown has started. Callers can use this to check whether
     31   * it's safe to access XPCOM services; if shutdown has started, such calls
     32   * must be avoided.
     33   *
     34   * @return true if shutdown has already started.
     35   */
     36  static bool ShutdownHasStarted();
     37 
     38 private:
     39  virtual ~ShutdownTracker() = 0;  // Forbid instantiation.
     40 };
     41 
     42 }  // namespace image
     43 }  // namespace mozilla
     44 
     45 #endif  // mozilla_image_ShutdownTracker_h