michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_network_Connection_h michael@0: #define mozilla_dom_network_Connection_h michael@0: michael@0: #include "Types.h" michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "mozilla/Observer.h" michael@0: #include "mozilla/dom/NetworkInformationBinding.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsINetworkProperties.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace hal { michael@0: class NetworkInformation; michael@0: } // namespace hal michael@0: michael@0: namespace dom { michael@0: namespace network { michael@0: michael@0: class Connection MOZ_FINAL : public DOMEventTargetHelper michael@0: , public NetworkObserver michael@0: , public nsINetworkProperties michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSINETWORKPROPERTIES michael@0: michael@0: NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) michael@0: michael@0: Connection(); michael@0: michael@0: void Init(nsPIDOMWindow *aWindow); michael@0: void Shutdown(); michael@0: michael@0: // For IObserver michael@0: void Notify(const hal::NetworkInformation& aNetworkInfo); michael@0: michael@0: // WebIDL michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: ConnectionType Type() const { return mType; } michael@0: michael@0: IMPL_EVENT_HANDLER(typechange) michael@0: michael@0: private: michael@0: /** michael@0: * Update the connection information stored in the object using a michael@0: * NetworkInformation object. michael@0: */ michael@0: void UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo); michael@0: michael@0: /** michael@0: * The type of current connection. michael@0: */ michael@0: ConnectionType mType; michael@0: michael@0: /** michael@0: * If the connection is WIFI michael@0: */ michael@0: bool mIsWifi; michael@0: michael@0: /** michael@0: * DHCP Gateway information for IPV4, in network byte order. 0 if unassigned. michael@0: */ michael@0: uint32_t mDHCPGateway; michael@0: }; michael@0: michael@0: } // namespace network michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_network_Connection_h