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 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_dom_network_Connection_h |
michael@0 | 7 | #define mozilla_dom_network_Connection_h |
michael@0 | 8 | |
michael@0 | 9 | #include "Types.h" |
michael@0 | 10 | #include "mozilla/DOMEventTargetHelper.h" |
michael@0 | 11 | #include "mozilla/Observer.h" |
michael@0 | 12 | #include "mozilla/dom/NetworkInformationBinding.h" |
michael@0 | 13 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 14 | #include "nsINetworkProperties.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | |
michael@0 | 18 | namespace hal { |
michael@0 | 19 | class NetworkInformation; |
michael@0 | 20 | } // namespace hal |
michael@0 | 21 | |
michael@0 | 22 | namespace dom { |
michael@0 | 23 | namespace network { |
michael@0 | 24 | |
michael@0 | 25 | class Connection MOZ_FINAL : public DOMEventTargetHelper |
michael@0 | 26 | , public NetworkObserver |
michael@0 | 27 | , public nsINetworkProperties |
michael@0 | 28 | { |
michael@0 | 29 | public: |
michael@0 | 30 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 31 | NS_DECL_NSINETWORKPROPERTIES |
michael@0 | 32 | |
michael@0 | 33 | NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) |
michael@0 | 34 | |
michael@0 | 35 | Connection(); |
michael@0 | 36 | |
michael@0 | 37 | void Init(nsPIDOMWindow *aWindow); |
michael@0 | 38 | void Shutdown(); |
michael@0 | 39 | |
michael@0 | 40 | // For IObserver |
michael@0 | 41 | void Notify(const hal::NetworkInformation& aNetworkInfo); |
michael@0 | 42 | |
michael@0 | 43 | // WebIDL |
michael@0 | 44 | |
michael@0 | 45 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 46 | |
michael@0 | 47 | ConnectionType Type() const { return mType; } |
michael@0 | 48 | |
michael@0 | 49 | IMPL_EVENT_HANDLER(typechange) |
michael@0 | 50 | |
michael@0 | 51 | private: |
michael@0 | 52 | /** |
michael@0 | 53 | * Update the connection information stored in the object using a |
michael@0 | 54 | * NetworkInformation object. |
michael@0 | 55 | */ |
michael@0 | 56 | void UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo); |
michael@0 | 57 | |
michael@0 | 58 | /** |
michael@0 | 59 | * The type of current connection. |
michael@0 | 60 | */ |
michael@0 | 61 | ConnectionType mType; |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * If the connection is WIFI |
michael@0 | 65 | */ |
michael@0 | 66 | bool mIsWifi; |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * DHCP Gateway information for IPV4, in network byte order. 0 if unassigned. |
michael@0 | 70 | */ |
michael@0 | 71 | uint32_t mDHCPGateway; |
michael@0 | 72 | }; |
michael@0 | 73 | |
michael@0 | 74 | } // namespace network |
michael@0 | 75 | } // namespace dom |
michael@0 | 76 | } // namespace mozilla |
michael@0 | 77 | |
michael@0 | 78 | #endif // mozilla_dom_network_Connection_h |