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_BroadcastChannelService_h
8 : #define mozilla_dom_BroadcastChannelService_h
9 :
10 : #include "nsISupportsImpl.h"
11 : #include "nsHashKeys.h"
12 : #include "nsClassHashtable.h"
13 :
14 : #ifdef XP_WIN
15 : #undef PostMessage
16 : #endif
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 : class BroadcastChannelParent;
22 : class ClonedMessageData;
23 :
24 : class BroadcastChannelService final
25 : {
26 : public:
27 0 : NS_INLINE_DECL_REFCOUNTING(BroadcastChannelService)
28 :
29 : static already_AddRefed<BroadcastChannelService> GetOrCreate();
30 :
31 : void RegisterActor(BroadcastChannelParent* aParent,
32 : const nsAString& aOriginChannelKey);
33 : void UnregisterActor(BroadcastChannelParent* aParent,
34 : const nsAString& aOriginChannelKey);
35 :
36 : void PostMessage(BroadcastChannelParent* aParent,
37 : const ClonedMessageData& aData,
38 : const nsAString& aOriginChannelKey);
39 :
40 : private:
41 : BroadcastChannelService();
42 : ~BroadcastChannelService();
43 :
44 : // Raw Pointers because the actors keep alive this service.
45 : nsClassHashtable<nsStringHashKey,
46 : nsTArray<BroadcastChannelParent*>> mAgents;
47 : };
48 :
49 : } // namespace dom
50 : } // namespace mozilla
51 :
52 : #endif // mozilla_dom_BroadcastChannelService_h
|