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_MessagePortService_h
8
#define mozilla_dom_MessagePortService_h
9
10
#include "nsClassHashtable.h"
11
#include "nsHashKeys.h"
12
#include "nsISupportsImpl.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
class MessagePortParent;
18
class SharedMessageBody;
19
20
class MessagePortService final {
21
public:
22
NS_INLINE_DECL_REFCOUNTING(MessagePortService)
23
24
// Needs to be public for the MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR
25
// macro.
26
struct NextParent;
27
28
static MessagePortService* Get();
29
static MessagePortService* GetOrCreate();
30
31
bool RequestEntangling(MessagePortParent* aParent,
32
const nsID& aDestinationUUID,
33
const uint32_t& aSequenceID);
34
35
bool DisentanglePort(MessagePortParent* aParent,
36
FallibleTArray<RefPtr<SharedMessageBody>>& aMessages);
37
38
bool ClosePort(MessagePortParent* aParent);
39
40
bool PostMessages(MessagePortParent* aParent,
41
FallibleTArray<RefPtr<SharedMessageBody>>& aMessages);
42
43
void ParentDestroy(MessagePortParent* aParent);
44
45
bool ForceClose(const nsID& aUUID, const nsID& aDestinationUUID,
46
const uint32_t& aSequenceID);
47
48
private:
49
~MessagePortService() = default;
50
51
void CloseAll(const nsID& aUUID, bool aForced = false);
52
void MaybeShutdown();
53
54
class MessagePortServiceData;
55
56
nsClassHashtable<nsIDHashKey, MessagePortServiceData> mPorts;
57
};
58
59
} // namespace dom
60
} // namespace mozilla
61
62
#endif // mozilla_dom_MessagePortService_h