Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/serviceworkers/ServiceWorkerManagerChild.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 "ServiceWorkerManagerChild.h"
8
#include "ServiceWorkerManager.h"
9
#include "ServiceWorkerUpdaterChild.h"
10
#include "mozilla/Unused.h"
11
12
namespace mozilla {
13
14
using namespace ipc;
15
16
namespace dom {
17
18
mozilla::ipc::IPCResult
19
ServiceWorkerManagerChild::RecvNotifyRegister(
20
                                     const ServiceWorkerRegistrationData& aData)
21
0
{
22
0
  if (mShuttingDown) {
23
0
    return IPC_OK();
24
0
  }
25
0
26
0
  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
27
0
  if (swm) {
28
0
    swm->LoadRegistration(aData);
29
0
  }
30
0
31
0
  return IPC_OK();
32
0
}
33
34
mozilla::ipc::IPCResult
35
ServiceWorkerManagerChild::RecvNotifySoftUpdate(
36
                                      const OriginAttributes& aOriginAttributes,
37
                                      const nsString& aScope)
38
0
{
39
0
  if (mShuttingDown) {
40
0
    return IPC_OK();
41
0
  }
42
0
43
0
  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
44
0
  if (swm) {
45
0
    swm->SoftUpdate(aOriginAttributes, NS_ConvertUTF16toUTF8(aScope));
46
0
  }
47
0
48
0
  return IPC_OK();
49
0
}
50
51
mozilla::ipc::IPCResult
52
ServiceWorkerManagerChild::RecvNotifyUnregister(const PrincipalInfo& aPrincipalInfo,
53
                                                const nsString& aScope)
54
0
{
55
0
  if (mShuttingDown) {
56
0
    return IPC_OK();
57
0
  }
58
0
59
0
  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
60
0
  if (!swm) {
61
0
    // browser shutdown
62
0
    return IPC_OK();
63
0
  }
64
0
65
0
  nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(aPrincipalInfo);
66
0
  if (NS_WARN_IF(!principal)) {
67
0
    return IPC_OK();
68
0
  }
69
0
70
0
  nsresult rv = swm->NotifyUnregister(principal, aScope);
71
0
  Unused << NS_WARN_IF(NS_FAILED(rv));
72
0
  return IPC_OK();
73
0
}
74
75
mozilla::ipc::IPCResult
76
ServiceWorkerManagerChild::RecvNotifyRemove(const nsCString& aHost)
77
0
{
78
0
  if (mShuttingDown) {
79
0
    return IPC_OK();
80
0
  }
81
0
82
0
  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
83
0
  if (swm) {
84
0
    swm->Remove(aHost);
85
0
  }
86
0
87
0
  return IPC_OK();
88
0
}
89
90
mozilla::ipc::IPCResult
91
ServiceWorkerManagerChild::RecvNotifyRemoveAll()
92
0
{
93
0
  if (mShuttingDown) {
94
0
    return IPC_OK();
95
0
  }
96
0
97
0
  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
98
0
  if (swm) {
99
0
    swm->RemoveAll();
100
0
  }
101
0
102
0
  return IPC_OK();
103
0
}
104
105
PServiceWorkerUpdaterChild*
106
ServiceWorkerManagerChild::AllocPServiceWorkerUpdaterChild(const OriginAttributes& aOriginAttributes,
107
                                                           const nsCString& aScope)
108
0
{
109
0
  MOZ_CRASH("Do no use ServiceWorkerUpdaterChild IPC CTOR.");
110
0
}
111
112
bool
113
ServiceWorkerManagerChild::DeallocPServiceWorkerUpdaterChild(PServiceWorkerUpdaterChild* aActor)
114
0
{
115
0
  delete aActor;
116
0
  return true;
117
0
}
118
119
} // namespace dom
120
} // namespace mozilla