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
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_dom_MessageChannel_h
8
#define mozilla_dom_MessageChannel_h
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/ErrorResult.h"
12
#include "mozilla/dom/BindingDeclarations.h"
13
#include "nsCycleCollectionParticipant.h"
14
#include "nsWrapperCache.h"
15
#include "nsCOMPtr.h"
16
17
class nsIGlobalObject;
18
19
namespace mozilla {
20
namespace dom {
21
22
class MessagePort;
23
24
class MessageChannel final : public nsISupports, public nsWrapperCache {
25
public:
26
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
27
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MessageChannel)
28
29
nsIGlobalObject* GetParentObject() const { return mGlobal; }
30
31
virtual JSObject* WrapObject(JSContext* aCx,
32
JS::Handle<JSObject*> aGivenProto) override;
33
34
static already_AddRefed<MessageChannel> Constructor(
35
const GlobalObject& aGlobal, ErrorResult& aRv);
36
37
static already_AddRefed<MessageChannel> Constructor(nsIGlobalObject* aGlobal,
38
ErrorResult& aRv);
39
40
MessagePort* Port1() const { return mPort1; }
41
42
MessagePort* Port2() const { return mPort2; }
43
44
private:
45
explicit MessageChannel(nsIGlobalObject* aGlobal);
46
~MessageChannel();
47
48
nsCOMPtr<nsIGlobalObject> mGlobal;
49
50
RefPtr<MessagePort> mPort1;
51
RefPtr<MessagePort> mPort2;
52
};
53
54
} // namespace dom
55
} // namespace mozilla
56
57
#endif // mozilla_dom_MessageChannel_h