|
1 |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
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 nsPIDOMWindow; |
|
18 |
|
19 namespace mozilla { |
|
20 namespace dom { |
|
21 |
|
22 class MessagePort; |
|
23 |
|
24 class MessageChannel MOZ_FINAL : public nsISupports |
|
25 , public nsWrapperCache |
|
26 { |
|
27 public: |
|
28 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
29 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MessageChannel) |
|
30 |
|
31 static bool PrefEnabled(); |
|
32 |
|
33 public: |
|
34 MessageChannel(nsPIDOMWindow* aWindow); |
|
35 |
|
36 ~MessageChannel(); |
|
37 |
|
38 nsPIDOMWindow* |
|
39 GetParentObject() const |
|
40 { |
|
41 return mWindow; |
|
42 } |
|
43 |
|
44 virtual JSObject* |
|
45 WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
46 |
|
47 static already_AddRefed<MessageChannel> |
|
48 Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); |
|
49 |
|
50 MessagePort* |
|
51 Port1() const |
|
52 { |
|
53 return mPort1; |
|
54 } |
|
55 |
|
56 MessagePort* |
|
57 Port2() const |
|
58 { |
|
59 return mPort2; |
|
60 } |
|
61 |
|
62 private: |
|
63 nsCOMPtr<nsPIDOMWindow> mWindow; |
|
64 |
|
65 nsRefPtr<MessagePort> mPort1; |
|
66 nsRefPtr<MessagePort> mPort2; |
|
67 }; |
|
68 |
|
69 } // namespace dom |
|
70 } // namespace mozilla |
|
71 |
|
72 #endif // mozilla_dom_MessageChannel_h |