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 #include "ServiceWorkerParent.h"
9 #include "ServiceWorkerCloneData.h"
10 #include "ServiceWorkerProxy.h"
11 #include "mozilla/dom/ClientInfo.h"
12 #include "mozilla/dom/ClientState.h"
13 #include "mozilla/dom/ipc/StructuredCloneData.h"
15 namespace mozilla::dom
{
17 using mozilla::dom::ipc::StructuredCloneData
;
18 using mozilla::ipc::IPCResult
;
20 void ServiceWorkerParent::ActorDestroy(ActorDestroyReason aReason
) {
22 mProxy
->RevokeActor(this);
27 IPCResult
ServiceWorkerParent::RecvTeardown() {
32 IPCResult
ServiceWorkerParent::RecvPostMessage(
33 const ClonedOrErrorMessageData
& aClonedData
,
34 const PostMessageSource
& aSource
) {
35 RefPtr
<ServiceWorkerCloneData
> data
= new ServiceWorkerCloneData();
36 data
->CopyFromClonedMessageData(aClonedData
);
38 mProxy
->PostMessage(std::move(data
), aSource
);
43 ServiceWorkerParent::ServiceWorkerParent() : mDeleteSent(false) {}
45 ServiceWorkerParent::~ServiceWorkerParent() { MOZ_DIAGNOSTIC_ASSERT(!mProxy
); }
47 void ServiceWorkerParent::Init(const IPCServiceWorkerDescriptor
& aDescriptor
) {
48 MOZ_DIAGNOSTIC_ASSERT(!mProxy
);
49 mProxy
= new ServiceWorkerProxy(ServiceWorkerDescriptor(aDescriptor
));
53 void ServiceWorkerParent::MaybeSendDelete() {
58 Unused
<< Send__delete__(this);
61 } // namespace mozilla::dom