2018-01-24 17:47:16 +00: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/. */
|
|
|
|
#ifndef _mozilla_dom_ServiceWorkerUtils_h
|
|
|
|
#define _mozilla_dom_ServiceWorkerUtils_h
|
|
|
|
|
2018-03-22 20:03:22 +00:00
|
|
|
#include "mozilla/MozPromise.h"
|
2021-06-10 06:01:27 +00:00
|
|
|
#include "mozilla/dom/IPCNavigationPreloadState.h"
|
2018-03-22 20:03:22 +00:00
|
|
|
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
|
2018-04-17 14:46:14 +00:00
|
|
|
#include "nsTArray.h"
|
2018-03-22 20:03:22 +00:00
|
|
|
|
2018-07-09 23:02:39 +00:00
|
|
|
class nsIURI;
|
|
|
|
|
2018-01-24 17:47:16 +00:00
|
|
|
namespace mozilla {
|
2018-04-23 16:46:53 +00:00
|
|
|
|
2018-07-09 23:02:39 +00:00
|
|
|
class CopyableErrorResult;
|
2020-11-23 16:21:38 +00:00
|
|
|
class ErrorResult;
|
2018-04-23 16:46:53 +00:00
|
|
|
|
2018-01-24 17:47:16 +00:00
|
|
|
namespace dom {
|
|
|
|
|
2018-07-09 23:02:39 +00:00
|
|
|
class ClientInfo;
|
2018-04-09 17:54:23 +00:00
|
|
|
class ServiceWorkerRegistrationData;
|
2018-03-22 20:03:22 +00:00
|
|
|
class ServiceWorkerRegistrationDescriptor;
|
2021-06-10 06:01:27 +00:00
|
|
|
struct NavigationPreloadState;
|
2018-03-22 20:03:22 +00:00
|
|
|
|
2021-08-11 14:41:34 +00:00
|
|
|
using ServiceWorkerRegistrationPromise =
|
|
|
|
MozPromise<ServiceWorkerRegistrationDescriptor, CopyableErrorResult, false>;
|
2018-03-22 20:03:22 +00:00
|
|
|
|
2021-08-11 14:41:34 +00:00
|
|
|
using ServiceWorkerRegistrationListPromise =
|
|
|
|
MozPromise<CopyableTArray<ServiceWorkerRegistrationDescriptor>,
|
|
|
|
CopyableErrorResult, false>;
|
2018-04-17 14:46:14 +00:00
|
|
|
|
2021-08-11 14:41:34 +00:00
|
|
|
using NavigationPreloadStatePromise =
|
|
|
|
MozPromise<IPCNavigationPreloadState, CopyableErrorResult, false>;
|
2021-06-10 06:01:27 +00:00
|
|
|
|
2021-08-11 14:41:34 +00:00
|
|
|
using ServiceWorkerRegistrationCallback =
|
|
|
|
std::function<void(const ServiceWorkerRegistrationDescriptor&)>;
|
2018-06-15 19:21:32 +00:00
|
|
|
|
2021-08-11 14:41:34 +00:00
|
|
|
using ServiceWorkerRegistrationListCallback =
|
|
|
|
std::function<void(const nsTArray<ServiceWorkerRegistrationDescriptor>&)>;
|
2018-06-15 19:21:33 +00:00
|
|
|
|
2021-08-11 14:41:34 +00:00
|
|
|
using ServiceWorkerBoolCallback = std::function<void(bool)>;
|
2018-06-15 19:21:33 +00:00
|
|
|
|
2021-08-11 14:41:34 +00:00
|
|
|
using ServiceWorkerFailureCallback = std::function<void(ErrorResult&&)>;
|
2018-06-15 19:21:32 +00:00
|
|
|
|
2021-08-11 14:41:34 +00:00
|
|
|
using NavigationPreloadGetStateCallback =
|
|
|
|
std::function<void(NavigationPreloadState&&)>;
|
2021-06-10 06:01:27 +00:00
|
|
|
|
2018-04-09 17:54:23 +00:00
|
|
|
bool ServiceWorkerRegistrationDataIsValid(
|
|
|
|
const ServiceWorkerRegistrationData& aData);
|
|
|
|
|
2020-02-06 19:56:31 +00:00
|
|
|
void ServiceWorkerScopeAndScriptAreValid(const ClientInfo& aClientInfo,
|
|
|
|
nsIURI* aScopeURI, nsIURI* aScriptURI,
|
|
|
|
ErrorResult& aRv);
|
2018-04-23 16:46:55 +00:00
|
|
|
|
2018-01-24 17:47:16 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // _mozilla_dom_ServiceWorkerUtils_h
|