Bug 1554951 [wpt PR 17043] - wake-lock: Fix invalid types test in wakelock-type.https...
[gecko.git] / dom / serviceworkers / ServiceWorkerManagerChild.cpp
blobbca901ab82cafc9c610b063c72aa92f55ed90103
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 "ServiceWorkerManagerChild.h"
8 #include "ServiceWorkerManager.h"
9 #include "ServiceWorkerUpdaterChild.h"
10 #include "mozilla/Unused.h"
12 namespace mozilla {
14 using namespace ipc;
16 namespace dom {
18 mozilla::ipc::IPCResult ServiceWorkerManagerChild::RecvNotifyRegister(
19 const ServiceWorkerRegistrationData& aData) {
20 if (mShuttingDown) {
21 return IPC_OK();
24 RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
25 if (swm) {
26 swm->LoadRegistration(aData);
29 return IPC_OK();
32 mozilla::ipc::IPCResult ServiceWorkerManagerChild::RecvNotifySoftUpdate(
33 const OriginAttributes& aOriginAttributes, const nsString& aScope) {
34 if (mShuttingDown) {
35 return IPC_OK();
38 RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
39 if (swm) {
40 swm->SoftUpdate(aOriginAttributes, NS_ConvertUTF16toUTF8(aScope));
43 return IPC_OK();
46 mozilla::ipc::IPCResult ServiceWorkerManagerChild::RecvNotifyUnregister(
47 const PrincipalInfo& aPrincipalInfo, const nsString& aScope) {
48 if (mShuttingDown) {
49 return IPC_OK();
52 RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
53 if (!swm) {
54 // browser shutdown
55 return IPC_OK();
58 nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(aPrincipalInfo);
59 if (NS_WARN_IF(!principal)) {
60 return IPC_OK();
63 nsresult rv = swm->NotifyUnregister(principal, aScope);
64 Unused << NS_WARN_IF(NS_FAILED(rv));
65 return IPC_OK();
68 mozilla::ipc::IPCResult ServiceWorkerManagerChild::RecvNotifyRemove(
69 const nsCString& aHost) {
70 if (mShuttingDown) {
71 return IPC_OK();
74 RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
75 if (swm) {
76 swm->Remove(aHost);
79 return IPC_OK();
82 mozilla::ipc::IPCResult ServiceWorkerManagerChild::RecvNotifyRemoveAll() {
83 if (mShuttingDown) {
84 return IPC_OK();
87 RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
88 if (swm) {
89 swm->RemoveAll();
92 return IPC_OK();
95 PServiceWorkerUpdaterChild*
96 ServiceWorkerManagerChild::AllocPServiceWorkerUpdaterChild(
97 const OriginAttributes& aOriginAttributes, const nsCString& aScope) {
98 MOZ_CRASH("Do no use ServiceWorkerUpdaterChild IPC CTOR.");
101 bool ServiceWorkerManagerChild::DeallocPServiceWorkerUpdaterChild(
102 PServiceWorkerUpdaterChild* aActor) {
103 delete aActor;
104 return true;
107 } // namespace dom
108 } // namespace mozilla