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