2015-05-03 22:32:37 +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: */
|
2015-03-18 19:46:38 +03:00
|
|
|
/* 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/. */
|
|
|
|
|
2018-01-27 00:08:59 +03:00
|
|
|
#ifndef mozilla_dom_ServiceWorkerScriptCache_h
|
|
|
|
#define mozilla_dom_ServiceWorkerScriptCache_h
|
2015-03-18 19:46:38 +03:00
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
|
2015-07-02 15:54:00 +03:00
|
|
|
class nsILoadGroup;
|
2015-03-18 19:46:38 +03:00
|
|
|
class nsIPrincipal;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-03-16 21:51:11 +03:00
|
|
|
class ServiceWorkerRegistrationInfo;
|
|
|
|
|
2015-03-18 19:46:38 +03:00
|
|
|
namespace serviceWorkerScriptCache {
|
|
|
|
|
|
|
|
nsresult PurgeCache(nsIPrincipal* aPrincipal, const nsAString& aCacheName);
|
|
|
|
|
|
|
|
nsresult GenerateCacheName(nsAString& aName);
|
|
|
|
|
2018-04-02 17:50:22 +03:00
|
|
|
enum class OnFailure : uint8_t { DoNothing, Uninstall };
|
|
|
|
|
2015-03-18 19:52:54 +03:00
|
|
|
class CompareCallback {
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2015-04-14 07:05:28 +03:00
|
|
|
/*
|
|
|
|
* If there is an error, ignore aInCacheAndEqual and aNewCacheName.
|
|
|
|
* On success, if the cached result and network result matched,
|
|
|
|
* aInCacheAndEqual will be true and no new cache name is passed, otherwise
|
|
|
|
* use the new cache name to load the ServiceWorker.
|
|
|
|
*/
|
|
|
|
virtual void ComparisonResult(nsresult aStatus, bool aInCacheAndEqual,
|
2018-04-02 17:50:22 +03:00
|
|
|
OnFailure aOnFailure,
|
2015-05-06 08:17:20 +03:00
|
|
|
const nsAString& aNewCacheName,
|
2017-06-07 08:59:48 +03:00
|
|
|
const nsACString& aMaxScope,
|
|
|
|
nsLoadFlags aLoadFlags) = 0;
|
2017-01-04 12:08:58 +03:00
|
|
|
|
2017-01-25 22:51:34 +03:00
|
|
|
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
2015-03-18 19:52:54 +03:00
|
|
|
};
|
|
|
|
|
2015-10-26 05:59:48 +03:00
|
|
|
nsresult Compare(ServiceWorkerRegistrationInfo* aRegistration,
|
|
|
|
nsIPrincipal* aPrincipal, const nsAString& aCacheName,
|
2019-02-28 21:57:46 +03:00
|
|
|
const nsAString& aURL, CompareCallback* aCallback);
|
2015-03-18 19:52:54 +03:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace serviceWorkerScriptCache
|
2015-03-18 19:46:38 +03:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2015-03-18 19:46:38 +03:00
|
|
|
|
2018-01-27 00:08:59 +03:00
|
|
|
#endif // mozilla_dom_ServiceWorkerScriptCache_h
|