Source code

Revision control

Other Tools

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 "nsString.h"
11
12
class nsILoadGroup;
13
class nsIPrincipal;
14
15
namespace mozilla {
16
namespace dom {
17
18
class ServiceWorkerRegistrationInfo;
19
20
namespace serviceWorkerScriptCache {
21
22
nsresult PurgeCache(nsIPrincipal* aPrincipal, const nsAString& aCacheName);
23
24
nsresult GenerateCacheName(nsAString& aName);
25
26
enum class OnFailure : uint8_t { DoNothing, Uninstall };
27
28
class CompareCallback {
29
public:
30
/*
31
* If there is an error, ignore aInCacheAndEqual and aNewCacheName.
32
* On success, if the cached result and network result matched,
33
* aInCacheAndEqual will be true and no new cache name is passed, otherwise
34
* use the new cache name to load the ServiceWorker.
35
*/
36
virtual void ComparisonResult(nsresult aStatus, bool aInCacheAndEqual,
37
OnFailure aOnFailure,
38
const nsAString& aNewCacheName,
39
const nsACString& aMaxScope,
40
nsLoadFlags aLoadFlags) = 0;
41
42
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
43
};
44
45
nsresult Compare(ServiceWorkerRegistrationInfo* aRegistration,
46
nsIPrincipal* aPrincipal, const nsAString& aCacheName,
47
const nsAString& aURL, CompareCallback* aCallback);
48
49
} // namespace serviceWorkerScriptCache
50
51
} // namespace dom
52
} // namespace mozilla
53
54
#endif // mozilla_dom_ServiceWorkerScriptCache_h