Bug 1699998 - Extract the Enabled() check in TRRService::IsDomainBlocked into TRR::MaybeBlockRequest. r=necko-reviewers,valentin

Currently, we are checking Enabled() without passing the request mode in IsDomainBlocked.
This isn't the right place to do this, it's cleaner if IsDomainBlocked trusts the caller
to have checked Enabled already. We should call Enabled, with the request mode, in
TRR::MaybeBlockDomain() and return early if it's false.

Differential Revision: https://phabricator.services.mozilla.com/D109240
This commit is contained in:
Nihanth Subramanya 2021-03-21 20:20:34 +00:00
parent 4e87b5392e
commit acc81306ba
2 changed files with 6 additions and 4 deletions

View File

@ -167,6 +167,12 @@ bool TRR::MaybeBlockRequest() {
// we also don't check the blocklist for TRR only requests
MOZ_ASSERT(mRec);
// If TRRService isn't enabled anymore for the req, don't do TRR.
if (!gTRRService->Enabled(mRec->mEffectiveTRRMode)) {
RecordReason(TRRSkippedReason::TRR_MODE_NOT_ENABLED);
return true;
}
if (UseDefaultServer() &&
gTRRService->IsTemporarilyBlocked(mHost, mOriginSuffix, mPB, true)) {
if (mType == TRRTYPE_A) {

View File

@ -868,10 +868,6 @@ bool TRRService::MaybeBootstrap(const nsACString& aPossible,
bool TRRService::IsDomainBlocked(const nsACString& aHost,
const nsACString& aOriginSuffix,
bool aPrivateBrowsing) {
if (!Enabled()) {
return true;
}
auto bl = mTRRBLStorage.Lock();
if (bl->IsEmpty()) {
return false;