tor-browser

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

ProcessRuntimeShared.h (1593B)


      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_mscom_ProcessRuntimeShared_h
      8 #define mozilla_mscom_ProcessRuntimeShared_h
      9 
     10 #include "mozilla/Assertions.h"
     11 #include "mozilla/Attributes.h"
     12 #include "mozilla/Types.h"
     13 
     14 namespace mozilla {
     15 namespace mscom {
     16 namespace detail {
     17 
     18 enum class ProcessInitState : uint32_t {
     19  Uninitialized = 0,
     20  PartialSecurityInitialized,
     21  PartialGlobalOptions,
     22  FullyInitialized,
     23 };
     24 
     25 MFBT_API ProcessInitState& BeginProcessRuntimeInit();
     26 MFBT_API void EndProcessRuntimeInit();
     27 
     28 }  // namespace detail
     29 
     30 class MOZ_RAII ProcessInitLock final {
     31 public:
     32  ProcessInitLock() : mInitState(detail::BeginProcessRuntimeInit()) {}
     33 
     34  ~ProcessInitLock() { detail::EndProcessRuntimeInit(); }
     35 
     36  detail::ProcessInitState GetInitState() const { return mInitState; }
     37 
     38  void SetInitState(const detail::ProcessInitState aNewState) {
     39    MOZ_DIAGNOSTIC_ASSERT(aNewState > mInitState);
     40    mInitState = aNewState;
     41  }
     42 
     43  ProcessInitLock(const ProcessInitLock&) = delete;
     44  ProcessInitLock(ProcessInitLock&&) = delete;
     45  ProcessInitLock operator=(const ProcessInitLock&) = delete;
     46  ProcessInitLock operator=(ProcessInitLock&&) = delete;
     47 
     48 private:
     49  detail::ProcessInitState& mInitState;
     50 };
     51 
     52 }  // namespace mscom
     53 }  // namespace mozilla
     54 
     55 #endif  // mozilla_mscom_ProcessRuntimeShared_h