mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1755372: Cut Over Connection to finer-grained RFP Check r=tjr
Differential Revision: https://phabricator.services.mozilla.com/D138707
This commit is contained in:
parent
c732e21914
commit
b7254935b5
@ -1801,7 +1801,9 @@ network::Connection* Navigator::GetConnection(ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
mConnection = network::Connection::CreateForWindow(mWindow);
|
||||
nsCOMPtr<Document> doc = mWindow->GetExtantDoc();
|
||||
mConnection = network::Connection::CreateForWindow(
|
||||
mWindow, nsContentUtils::ShouldResistFingerprinting(doc));
|
||||
}
|
||||
|
||||
return mConnection;
|
||||
|
@ -23,8 +23,10 @@ namespace mozilla::dom::network {
|
||||
// we're not the only class with that name.
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(dom::network::Connection, DOMEventTargetHelper)
|
||||
|
||||
Connection::Connection(nsPIDOMWindowInner* aWindow)
|
||||
Connection::Connection(nsPIDOMWindowInner* aWindow,
|
||||
bool aShouldResistFingerprinting)
|
||||
: DOMEventTargetHelper(aWindow),
|
||||
mShouldResistFingerprinting(aShouldResistFingerprinting),
|
||||
mType(static_cast<ConnectionType>(kDefaultType)),
|
||||
mIsWifi(kDefaultIsWifi),
|
||||
mDHCPGateway(kDefaultDHCPGateway),
|
||||
@ -63,16 +65,16 @@ void Connection::Update(ConnectionType aType, bool aIsWifi,
|
||||
mIsWifi = aIsWifi;
|
||||
mDHCPGateway = aDHCPGateway;
|
||||
|
||||
if (aNotify && previousType != aType &&
|
||||
!nsContentUtils::ShouldResistFingerprinting()) {
|
||||
if (aNotify && previousType != aType && !mShouldResistFingerprinting) {
|
||||
DispatchTrustedEvent(CHANGE_EVENT_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
Connection* Connection::CreateForWindow(nsPIDOMWindowInner* aWindow) {
|
||||
Connection* Connection::CreateForWindow(nsPIDOMWindowInner* aWindow,
|
||||
bool aShouldResistFingerprinting) {
|
||||
MOZ_ASSERT(aWindow);
|
||||
return new ConnectionMainThread(aWindow);
|
||||
return new ConnectionMainThread(aWindow, aShouldResistFingerprinting);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -28,7 +28,8 @@ class Connection : public DOMEventTargetHelper {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
static Connection* CreateForWindow(nsPIDOMWindowInner* aWindow);
|
||||
static Connection* CreateForWindow(nsPIDOMWindowInner* aWindow,
|
||||
bool aShouldResistFingerprinting);
|
||||
|
||||
static already_AddRefed<Connection> CreateForWorker(
|
||||
WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
|
||||
@ -60,7 +61,7 @@ class Connection : public DOMEventTargetHelper {
|
||||
IMPL_EVENT_HANDLER(typechange)
|
||||
|
||||
protected:
|
||||
Connection(nsPIDOMWindowInner* aWindow);
|
||||
Connection(nsPIDOMWindowInner* aWindow, bool aShouldResistFingerprinting);
|
||||
virtual ~Connection();
|
||||
|
||||
void Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway,
|
||||
@ -69,6 +70,11 @@ class Connection : public DOMEventTargetHelper {
|
||||
virtual void ShutdownInternal() = 0;
|
||||
|
||||
private:
|
||||
/**
|
||||
* If ResistFingerprinting is enabled or disabled.
|
||||
*/
|
||||
bool mShouldResistFingerprinting;
|
||||
|
||||
/**
|
||||
* The type of current connection.
|
||||
*/
|
||||
|
@ -10,8 +10,9 @@
|
||||
|
||||
namespace mozilla::dom::network {
|
||||
|
||||
ConnectionMainThread::ConnectionMainThread(nsPIDOMWindowInner* aWindow)
|
||||
: Connection(aWindow) {
|
||||
ConnectionMainThread::ConnectionMainThread(nsPIDOMWindowInner* aWindow,
|
||||
bool aShouldResistFingerprinting)
|
||||
: Connection(aWindow, aShouldResistFingerprinting) {
|
||||
hal::RegisterNetworkObserver(this);
|
||||
|
||||
hal::NetworkInformation networkInfo;
|
||||
|
@ -18,7 +18,8 @@ namespace network {
|
||||
class ConnectionMainThread final : public Connection,
|
||||
public hal::NetworkObserver {
|
||||
public:
|
||||
explicit ConnectionMainThread(nsPIDOMWindowInner* aWindow);
|
||||
explicit ConnectionMainThread(nsPIDOMWindowInner* aWindow,
|
||||
bool aShouldResistFingerprinting);
|
||||
|
||||
// For IObserver
|
||||
void Notify(const hal::NetworkInformation& aNetworkInfo) override;
|
||||
|
@ -140,7 +140,9 @@ class NotifyRunnable : public WorkerRunnable {
|
||||
/* static */
|
||||
already_AddRefed<ConnectionWorker> ConnectionWorker::Create(
|
||||
WorkerPrivate* aWorkerPrivate, ErrorResult& aRv) {
|
||||
RefPtr<ConnectionWorker> c = new ConnectionWorker();
|
||||
bool shouldResistFingerprinting =
|
||||
aWorkerPrivate->ShouldResistFingerprinting();
|
||||
RefPtr<ConnectionWorker> c = new ConnectionWorker(shouldResistFingerprinting);
|
||||
c->mProxy = ConnectionProxy::Create(aWorkerPrivate, c);
|
||||
if (!c->mProxy) {
|
||||
aRv.ThrowTypeError("The Worker thread is shutting down.");
|
||||
@ -161,7 +163,8 @@ already_AddRefed<ConnectionWorker> ConnectionWorker::Create(
|
||||
return c.forget();
|
||||
}
|
||||
|
||||
ConnectionWorker::ConnectionWorker() : Connection(nullptr) {
|
||||
ConnectionWorker::ConnectionWorker(bool aShouldResistFingerprinting)
|
||||
: Connection(nullptr, aShouldResistFingerprinting) {
|
||||
MOZ_ASSERT(IsCurrentThreadRunningWorker());
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ class ConnectionWorker final : public Connection {
|
||||
WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
ConnectionWorker();
|
||||
explicit ConnectionWorker(bool aShouldResistFingerprinting);
|
||||
~ConnectionWorker();
|
||||
|
||||
virtual void ShutdownInternal() override;
|
||||
|
Loading…
Reference in New Issue
Block a user