tor-browser

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

Neutering.h (1849B)


      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/. */
      6 
      7 #ifndef mozilla_ipc_Neutering_h
      8 #define mozilla_ipc_Neutering_h
      9 
     10 /**
     11 * This header declares RAII wrappers for Window neutering. See
     12 * WindowsMessageLoop.cpp for more details.
     13 */
     14 
     15 namespace mozilla {
     16 namespace ipc {
     17 
     18 /**
     19 * This class is a RAII wrapper around Window neutering. As long as a
     20 * NeuteredWindowRegion object is instantiated, Win32 windows belonging to the
     21 * current thread will be neutered. It is safe to nest multiple instances of
     22 * this class.
     23 */
     24 class MOZ_RAII NeuteredWindowRegion {
     25 public:
     26  explicit NeuteredWindowRegion(bool aDoNeuter);
     27  ~NeuteredWindowRegion();
     28 
     29  /**
     30   * This function clears any backlog of nonqueued messages that are pending for
     31   * the current thread.
     32   */
     33  void PumpOnce();
     34 
     35 private:
     36  bool mNeuteredByThis;
     37 };
     38 
     39 /**
     40 * This class is analagous to MutexAutoUnlock for Mutex; it is an RAII class
     41 * that is to be instantiated within a NeuteredWindowRegion, thus temporarily
     42 * disabling neutering for the remainder of its enclosing block.
     43 * @see NeuteredWindowRegion
     44 */
     45 class MOZ_RAII DeneuteredWindowRegion {
     46 public:
     47  explicit DeneuteredWindowRegion();
     48  ~DeneuteredWindowRegion();
     49 
     50 private:
     51  bool mReneuter;
     52 };
     53 
     54 class MOZ_RAII SuppressedNeuteringRegion {
     55 public:
     56  explicit SuppressedNeuteringRegion();
     57  ~SuppressedNeuteringRegion();
     58 
     59  static inline bool IsNeuteringSuppressed() { return sSuppressNeutering; }
     60 
     61 private:
     62  bool mReenable;
     63 
     64  static bool sSuppressNeutering;
     65 };
     66 
     67 }  // namespace ipc
     68 }  // namespace mozilla
     69 
     70 #endif  // mozilla_ipc_Neutering_h