/src/mozilla-central/dom/serviceworkers/ServiceWorkerRegistrationChild.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 "ServiceWorkerRegistrationChild.h" |
8 | | |
9 | | #include "RemoteServiceWorkerRegistrationImpl.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace dom { |
13 | | |
14 | | using mozilla::ipc::IPCResult; |
15 | | |
16 | | void |
17 | | ServiceWorkerRegistrationChild::ActorDestroy(ActorDestroyReason aReason) |
18 | 0 | { |
19 | 0 | if (mWorkerHolderToken) { |
20 | 0 | mWorkerHolderToken->RemoveListener(this); |
21 | 0 | mWorkerHolderToken = nullptr; |
22 | 0 | } |
23 | 0 |
|
24 | 0 | if (mOwner) { |
25 | 0 | mOwner->RevokeActor(this); |
26 | 0 | MOZ_DIAGNOSTIC_ASSERT(!mOwner); |
27 | 0 | } |
28 | 0 | } |
29 | | |
30 | | IPCResult |
31 | | ServiceWorkerRegistrationChild::RecvUpdateState(const IPCServiceWorkerRegistrationDescriptor& aDescriptor) |
32 | 0 | { |
33 | 0 | if (mOwner) { |
34 | 0 | mOwner->UpdateState(ServiceWorkerRegistrationDescriptor(aDescriptor)); |
35 | 0 | } |
36 | 0 | return IPC_OK(); |
37 | 0 | } |
38 | | |
39 | | void |
40 | | ServiceWorkerRegistrationChild::WorkerShuttingDown() |
41 | 0 | { |
42 | 0 | MaybeStartTeardown(); |
43 | 0 | } |
44 | | |
45 | | ServiceWorkerRegistrationChild::ServiceWorkerRegistrationChild(WorkerHolderToken* aWorkerHolderToken) |
46 | | : mWorkerHolderToken(aWorkerHolderToken) |
47 | | , mOwner(nullptr) |
48 | | , mTeardownStarted(false) |
49 | 0 | { |
50 | 0 | if (mWorkerHolderToken) { |
51 | 0 | mWorkerHolderToken->AddListener(this); |
52 | 0 | } |
53 | 0 | } |
54 | | |
55 | | void |
56 | | ServiceWorkerRegistrationChild::SetOwner(RemoteServiceWorkerRegistrationImpl* aOwner) |
57 | 0 | { |
58 | 0 | MOZ_DIAGNOSTIC_ASSERT(!mOwner); |
59 | 0 | MOZ_DIAGNOSTIC_ASSERT(aOwner); |
60 | 0 | mOwner = aOwner; |
61 | 0 | } |
62 | | |
63 | | void |
64 | | ServiceWorkerRegistrationChild::RevokeOwner(RemoteServiceWorkerRegistrationImpl* aOwner) |
65 | 0 | { |
66 | 0 | MOZ_DIAGNOSTIC_ASSERT(mOwner); |
67 | 0 | MOZ_DIAGNOSTIC_ASSERT(aOwner == mOwner); |
68 | 0 | mOwner = nullptr; |
69 | 0 | } |
70 | | |
71 | | void |
72 | | ServiceWorkerRegistrationChild::MaybeStartTeardown() |
73 | 0 | { |
74 | 0 | if (mTeardownStarted) { |
75 | 0 | return; |
76 | 0 | } |
77 | 0 | mTeardownStarted = true; |
78 | 0 | Unused << SendTeardown(); |
79 | 0 | } |
80 | | |
81 | | } // namespace dom |
82 | | } // namespace mozilla |