tor-browser

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

CrashReporterClient.h (1431B)


      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_CrashReporterClient_h
      8 #define mozilla_ipc_CrashReporterClient_h
      9 
     10 #include "CrashReporter/CrashReporterInitArgs.h"
     11 #include "mozilla/StaticMutex.h"
     12 #include "mozilla/StaticPtr.h"
     13 #include "nsExceptionHandler.h"
     14 
     15 namespace mozilla::ipc {
     16 
     17 class CrashReporterClient {
     18 public:
     19  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CrashReporterClient);
     20 
     21  // |aTopLevelProtocol| must have a child-to-parent message:
     22  //
     23  //   async InitCrashReporter(NativeThreadId threadId);
     24  template <typename T>
     25  static void InitSingleton(T* aToplevelProtocol) {
     26    InitSingleton();
     27    (void)aToplevelProtocol->SendInitCrashReporter(CreateInitArgs());
     28  }
     29 
     30  static void InitSingleton();
     31  static CrashReporter::CrashReporterInitArgs CreateInitArgs();
     32 
     33  static void DestroySingleton();
     34  static RefPtr<CrashReporterClient> GetSingleton();
     35 
     36 private:
     37  explicit CrashReporterClient();
     38  ~CrashReporterClient();
     39 
     40  static StaticMutex sLock;
     41  static StaticRefPtr<CrashReporterClient> sClientSingleton
     42      MOZ_GUARDED_BY(sLock);
     43 };
     44 
     45 }  // namespace mozilla::ipc
     46 
     47 #endif  // mozilla_ipc_CrashReporterClient_h