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