2015-10-30 05:53:25 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef nsIConsoleReportCollector_h
|
|
|
|
#define nsIConsoleReportCollector_h
|
|
|
|
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsISupports.h"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2015-10-30 05:53:25 +03:00
|
|
|
#include "nsTArrayForwardDeclare.h"
|
|
|
|
|
2018-01-05 01:32:15 +03:00
|
|
|
// Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
|
2015-10-30 05:53:25 +03:00
|
|
|
#define NS_NSICONSOLEREPORTCOLLECTOR_IID \
|
|
|
|
{ \
|
|
|
|
0xdd98a481, 0xd2c4, 0x4203, { \
|
|
|
|
0x8d, 0xfa, 0x85, 0xbf, 0xd7, 0xdc, 0xd7, 0x05 \
|
|
|
|
} \
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2015-10-30 05:53:25 +03:00
|
|
|
|
|
|
|
// An interface for saving reports until we can flush them to the correct
|
|
|
|
// window at a later time.
|
|
|
|
class NS_NO_VTABLE nsIConsoleReportCollector : public nsISupports {
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_NSICONSOLEREPORTCOLLECTOR_IID)
|
|
|
|
|
|
|
|
// Add a pending report to be later displayed on the console. This may be
|
|
|
|
// called from any thread.
|
|
|
|
//
|
|
|
|
// aErrorFlags A nsIScriptError flags value.
|
|
|
|
// aCategory Name of module reporting error.
|
|
|
|
// aPropertiesFile Properties file containing localized message.
|
|
|
|
// aSourceFileURI The URI of the script generating the error. Must be a URI
|
|
|
|
// spec.
|
|
|
|
// aLineNumber The line number where the error was generated. May be 0 if
|
|
|
|
// the line number is not known.
|
|
|
|
// aColumnNumber The column number where the error was generated. May be 0
|
|
|
|
// if the line number is not known.
|
|
|
|
// aMessageName The name of the localized message contained in the
|
|
|
|
// properties file.
|
|
|
|
// aStringParams An array of nsString parameters to use when localizing the
|
|
|
|
// message.
|
|
|
|
virtual void AddConsoleReport(uint32_t aErrorFlags,
|
|
|
|
const nsACString& aCategory,
|
|
|
|
nsContentUtils::PropertiesFile aPropertiesFile,
|
|
|
|
const nsACString& aSourceFileURI,
|
|
|
|
uint32_t aLineNumber, uint32_t aColumnNumber,
|
|
|
|
const nsACString& aMessageName,
|
|
|
|
const nsTArray<nsString>& aStringParams) = 0;
|
|
|
|
|
|
|
|
// A version of AddConsoleReport() that accepts the message parameters
|
2015-11-20 21:36:46 +03:00
|
|
|
// as variable nsString arguments (or really, any sort of const nsAString).
|
|
|
|
// All other args the same as AddConsoleReport().
|
2015-10-30 05:53:25 +03:00
|
|
|
template <typename... Params>
|
|
|
|
void AddConsoleReport(uint32_t aErrorFlags, const nsACString& aCategory,
|
|
|
|
nsContentUtils::PropertiesFile aPropertiesFile,
|
|
|
|
const nsACString& aSourceFileURI, uint32_t aLineNumber,
|
|
|
|
uint32_t aColumnNumber, const nsACString& aMessageName,
|
2015-11-20 21:36:46 +03:00
|
|
|
Params&&... aParams) {
|
2015-10-30 05:53:25 +03:00
|
|
|
nsTArray<nsString> params;
|
2015-11-20 21:36:46 +03:00
|
|
|
mozilla::dom::StringArrayAppender::Append(params, sizeof...(Params),
|
2018-06-01 19:30:30 +03:00
|
|
|
std::forward<Params>(aParams)...);
|
2015-10-30 05:53:25 +03:00
|
|
|
AddConsoleReport(aErrorFlags, aCategory, aPropertiesFile, aSourceFileURI,
|
|
|
|
aLineNumber, aColumnNumber, aMessageName, params);
|
|
|
|
}
|
|
|
|
|
2016-05-23 09:56:46 +03:00
|
|
|
// An enum calss to indicate whether should free the pending reports or not.
|
|
|
|
// Forget Free the pending reports.
|
|
|
|
// Save Keep the pending reports.
|
|
|
|
enum class ReportAction { Forget, Save };
|
|
|
|
|
2017-02-06 04:19:34 +03:00
|
|
|
// Flush all pending reports to the console. May be called from any thread.
|
|
|
|
//
|
|
|
|
// aInnerWindowID A inner window ID representing where to flush the reports.
|
|
|
|
// aAction An action to determine whether to reserve the pending
|
|
|
|
// reports. Defalut action is to forget the report.
|
|
|
|
virtual void FlushReportsToConsole(
|
|
|
|
uint64_t aInnerWindowID, ReportAction aAction = ReportAction::Forget) = 0;
|
|
|
|
|
2018-01-12 20:16:04 +03:00
|
|
|
virtual void FlushReportsToConsoleForServiceWorkerScope(
|
|
|
|
const nsACString& aScope,
|
|
|
|
ReportAction aAction = ReportAction::Forget) = 0;
|
|
|
|
|
2015-11-03 22:20:56 +03:00
|
|
|
// Flush all pending reports to the console. Main thread only.
|
2015-10-30 05:53:25 +03:00
|
|
|
//
|
|
|
|
// aDocument An optional document representing where to flush the
|
|
|
|
// reports. If provided, then the corresponding window's
|
|
|
|
// web console will get the reports. Otherwise the reports
|
|
|
|
// go to the browser console.
|
2016-05-23 09:56:46 +03:00
|
|
|
// aAction An action to determine whether to reserve the pending
|
|
|
|
// reports. Defalut action is to forget the report.
|
|
|
|
virtual void FlushConsoleReports(
|
2019-01-02 16:05:23 +03:00
|
|
|
mozilla::dom::Document* aDocument,
|
|
|
|
ReportAction aAction = ReportAction::Forget) = 0;
|
2015-11-03 22:20:56 +03:00
|
|
|
|
2017-02-06 04:19:34 +03:00
|
|
|
// Flush all pending reports to the console. May be called from any thread.
|
|
|
|
//
|
|
|
|
// aLoadGroup An optional loadGroup representing where to flush the
|
|
|
|
// reports. If provided, then the corresponding window's
|
|
|
|
// web console will get the reports. Otherwise the reports
|
|
|
|
// go to the browser console.
|
|
|
|
// aAction An action to determine whether to reserve the pending
|
|
|
|
// reports. Defalut action is to forget the report.
|
|
|
|
virtual void FlushConsoleReports(
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
ReportAction aAction = ReportAction::Forget) = 0;
|
|
|
|
|
2015-11-03 22:20:56 +03:00
|
|
|
// Flush all pending reports to another collector. May be called from any
|
|
|
|
// thread.
|
|
|
|
//
|
|
|
|
// aCollector A required collector object that will effectively take
|
|
|
|
// ownership of our currently console reports.
|
|
|
|
virtual void FlushConsoleReports(nsIConsoleReportCollector* aCollector) = 0;
|
2016-05-23 09:56:46 +03:00
|
|
|
|
|
|
|
// Clear all pending reports.
|
|
|
|
virtual void ClearConsoleReports() = 0;
|
2015-10-30 05:53:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIConsoleReportCollector,
|
|
|
|
NS_NSICONSOLEREPORTCOLLECTOR_IID)
|
|
|
|
|
|
|
|
#endif // nsIConsoleReportCollector_h
|