зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1752907: Cut over Hardware Concurrency to finer-grained RFP Check r=tjr
Differential Revision: https://phabricator.services.mozilla.com/D137481
This commit is contained in:
Родитель
94c2c41214
Коммит
430822123f
|
@ -649,7 +649,8 @@ uint64_t Navigator::HardwareConcurrency() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
return rts->ClampedHardwareConcurrency();
|
||||
return rts->ClampedHardwareConcurrency(
|
||||
nsContentUtils::ShouldResistFingerprinting(mWindow->GetExtantDoc()));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -1992,11 +1992,12 @@ void RuntimeService::MemoryPressureAllWorkers() {
|
|||
BroadcastAllWorkers([](auto& worker) { worker.MemoryPressure(); });
|
||||
}
|
||||
|
||||
uint32_t RuntimeService::ClampedHardwareConcurrency() const {
|
||||
uint32_t RuntimeService::ClampedHardwareConcurrency(
|
||||
bool aShouldResistFingerprinting) const {
|
||||
// The Firefox Hardware Report says 70% of Firefox users have exactly 2 cores.
|
||||
// When the resistFingerprinting pref is set, we want to blend into the crowd
|
||||
// so spoof navigator.hardwareConcurrency = 2 to reduce user uniqueness.
|
||||
if (MOZ_UNLIKELY(nsContentUtils::ShouldResistFingerprinting())) {
|
||||
if (MOZ_UNLIKELY(aShouldResistFingerprinting)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ class RuntimeService final : public nsIObserver {
|
|||
|
||||
void MemoryPressureAllWorkers();
|
||||
|
||||
uint32_t ClampedHardwareConcurrency() const;
|
||||
uint32_t ClampedHardwareConcurrency(bool aShouldResistFingerprinting) const;
|
||||
|
||||
void CrashIfHanging();
|
||||
|
||||
|
|
|
@ -176,7 +176,10 @@ uint64_t WorkerNavigator::HardwareConcurrency() const {
|
|||
RuntimeService* rts = RuntimeService::GetService();
|
||||
MOZ_ASSERT(rts);
|
||||
|
||||
return rts->ClampedHardwareConcurrency();
|
||||
WorkerPrivate* aWorkerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
bool rfp = aWorkerPrivate->ShouldResistFingerprinting();
|
||||
|
||||
return rts->ClampedHardwareConcurrency(rfp);
|
||||
}
|
||||
|
||||
StorageManager* WorkerNavigator::Storage() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче