Bug 1842773 - Part 18: Update TypedArray length, byteLength, and byteOffset accesses...
[gecko.git] / dom / serviceworkers / ServiceWorkerUtils.h
blob8140c3225afb7a44c71f8b230e22dd4ae67589c6
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 #ifndef _mozilla_dom_ServiceWorkerUtils_h
7 #define _mozilla_dom_ServiceWorkerUtils_h
9 #include "mozilla/MozPromise.h"
10 #include "mozilla/dom/IPCNavigationPreloadState.h"
11 #include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
12 #include "nsTArray.h"
14 class nsIURI;
16 namespace mozilla {
18 class CopyableErrorResult;
19 class ErrorResult;
21 namespace dom {
23 class ClientInfo;
24 class ServiceWorkerRegistrationData;
25 class ServiceWorkerRegistrationDescriptor;
26 struct NavigationPreloadState;
28 using ServiceWorkerRegistrationPromise =
29 MozPromise<ServiceWorkerRegistrationDescriptor, CopyableErrorResult, false>;
31 using ServiceWorkerRegistrationListPromise =
32 MozPromise<CopyableTArray<ServiceWorkerRegistrationDescriptor>,
33 CopyableErrorResult, false>;
35 using NavigationPreloadStatePromise =
36 MozPromise<IPCNavigationPreloadState, CopyableErrorResult, false>;
38 using ServiceWorkerRegistrationCallback =
39 std::function<void(const ServiceWorkerRegistrationDescriptor&)>;
41 using ServiceWorkerRegistrationListCallback =
42 std::function<void(const nsTArray<ServiceWorkerRegistrationDescriptor>&)>;
44 using ServiceWorkerBoolCallback = std::function<void(bool)>;
46 using ServiceWorkerFailureCallback = std::function<void(ErrorResult&&)>;
48 using NavigationPreloadGetStateCallback =
49 std::function<void(NavigationPreloadState&&)>;
51 bool ServiceWorkerRegistrationDataIsValid(
52 const ServiceWorkerRegistrationData& aData);
54 void ServiceWorkerScopeAndScriptAreValid(const ClientInfo& aClientInfo,
55 nsIURI* aScopeURI, nsIURI* aScriptURI,
56 ErrorResult& aRv);
58 bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aGlobal);
60 bool ServiceWorkerVisible(JSContext* aCx, JSObject* aGlobal);
62 } // namespace dom
63 } // namespace mozilla
65 #endif // _mozilla_dom_ServiceWorkerUtils_h