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