Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #ifndef mozilla_dom_MessagePortService_h
6 : #define mozilla_dom_MessagePortService_h
7 :
8 : #include "nsClassHashtable.h"
9 : #include "nsHashKeys.h"
10 : #include "nsISupportsImpl.h"
11 :
12 : namespace mozilla {
13 : namespace dom {
14 :
15 : class MessagePortParent;
16 : class SharedMessagePortMessage;
17 :
18 0 : class MessagePortService final
19 : {
20 : public:
21 0 : NS_INLINE_DECL_REFCOUNTING(MessagePortService)
22 :
23 : static MessagePortService* Get();
24 : static MessagePortService* GetOrCreate();
25 :
26 : bool RequestEntangling(MessagePortParent* aParent,
27 : const nsID& aDestinationUUID,
28 : const uint32_t& aSequenceID);
29 :
30 : bool DisentanglePort(
31 : MessagePortParent* aParent,
32 : FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);
33 :
34 : bool ClosePort(MessagePortParent* aParent);
35 :
36 : bool PostMessages(
37 : MessagePortParent* aParent,
38 : FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);
39 :
40 : void ParentDestroy(MessagePortParent* aParent);
41 :
42 : bool ForceClose(const nsID& aUUID,
43 : const nsID& aDestinationUUID,
44 : const uint32_t& aSequenceID);
45 :
46 : private:
47 0 : ~MessagePortService() {}
48 :
49 : void CloseAll(const nsID& aUUID, bool aForced = false);
50 : void MaybeShutdown();
51 :
52 : class MessagePortServiceData;
53 :
54 : nsClassHashtable<nsIDHashKey, MessagePortServiceData> mPorts;
55 : };
56 :
57 : } // namespace dom
58 : } // namespace mozilla
59 :
60 : #endif // mozilla_dom_MessagePortService_h
|