tor-browser

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

SandboxReporterClient.h (1447B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_SandboxReporterClient_h
      8 #define mozilla_SandboxReporterClient_h
      9 
     10 #include "reporter/SandboxReporterCommon.h"
     11 
     12 namespace mozilla {
     13 
     14 // This class is instantiated in child processes in Sandbox.cpp to
     15 // send reports from the SIGSYS handler to the SandboxReporter
     16 // instance in the parent.
     17 class SandboxReporterClient {
     18 public:
     19  // Note: this does not take ownership of the file descriptor; if
     20  // it's not process-global (e.g., for unit testing), the caller
     21  // will need to close it to avoid leaks.
     22  SandboxReporterClient(SandboxReport::ProcType aProcType, int aFd);
     23 
     24  // Constructs a report from a signal context (the ucontext_t* passed
     25  // as void* to an sa_sigaction handler); uses the caller's pid and tid.
     26  SandboxReport MakeReport(const void* aContext);
     27 
     28  void SendReport(const SandboxReport& aReport);
     29 
     30  SandboxReport MakeReportAndSend(const void* aContext) {
     31    SandboxReport report = MakeReport(aContext);
     32    SendReport(report);
     33    return report;
     34  }
     35 
     36 private:
     37  SandboxReport::ProcType mProcType;
     38  int mFd;
     39 };
     40 
     41 }  // namespace mozilla
     42 
     43 #endif  // mozilla_SandboxReporterClient_h