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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_MessageChannel_h
8 #define mozilla_dom_MessageChannel_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/BindingDeclarations.h"
12 #include "nsCycleCollectionParticipant.h"
13 #include "nsWrapperCache.h"
16 class nsIGlobalObject
;
25 class MessageChannel final
: public nsISupports
, public nsWrapperCache
{
27 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
28 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(MessageChannel
)
30 nsIGlobalObject
* GetParentObject() const { return mGlobal
; }
32 virtual JSObject
* WrapObject(JSContext
* aCx
,
33 JS::Handle
<JSObject
*> aGivenProto
) override
;
35 static already_AddRefed
<MessageChannel
> Constructor(
36 const GlobalObject
& aGlobal
, ErrorResult
& aRv
);
38 static already_AddRefed
<MessageChannel
> Constructor(nsIGlobalObject
* aGlobal
,
41 MessagePort
* Port1() const { return mPort1
; }
43 MessagePort
* Port2() const { return mPort2
; }
46 explicit MessageChannel(nsIGlobalObject
* aGlobal
);
49 nsCOMPtr
<nsIGlobalObject
> mGlobal
;
51 RefPtr
<MessagePort
> mPort1
;
52 RefPtr
<MessagePort
> mPort2
;
56 } // namespace mozilla
58 #endif // mozilla_dom_MessageChannel_h