/src/mozilla-central/dom/serviceworkers/ServiceWorkerParent.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #include "ServiceWorkerParent.h" |
8 | | |
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" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | using mozilla::dom::ipc::StructuredCloneData; |
19 | | using mozilla::ipc::IPCResult; |
20 | | |
21 | | void |
22 | | ServiceWorkerParent::ActorDestroy(ActorDestroyReason aReason) |
23 | 0 | { |
24 | 0 | if (mProxy) { |
25 | 0 | mProxy->RevokeActor(this); |
26 | 0 | mProxy = nullptr; |
27 | 0 | } |
28 | 0 | } |
29 | | |
30 | | IPCResult |
31 | | ServiceWorkerParent::RecvTeardown() |
32 | 0 | { |
33 | 0 | MaybeSendDelete(); |
34 | 0 | return IPC_OK(); |
35 | 0 | } |
36 | | |
37 | | IPCResult |
38 | | ServiceWorkerParent::RecvPostMessage(const ClonedMessageData& aClonedData, |
39 | | const ClientInfoAndState& aSource) |
40 | 0 | { |
41 | 0 | RefPtr<ServiceWorkerCloneData> data = new ServiceWorkerCloneData(); |
42 | 0 | data->CopyFromClonedMessageDataForBackgroundParent(aClonedData); |
43 | 0 |
|
44 | 0 | mProxy->PostMessage(std::move(data), ClientInfo(aSource.info()), |
45 | 0 | ClientState::FromIPC(aSource.state())); |
46 | 0 |
|
47 | 0 | return IPC_OK(); |
48 | 0 | } |
49 | | |
50 | | ServiceWorkerParent::ServiceWorkerParent() |
51 | | : mDeleteSent(false) |
52 | 0 | { |
53 | 0 | } |
54 | | |
55 | | ServiceWorkerParent::~ServiceWorkerParent() |
56 | 0 | { |
57 | 0 | MOZ_DIAGNOSTIC_ASSERT(!mProxy); |
58 | 0 | } |
59 | | |
60 | | void |
61 | | ServiceWorkerParent::Init(const IPCServiceWorkerDescriptor& aDescriptor) |
62 | 0 | { |
63 | 0 | MOZ_DIAGNOSTIC_ASSERT(!mProxy); |
64 | 0 | mProxy = new ServiceWorkerProxy(ServiceWorkerDescriptor(aDescriptor)); |
65 | 0 | mProxy->Init(this); |
66 | 0 | } |
67 | | |
68 | | void |
69 | | ServiceWorkerParent::MaybeSendDelete() |
70 | 0 | { |
71 | 0 | if (mDeleteSent) { |
72 | 0 | return; |
73 | 0 | } |
74 | 0 | mDeleteSent = true; |
75 | 0 | Unused << Send__delete__(this); |
76 | 0 | } |
77 | | |
78 | | } // namespace dom |
79 | | } // namespace mozilla |