2015-06-04 21:51:57 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "ServiceWorkerManagerChild.h"
|
|
|
|
#include "ServiceWorkerManager.h"
|
2017-03-28 12:48:38 +03:00
|
|
|
#include "ServiceWorkerUpdaterChild.h"
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2015-06-04 21:51:57 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
using namespace ipc;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
namespace workers {
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-06-04 21:51:57 +03:00
|
|
|
ServiceWorkerManagerChild::RecvNotifyRegister(
|
|
|
|
const ServiceWorkerRegistrationData& aData)
|
|
|
|
{
|
|
|
|
if (mShuttingDown) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-04 21:51:57 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
2017-01-13 01:00:36 +03:00
|
|
|
if (swm) {
|
|
|
|
swm->LoadRegistration(aData);
|
|
|
|
}
|
2015-06-04 21:51:57 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-04 21:51:57 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-06-04 21:51:57 +03:00
|
|
|
ServiceWorkerManagerChild::RecvNotifySoftUpdate(
|
2017-01-12 19:38:48 +03:00
|
|
|
const OriginAttributes& aOriginAttributes,
|
2015-06-04 21:51:57 +03:00
|
|
|
const nsString& aScope)
|
|
|
|
{
|
|
|
|
if (mShuttingDown) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-04 21:51:57 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
2017-01-13 01:00:36 +03:00
|
|
|
if (swm) {
|
|
|
|
swm->SoftUpdate(aOriginAttributes, NS_ConvertUTF16toUTF8(aScope));
|
|
|
|
}
|
2015-06-04 21:51:57 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-04 21:51:57 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-06-04 21:51:57 +03:00
|
|
|
ServiceWorkerManagerChild::RecvNotifyUnregister(const PrincipalInfo& aPrincipalInfo,
|
|
|
|
const nsString& aScope)
|
|
|
|
{
|
|
|
|
if (mShuttingDown) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-04 21:51:57 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
2017-01-13 01:00:36 +03:00
|
|
|
if (!swm) {
|
|
|
|
// browser shutdown
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2015-06-04 21:51:57 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(aPrincipalInfo);
|
|
|
|
if (NS_WARN_IF(!principal)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-04 21:51:57 +03:00
|
|
|
}
|
|
|
|
|
2016-02-20 09:03:00 +03:00
|
|
|
nsresult rv = swm->NotifyUnregister(principal, aScope);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << NS_WARN_IF(NS_FAILED(rv));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-04 21:51:57 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-06-21 14:19:07 +03:00
|
|
|
ServiceWorkerManagerChild::RecvNotifyRemove(const nsCString& aHost)
|
|
|
|
{
|
|
|
|
if (mShuttingDown) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-21 14:19:07 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
2017-01-13 01:00:36 +03:00
|
|
|
if (swm) {
|
|
|
|
swm->Remove(aHost);
|
|
|
|
}
|
2015-06-21 14:19:07 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-21 14:19:07 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-06-21 14:17:58 +03:00
|
|
|
ServiceWorkerManagerChild::RecvNotifyRemoveAll()
|
|
|
|
{
|
|
|
|
if (mShuttingDown) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-21 14:17:58 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
2017-01-13 01:00:36 +03:00
|
|
|
if (swm) {
|
|
|
|
swm->RemoveAll();
|
|
|
|
}
|
2015-06-21 14:17:58 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-21 14:17:58 +03:00
|
|
|
}
|
|
|
|
|
2017-03-28 12:48:38 +03:00
|
|
|
PServiceWorkerUpdaterChild*
|
|
|
|
ServiceWorkerManagerChild::AllocPServiceWorkerUpdaterChild(const OriginAttributes& aOriginAttributes,
|
|
|
|
const nsCString& aScope)
|
|
|
|
{
|
|
|
|
MOZ_CRASH("Do no use ServiceWorkerUpdaterChild IPC CTOR.");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ServiceWorkerManagerChild::DeallocPServiceWorkerUpdaterChild(PServiceWorkerUpdaterChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace workers
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|