diff -r 000000000000 -r 6474c204b198 dom/mobileconnection/src/MobileConnection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dom/mobileconnection/src/MobileConnection.h Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_network_MobileConnection_h +#define mozilla_dom_network_MobileConnection_h + +#include "mozilla/DOMEventTargetHelper.h" +#include "nsIDOMMobileConnection.h" +#include "nsIMobileConnectionProvider.h" +#include "nsCycleCollectionParticipant.h" +#include "nsWeakPtr.h" + +namespace mozilla { +namespace dom { + +class MobileConnection : public DOMEventTargetHelper + , public nsIDOMMozMobileConnection +{ + /** + * Class MobileConnection doesn't actually inherit + * nsIMobileConnectionListener. Instead, it owns an + * nsIMobileConnectionListener derived instance mListener and passes it to + * nsIMobileConnectionProvider. The onreceived events are first delivered to + * mListener and then forwarded to its owner, MobileConnection. See also bug + * 775997 comment #51. + */ + class Listener; + +public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMMOZMOBILECONNECTION + NS_DECL_NSIMOBILECONNECTIONLISTENER + + NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) + + MobileConnection(uint32_t aClientId); + + void Init(nsPIDOMWindow *aWindow); + void Shutdown(); + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection, + DOMEventTargetHelper) + +private: + nsCOMPtr mProvider; + nsRefPtr mListener; + nsWeakPtr mWindow; + + uint32_t mClientId; + + bool CheckPermission(const char* aType); +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_network_MobileConnection_h