2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-01-16 16:23:44 +04:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_network_Connection_h
|
|
|
|
#define mozilla_dom_network_Connection_h
|
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2014-03-05 07:54:55 +04:00
|
|
|
#include "mozilla/dom/NetworkInformationBinding.h"
|
2017-06-13 06:10:30 +03:00
|
|
|
#include "nsContentUtils.h"
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-01-16 16:23:44 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2012-01-16 21:14:56 +04:00
|
|
|
|
|
|
|
namespace hal {
|
|
|
|
class NetworkInformation;
|
|
|
|
} // namespace hal
|
|
|
|
|
2012-01-16 16:23:44 +04:00
|
|
|
namespace dom {
|
2017-03-24 22:27:11 +03:00
|
|
|
|
|
|
|
class WorkerPrivate;
|
|
|
|
|
2012-01-16 16:23:44 +04:00
|
|
|
namespace network {
|
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
class Connection : public DOMEventTargetHelper {
|
2012-01-16 16:23:44 +04:00
|
|
|
public:
|
2013-02-07 14:19:08 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-01-16 16:25:13 +04:00
|
|
|
|
2022-03-03 00:27:46 +03:00
|
|
|
static Connection* CreateForWindow(nsPIDOMWindowInner* aWindow,
|
|
|
|
bool aShouldResistFingerprinting);
|
2016-12-15 16:21:09 +03:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
static already_AddRefed<Connection> CreateForWorker(
|
2018-01-31 10:24:08 +03:00
|
|
|
WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
|
2016-12-16 10:50:23 +03:00
|
|
|
|
|
|
|
void Shutdown();
|
2016-12-15 19:06:22 +03:00
|
|
|
|
2014-01-16 14:53:48 +04:00
|
|
|
// WebIDL
|
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2014-01-16 14:53:48 +04:00
|
|
|
|
2017-06-13 06:10:30 +03:00
|
|
|
ConnectionType Type() const {
|
|
|
|
return nsContentUtils::ShouldResistFingerprinting()
|
|
|
|
? static_cast<ConnectionType>(ConnectionType::Unknown)
|
|
|
|
: mType;
|
|
|
|
}
|
2014-01-16 14:53:48 +04:00
|
|
|
|
2022-05-13 08:35:25 +03:00
|
|
|
bool GetIsWifi() const {
|
2018-11-23 18:53:01 +03:00
|
|
|
NS_ASSERT_OWNINGTHREAD(Connection);
|
|
|
|
|
|
|
|
return mIsWifi;
|
|
|
|
}
|
2022-05-13 08:35:25 +03:00
|
|
|
uint32_t GetDhcpGateway() const {
|
2018-11-23 18:53:01 +03:00
|
|
|
NS_ASSERT_OWNINGTHREAD(Connection);
|
|
|
|
|
|
|
|
return mDHCPGateway;
|
|
|
|
}
|
|
|
|
|
2014-03-05 07:54:55 +04:00
|
|
|
IMPL_EVENT_HANDLER(typechange)
|
2014-01-16 14:53:48 +04:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
protected:
|
2022-03-03 00:27:46 +03:00
|
|
|
Connection(nsPIDOMWindowInner* aWindow, bool aShouldResistFingerprinting);
|
2016-12-16 10:50:23 +03:00
|
|
|
virtual ~Connection();
|
2016-12-15 16:36:47 +03:00
|
|
|
|
2017-07-03 00:11:46 +03:00
|
|
|
void Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway,
|
2016-12-16 10:50:23 +03:00
|
|
|
bool aNotify);
|
|
|
|
|
|
|
|
virtual void ShutdownInternal() = 0;
|
2012-01-16 21:14:56 +04:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
private:
|
2022-03-03 00:27:46 +03:00
|
|
|
/**
|
|
|
|
* If ResistFingerprinting is enabled or disabled.
|
|
|
|
*/
|
|
|
|
bool mShouldResistFingerprinting;
|
|
|
|
|
2012-01-16 21:14:56 +04:00
|
|
|
/**
|
2014-03-05 07:54:55 +04:00
|
|
|
* The type of current connection.
|
2012-01-16 21:14:56 +04:00
|
|
|
*/
|
2014-03-05 07:54:55 +04:00
|
|
|
ConnectionType mType;
|
2012-01-16 21:14:56 +04:00
|
|
|
|
2013-07-11 19:39:36 +04:00
|
|
|
/**
|
|
|
|
* If the connection is WIFI
|
|
|
|
*/
|
|
|
|
bool mIsWifi;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DHCP Gateway information for IPV4, in network byte order. 0 if unassigned.
|
|
|
|
*/
|
|
|
|
uint32_t mDHCPGateway;
|
2016-12-16 10:50:23 +03:00
|
|
|
|
|
|
|
bool mBeenShutDown;
|
2012-01-16 16:23:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace network
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_network_Connection_h
|