1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_network_Connection_h
8 #define mozilla_dom_network_Connection_h
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/NetworkInformationBinding.h"
12 #include "nsCycleCollectionParticipant.h"
17 class NetworkInformation
;
26 class Connection
: public DOMEventTargetHelper
{
28 NS_DECL_ISUPPORTS_INHERITED
30 static Connection
* CreateForWindow(nsPIDOMWindowInner
* aWindow
,
31 bool aShouldResistFingerprinting
);
33 static already_AddRefed
<Connection
> CreateForWorker(
34 WorkerPrivate
* aWorkerPrivate
, ErrorResult
& aRv
);
40 virtual JSObject
* WrapObject(JSContext
* aCx
,
41 JS::Handle
<JSObject
*> aGivenProto
) override
;
43 ConnectionType
Type() const {
44 return mShouldResistFingerprinting
45 ? static_cast<ConnectionType
>(ConnectionType::Unknown
)
49 bool GetIsWifi() const {
50 NS_ASSERT_OWNINGTHREAD(Connection
);
54 uint32_t GetDhcpGateway() const {
55 NS_ASSERT_OWNINGTHREAD(Connection
);
60 IMPL_EVENT_HANDLER(typechange
)
63 Connection(nsPIDOMWindowInner
* aWindow
, bool aShouldResistFingerprinting
);
64 virtual ~Connection();
66 void Update(ConnectionType aType
, bool aIsWifi
, uint32_t aDHCPGateway
,
69 virtual void ShutdownInternal() = 0;
73 * If ResistFingerprinting is enabled or disabled.
75 bool mShouldResistFingerprinting
;
78 * The type of current connection.
83 * If the connection is WIFI
88 * DHCP Gateway information for IPV4, in network byte order. 0 if unassigned.
90 uint32_t mDHCPGateway
;
95 } // namespace network
97 } // namespace mozilla
99 #endif // mozilla_dom_network_Connection_h