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/EndpointForReportParent.h"
8 #include "mozilla/dom/ReportingHeader.h"
9 #include "mozilla/ipc/PBackgroundSharedTypes.h"
10 #include "mozilla/Unused.h"
11 #include "nsIThread.h"
12 #include "nsThreadUtils.h"
14 namespace mozilla::dom
{
16 EndpointForReportParent::EndpointForReportParent()
17 : mPBackgroundThread(NS_GetCurrentThread()), mActive(true) {}
19 EndpointForReportParent::~EndpointForReportParent() = default;
21 void EndpointForReportParent::ActorDestroy(ActorDestroyReason aWhy
) {
25 void EndpointForReportParent::Run(
26 const nsAString
& aGroupName
,
27 const mozilla::ipc::PrincipalInfo
& aPrincipalInfo
) {
28 RefPtr
<EndpointForReportParent
> self
= this;
30 NS_DispatchToMainThread(NS_NewRunnableFunction(
31 "EndpointForReportParent::Run",
32 [self
, aGroupName
= nsString(aGroupName
), aPrincipalInfo
]() {
34 ReportingHeader::GetEndpointForReport(aGroupName
, aPrincipalInfo
, uri
);
35 self
->mPBackgroundThread
->Dispatch(NS_NewRunnableFunction(
36 "EndpointForReportParent::Answer", [self
, uri
]() {
38 Unused
<< self
->Send__delete__(self
, uri
);
44 } // namespace mozilla::dom