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 file,
5
* You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_dom_ServiceWorkerManagerService_h
8
#define mozilla_dom_ServiceWorkerManagerService_h
9
10
#include "nsISupportsImpl.h"
11
#include "nsHashKeys.h"
12
#include "nsTArray.h"
13
#include "nsTHashtable.h"
14
15
namespace mozilla {
16
17
class OriginAttributes;
18
19
namespace ipc {
20
class PrincipalInfo;
21
} // namespace ipc
22
23
namespace dom {
24
25
class ServiceWorkerManagerParent;
26
class ServiceWorkerRegistrationData;
27
class ServiceWorkerUpdaterParent;
28
29
class ServiceWorkerManagerService final {
30
public:
31
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerManagerService)
32
33
static already_AddRefed<ServiceWorkerManagerService> Get();
34
static already_AddRefed<ServiceWorkerManagerService> GetOrCreate();
35
36
void RegisterActor(ServiceWorkerManagerParent* aParent);
37
void UnregisterActor(ServiceWorkerManagerParent* aParent);
38
39
void PropagateRegistration(uint64_t aParentID,
40
ServiceWorkerRegistrationData& aData);
41
42
void PropagateSoftUpdate(uint64_t aParentID,
43
const OriginAttributes& aOriginAttributes,
44
const nsAString& aScope);
45
46
void PropagateUnregister(uint64_t aParentID,
47
const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
48
const nsAString& aScope);
49
50
void PropagateRemove(uint64_t aParentID, const nsACString& aHost);
51
52
void PropagateRemoveAll(uint64_t aParentID);
53
54
void ProcessUpdaterActor(ServiceWorkerUpdaterParent* aActor,
55
const OriginAttributes& aOriginAttributes,
56
const nsACString& aScope, uint64_t aParentID);
57
58
void UpdaterActorDestroyed(ServiceWorkerUpdaterParent* aActor);
59
60
private:
61
ServiceWorkerManagerService();
62
~ServiceWorkerManagerService();
63
64
nsTHashtable<nsPtrHashKey<ServiceWorkerManagerParent>> mAgents;
65
66
struct PendingUpdaterActor {
67
nsCString mScope;
68
ServiceWorkerUpdaterParent* mActor;
69
uint64_t mParentId;
70
};
71
72
nsTArray<PendingUpdaterActor> mPendingUpdaterActors;
73
};
74
75
} // namespace dom
76
} // namespace mozilla
77
78
#endif // mozilla_dom_ServiceWorkerManagerService_h