ServiceWorkerScriptCache.h (1824B)
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 #ifndef mozilla_dom_ServiceWorkerScriptCache_h 8 #define mozilla_dom_ServiceWorkerScriptCache_h 9 10 #include "nsIRequest.h" 11 #include "nsISupportsImpl.h" 12 #include "nsString.h" 13 14 class nsILoadGroup; 15 class nsIPrincipal; 16 17 namespace mozilla::dom { 18 19 class ServiceWorkerRegistrationInfo; 20 21 namespace serviceWorkerScriptCache { 22 23 nsresult PurgeCache(nsIPrincipal* aPrincipal, const nsAString& aCacheName); 24 25 nsresult GenerateCacheName(nsAString& aName); 26 27 enum class OnFailure : uint8_t { DoNothing, Uninstall }; 28 29 class CompareCallback { 30 public: 31 /* 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. 36 */ 37 virtual void ComparisonResult(nsresult aStatus, bool aInCacheAndEqual, 38 OnFailure aOnFailure, 39 const nsAString& aNewCacheName, 40 const nsACString& aMaxScope, 41 nsLoadFlags aLoadFlags) = 0; 42 43 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING 44 }; 45 46 nsresult Compare(ServiceWorkerRegistrationInfo* aRegistration, 47 nsIPrincipal* aPrincipal, const nsAString& aCacheName, 48 const nsACString& aURL, CompareCallback* aCallback); 49 50 } // namespace serviceWorkerScriptCache 51 52 } // namespace mozilla::dom 53 54 #endif // mozilla_dom_ServiceWorkerScriptCache_h