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