Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / dom / reporting / ReportingUtils.cpp
blobce7966a0a34337bd742320b94cda5922bfa5b10e
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/. */
7 #include "mozilla/dom/ReportingUtils.h"
8 #include "mozilla/dom/ReportBody.h"
9 #include "mozilla/dom/ReportDeliver.h"
10 #include "mozilla/dom/Report.h"
11 #include "mozilla/ipc/BackgroundChild.h"
12 #include "mozilla/ipc/BackgroundUtils.h"
13 #include "mozilla/ipc/PBackgroundChild.h"
14 #include "nsAtom.h"
15 #include "nsIGlobalObject.h"
17 namespace mozilla::dom {
19 /* static */
20 void ReportingUtils::Report(nsIGlobalObject* aGlobal, nsAtom* aType,
21 const nsAString& aGroupName, const nsAString& aURL,
22 ReportBody* aBody) {
23 MOZ_ASSERT(aGlobal);
24 MOZ_ASSERT(aBody);
26 nsDependentAtomString type(aType);
28 RefPtr<mozilla::dom::Report> report =
29 new mozilla::dom::Report(aGlobal, type, aURL, aBody);
30 aGlobal->BroadcastReport(report);
32 if (!NS_IsMainThread()) {
33 return;
36 nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
37 if (!window) {
38 return;
41 // Send the report to the server.
42 ReportDeliver::Record(window, type, aGroupName, aURL, aBody);
45 } // namespace mozilla::dom