|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef mozilla_dom_network_MobileConnection_h |
|
6 #define mozilla_dom_network_MobileConnection_h |
|
7 |
|
8 #include "mozilla/DOMEventTargetHelper.h" |
|
9 #include "nsIDOMMobileConnection.h" |
|
10 #include "nsIMobileConnectionProvider.h" |
|
11 #include "nsCycleCollectionParticipant.h" |
|
12 #include "nsWeakPtr.h" |
|
13 |
|
14 namespace mozilla { |
|
15 namespace dom { |
|
16 |
|
17 class MobileConnection : public DOMEventTargetHelper |
|
18 , public nsIDOMMozMobileConnection |
|
19 { |
|
20 /** |
|
21 * Class MobileConnection doesn't actually inherit |
|
22 * nsIMobileConnectionListener. Instead, it owns an |
|
23 * nsIMobileConnectionListener derived instance mListener and passes it to |
|
24 * nsIMobileConnectionProvider. The onreceived events are first delivered to |
|
25 * mListener and then forwarded to its owner, MobileConnection. See also bug |
|
26 * 775997 comment #51. |
|
27 */ |
|
28 class Listener; |
|
29 |
|
30 public: |
|
31 NS_DECL_ISUPPORTS_INHERITED |
|
32 NS_DECL_NSIDOMMOZMOBILECONNECTION |
|
33 NS_DECL_NSIMOBILECONNECTIONLISTENER |
|
34 |
|
35 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) |
|
36 |
|
37 MobileConnection(uint32_t aClientId); |
|
38 |
|
39 void Init(nsPIDOMWindow *aWindow); |
|
40 void Shutdown(); |
|
41 |
|
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection, |
|
43 DOMEventTargetHelper) |
|
44 |
|
45 private: |
|
46 nsCOMPtr<nsIMobileConnectionProvider> mProvider; |
|
47 nsRefPtr<Listener> mListener; |
|
48 nsWeakPtr mWindow; |
|
49 |
|
50 uint32_t mClientId; |
|
51 |
|
52 bool CheckPermission(const char* aType); |
|
53 }; |
|
54 |
|
55 } // namespace dom |
|
56 } // namespace mozilla |
|
57 |
|
58 #endif // mozilla_dom_network_MobileConnection_h |