tor-browser

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

ConsoleReportCollector.h (3046B)


      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_ConsoleReportCollector_h
      8 #define mozilla_ConsoleReportCollector_h
      9 
     10 #include "mozilla/Mutex.h"
     11 #include "nsIConsoleReportCollector.h"
     12 #include "nsTArray.h"
     13 
     14 namespace mozilla {
     15 
     16 namespace net {
     17 class ConsoleReportCollected;
     18 }
     19 
     20 class ConsoleReportCollector final : public nsIConsoleReportCollector {
     21 public:
     22  ConsoleReportCollector();
     23 
     24  void AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory,
     25                        nsContentUtils::PropertiesFile aPropertiesFile,
     26                        const nsACString& aSourceFileURI, uint32_t aLineNumber,
     27                        uint32_t aColumnNumber, const nsACString& aMessageName,
     28                        const nsTArray<nsString>& aStringParams) override;
     29 
     30  void FlushReportsToConsole(
     31      uint64_t aInnerWindowID,
     32      ReportAction aAction = ReportAction::Forget) override;
     33 
     34  void FlushReportsToConsoleForServiceWorkerScope(
     35      const nsACString& aScope,
     36      ReportAction aAction = ReportAction::Forget) override;
     37 
     38  void FlushConsoleReports(
     39      dom::Document* aDocument,
     40      ReportAction aAction = ReportAction::Forget) override;
     41 
     42  void FlushConsoleReports(
     43      nsILoadGroup* aLoadGroup,
     44      ReportAction aAction = ReportAction::Forget) override;
     45 
     46  void FlushConsoleReports(nsIConsoleReportCollector* aCollector) override;
     47 
     48  void StealConsoleReports(
     49      nsTArray<net::ConsoleReportCollected>& aReports) override;
     50 
     51  void ClearConsoleReports() override;
     52 
     53 private:
     54  ~ConsoleReportCollector();
     55 
     56  struct PendingReport {
     57    PendingReport(uint32_t aErrorFlags, const nsACString& aCategory,
     58                  nsContentUtils::PropertiesFile aPropertiesFile,
     59                  const nsACString& aSourceFileURI, uint32_t aLineNumber,
     60                  uint32_t aColumnNumber, const nsACString& aMessageName,
     61                  const nsTArray<nsString>& aStringParams)
     62        : mErrorFlags(aErrorFlags),
     63          mCategory(aCategory),
     64          mPropertiesFile(aPropertiesFile),
     65          mSourceFileURI(aSourceFileURI),
     66          mLineNumber(aLineNumber),
     67          mColumnNumber(aColumnNumber),
     68          mMessageName(aMessageName),
     69          mStringParams(aStringParams.Clone()) {}
     70 
     71    const uint32_t mErrorFlags;
     72    const nsCString mCategory;
     73    const nsContentUtils::PropertiesFile mPropertiesFile;
     74    const nsCString mSourceFileURI;
     75    const uint32_t mLineNumber;
     76    const uint32_t mColumnNumber;
     77    const nsCString mMessageName;
     78    const CopyableTArray<nsString> mStringParams;
     79  };
     80 
     81  Mutex mMutex;
     82 
     83  // protected by mMutex
     84  nsTArray<PendingReport> mPendingReports MOZ_GUARDED_BY(mMutex);
     85 
     86 public:
     87  NS_DECL_THREADSAFE_ISUPPORTS
     88 };
     89 
     90 }  // namespace mozilla
     91 
     92 #endif  // mozilla_ConsoleReportCollector_h