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 SharedMessagePortMessage;
19
20
class MessagePortService final {
21
public:
22
NS_INLINE_DECL_REFCOUNTING(MessagePortService)
23
24
static MessagePortService* Get();
25
static MessagePortService* GetOrCreate();
26
27
bool RequestEntangling(MessagePortParent* aParent,
28
const nsID& aDestinationUUID,
29
const uint32_t& aSequenceID);
30
31
bool DisentanglePort(
32
MessagePortParent* aParent,
33
FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);
34
35
bool ClosePort(MessagePortParent* aParent);
36
37
bool PostMessages(
38
MessagePortParent* aParent,
39
FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);
40
41
void ParentDestroy(MessagePortParent* aParent);
42
43
bool ForceClose(const nsID& aUUID, const nsID& aDestinationUUID,
44
const uint32_t& aSequenceID);
45
46
private:
47
~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