|
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/. */ |
|
5 |
|
6 #ifndef mozilla_dom_network_Connection_h |
|
7 #define mozilla_dom_network_Connection_h |
|
8 |
|
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" |
|
15 |
|
16 namespace mozilla { |
|
17 |
|
18 namespace hal { |
|
19 class NetworkInformation; |
|
20 } // namespace hal |
|
21 |
|
22 namespace dom { |
|
23 namespace network { |
|
24 |
|
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 |
|
32 |
|
33 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) |
|
34 |
|
35 Connection(); |
|
36 |
|
37 void Init(nsPIDOMWindow *aWindow); |
|
38 void Shutdown(); |
|
39 |
|
40 // For IObserver |
|
41 void Notify(const hal::NetworkInformation& aNetworkInfo); |
|
42 |
|
43 // WebIDL |
|
44 |
|
45 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
46 |
|
47 ConnectionType Type() const { return mType; } |
|
48 |
|
49 IMPL_EVENT_HANDLER(typechange) |
|
50 |
|
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); |
|
57 |
|
58 /** |
|
59 * The type of current connection. |
|
60 */ |
|
61 ConnectionType mType; |
|
62 |
|
63 /** |
|
64 * If the connection is WIFI |
|
65 */ |
|
66 bool mIsWifi; |
|
67 |
|
68 /** |
|
69 * DHCP Gateway information for IPV4, in network byte order. 0 if unassigned. |
|
70 */ |
|
71 uint32_t mDHCPGateway; |
|
72 }; |
|
73 |
|
74 } // namespace network |
|
75 } // namespace dom |
|
76 } // namespace mozilla |
|
77 |
|
78 #endif // mozilla_dom_network_Connection_h |