Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=mgaudet
[gecko.git] / dom / messagechannel / MessagePortService.h
blobc98900f366ae315db3a0acf15aec453438f53fbc
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/. */
7 #ifndef mozilla_dom_MessagePortService_h
8 #define mozilla_dom_MessagePortService_h
10 #include "nsClassHashtable.h"
11 #include "nsHashKeys.h"
12 #include "nsISupportsImpl.h"
14 namespace mozilla::dom {
16 class MessagePortParent;
17 class SharedMessageBody;
19 class MessagePortService final {
20 public:
21 NS_INLINE_DECL_REFCOUNTING(MessagePortService)
23 // Needs to be public for the MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR
24 // macro.
25 struct NextParent;
27 static MessagePortService* Get();
28 static MessagePortService* GetOrCreate();
30 bool RequestEntangling(MessagePortParent* aParent,
31 const nsID& aDestinationUUID,
32 const uint32_t& aSequenceID);
34 bool DisentanglePort(MessagePortParent* aParent,
35 FallibleTArray<RefPtr<SharedMessageBody>> aMessages);
37 bool ClosePort(MessagePortParent* aParent);
39 bool PostMessages(MessagePortParent* aParent,
40 FallibleTArray<RefPtr<SharedMessageBody>> aMessages);
42 void ParentDestroy(MessagePortParent* aParent);
44 bool ForceClose(const nsID& aUUID, const nsID& aDestinationUUID,
45 const uint32_t& aSequenceID);
47 private:
48 ~MessagePortService() = default;
50 void CloseAll(const nsID& aUUID, bool aForced = false);
51 void MaybeShutdown();
53 class MessagePortServiceData;
55 nsClassHashtable<nsIDHashKey, MessagePortServiceData> mPorts;
58 } // namespace mozilla::dom
60 #endif // mozilla_dom_MessagePortService_h