Bug 1806483 - Enable TSAN cppunittests by default. r=jmaher
[gecko.git] / dom / serviceworkers / ServiceWorkerScriptCache.h
blob5d71840b4689f789fdbe2582e4697b526933c6e2
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 #ifndef mozilla_dom_ServiceWorkerScriptCache_h
8 #define mozilla_dom_ServiceWorkerScriptCache_h
10 #include "nsIRequest.h"
11 #include "nsISupportsImpl.h"
12 #include "nsString.h"
14 class nsILoadGroup;
15 class nsIPrincipal;
17 namespace mozilla::dom {
19 class ServiceWorkerRegistrationInfo;
21 namespace serviceWorkerScriptCache {
23 nsresult PurgeCache(nsIPrincipal* aPrincipal, const nsAString& aCacheName);
25 nsresult GenerateCacheName(nsAString& aName);
27 enum class OnFailure : uint8_t { DoNothing, Uninstall };
29 class CompareCallback {
30 public:
32 * If there is an error, ignore aInCacheAndEqual and aNewCacheName.
33 * On success, if the cached result and network result matched,
34 * aInCacheAndEqual will be true and no new cache name is passed, otherwise
35 * use the new cache name to load the ServiceWorker.
37 virtual void ComparisonResult(nsresult aStatus, bool aInCacheAndEqual,
38 OnFailure aOnFailure,
39 const nsAString& aNewCacheName,
40 const nsACString& aMaxScope,
41 nsLoadFlags aLoadFlags) = 0;
43 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
46 nsresult Compare(ServiceWorkerRegistrationInfo* aRegistration,
47 nsIPrincipal* aPrincipal, const nsAString& aCacheName,
48 const nsAString& aURL, CompareCallback* aCallback);
50 } // namespace serviceWorkerScriptCache
52 } // namespace mozilla::dom
54 #endif // mozilla_dom_ServiceWorkerScriptCache_h