Backed out 2 changesets (bug 1908320) for causing wr failures on align-items-baseline...
[gecko.git] / dom / network / Connection.h
blob9d18ad089bb9b897671cb89711c9a6bc469172ca
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"
14 namespace mozilla {
16 namespace hal {
17 class NetworkInformation;
18 } // namespace hal
20 namespace dom {
22 class WorkerPrivate;
24 namespace network {
26 class Connection : public DOMEventTargetHelper {
27 public:
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);
36 void Shutdown();
38 // WebIDL
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)
46 : mType;
49 bool GetIsWifi() const {
50 NS_ASSERT_OWNINGTHREAD(Connection);
52 return mIsWifi;
54 uint32_t GetDhcpGateway() const {
55 NS_ASSERT_OWNINGTHREAD(Connection);
57 return mDHCPGateway;
60 IMPL_EVENT_HANDLER(typechange)
62 protected:
63 Connection(nsPIDOMWindowInner* aWindow, bool aShouldResistFingerprinting);
64 virtual ~Connection();
66 void Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway,
67 bool aNotify);
69 virtual void ShutdownInternal() = 0;
71 private:
72 /**
73 * If ResistFingerprinting is enabled or disabled.
75 bool mShouldResistFingerprinting;
77 /**
78 * The type of current connection.
80 ConnectionType mType;
82 /**
83 * If the connection is WIFI
85 bool mIsWifi;
87 /**
88 * DHCP Gateway information for IPV4, in network byte order. 0 if unassigned.
90 uint32_t mDHCPGateway;
92 bool mBeenShutDown;
95 } // namespace network
96 } // namespace dom
97 } // namespace mozilla
99 #endif // mozilla_dom_network_Connection_h