Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / dom / console / nsIConsoleReportCollector.h
blob3e972184e3d296d698b9b4ccd2625876dd763bad
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/. */
7 #ifndef nsIConsoleReportCollector_h
8 #define nsIConsoleReportCollector_h
10 #include "nsContentUtils.h"
11 #include "nsISupports.h"
12 #include "nsStringFwd.h"
13 #include "nsTArrayForwardDeclare.h"
15 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
16 #define NS_NSICONSOLEREPORTCOLLECTOR_IID \
17 { \
18 0xdd98a481, 0xd2c4, 0x4203, { \
19 0x8d, 0xfa, 0x85, 0xbf, 0xd7, 0xdc, 0xd7, 0x05 \
20 } \
23 namespace mozilla::net {
24 class ConsoleReportCollected;
25 } // namespace mozilla::net
27 // An interface for saving reports until we can flush them to the correct
28 // window at a later time.
29 class NS_NO_VTABLE nsIConsoleReportCollector : public nsISupports {
30 public:
31 NS_DECLARE_STATIC_IID_ACCESSOR(NS_NSICONSOLEREPORTCOLLECTOR_IID)
33 // Add a pending report to be later displayed on the console. This may be
34 // called from any thread.
36 // aErrorFlags A nsIScriptError flags value.
37 // aCategory Name of module reporting error.
38 // aPropertiesFile Properties file containing localized message.
39 // aSourceFileURI The URI of the script generating the error. Must be a URI
40 // spec.
41 // aLineNumber The line number where the error was generated. May be 0 if
42 // the line number is not known.
43 // aColumnNumber The column number where the error was generated. May be 0
44 // if the line number is not known.
45 // aMessageName The name of the localized message contained in the
46 // properties file.
47 // aStringParams An array of nsString parameters to use when localizing the
48 // message.
49 virtual void AddConsoleReport(uint32_t aErrorFlags,
50 const nsACString& aCategory,
51 nsContentUtils::PropertiesFile aPropertiesFile,
52 const nsACString& aSourceFileURI,
53 uint32_t aLineNumber, uint32_t aColumnNumber,
54 const nsACString& aMessageName,
55 const nsTArray<nsString>& aStringParams) = 0;
57 // A version of AddConsoleReport() that accepts the message parameters
58 // as variable nsString arguments (or really, any sort of const nsAString).
59 // All other args the same as AddConsoleReport().
60 template <typename... Params>
61 void AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory,
62 nsContentUtils::PropertiesFile aPropertiesFile,
63 const nsACString& aSourceFileURI, uint32_t aLineNumber,
64 uint32_t aColumnNumber, const nsACString& aMessageName,
65 Params&&... aParams) {
66 nsTArray<nsString> params;
67 mozilla::dom::StringArrayAppender::Append(params, sizeof...(Params),
68 std::forward<Params>(aParams)...);
69 AddConsoleReport(aErrorFlags, aCategory, aPropertiesFile, aSourceFileURI,
70 aLineNumber, aColumnNumber, aMessageName, params);
73 // An enum calss to indicate whether should free the pending reports or not.
74 // Forget Free the pending reports.
75 // Save Keep the pending reports.
76 enum class ReportAction { Forget, Save };
78 // Flush all pending reports to the console. May be called from any thread.
80 // aInnerWindowID A inner window ID representing where to flush the reports.
81 // aAction An action to determine whether to reserve the pending
82 // reports. Defalut action is to forget the report.
83 virtual void FlushReportsToConsole(
84 uint64_t aInnerWindowID, ReportAction aAction = ReportAction::Forget) = 0;
86 virtual void FlushReportsToConsoleForServiceWorkerScope(
87 const nsACString& aScope,
88 ReportAction aAction = ReportAction::Forget) = 0;
90 // Flush all pending reports to the console. Main thread only.
92 // aDocument An optional document representing where to flush the
93 // reports. If provided, then the corresponding window's
94 // web console will get the reports. Otherwise the reports
95 // go to the browser console.
96 // aAction An action to determine whether to reserve the pending
97 // reports. Defalut action is to forget the report.
98 virtual void FlushConsoleReports(
99 mozilla::dom::Document* aDocument,
100 ReportAction aAction = ReportAction::Forget) = 0;
102 // Flush all pending reports to the console. May be called from any thread.
104 // aLoadGroup An optional loadGroup representing where to flush the
105 // reports. If provided, then the corresponding window's
106 // web console will get the reports. Otherwise the reports
107 // go to the browser console.
108 // aAction An action to determine whether to reserve the pending
109 // reports. Defalut action is to forget the report.
110 virtual void FlushConsoleReports(
111 nsILoadGroup* aLoadGroup,
112 ReportAction aAction = ReportAction::Forget) = 0;
114 // Flush all pending reports to another collector. May be called from any
115 // thread.
117 // aCollector A required collector object that will effectively take
118 // ownership of our currently console reports.
119 virtual void FlushConsoleReports(nsIConsoleReportCollector* aCollector) = 0;
121 // Steal all pending reports to IPC structs. May be called from any thread.
122 virtual void StealConsoleReports(
123 nsTArray<mozilla::net::ConsoleReportCollected>& aReports) = 0;
125 // Clear all pending reports.
126 virtual void ClearConsoleReports() = 0;
129 NS_DEFINE_STATIC_IID_ACCESSOR(nsIConsoleReportCollector,
130 NS_NSICONSOLEREPORTCOLLECTOR_IID)
132 #endif // nsIConsoleReportCollector_h