зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1482117 - Part 2: cache the result of IsThirdPartyChannel; r=mayhemer
cache the result to speed up Differential Revision: https://phabricator.services.mozilla.com/D3423 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
837bec1102
Коммит
a0692d51f7
|
@ -630,17 +630,8 @@ nsHttpChannel::Connect()
|
|||
LOG(("nsHttpChannel %p tracking resource=%d, cos=%u",
|
||||
this, isTrackingResource, mClassOfService));
|
||||
|
||||
if (isTrackingResource) {
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
|
||||
services::GetThirdPartyUtil();
|
||||
bool result = false;
|
||||
if (thirdPartyUtil &&
|
||||
NS_SUCCEEDED(thirdPartyUtil->IsThirdPartyChannel(this, nullptr,
|
||||
&result)) &&
|
||||
result) {
|
||||
|
||||
AddClassFlags(nsIClassOfService::Tail);
|
||||
}
|
||||
if (isTrackingResource && IsThirdPartyChannel()) {
|
||||
AddClassFlags(nsIClassOfService::Tail);
|
||||
}
|
||||
|
||||
if (WaitingForTailUnblock()) {
|
||||
|
@ -694,11 +685,7 @@ nsHttpChannel::CheckFastBlocked()
|
|||
Preferences::AddUintVarCache(&sFastBlockTimeout, "browser.fastblock.timeout");
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
|
||||
bool result = false;
|
||||
if (!thirdPartyUtil ||
|
||||
NS_FAILED(thirdPartyUtil->IsThirdPartyChannel(this, nullptr, &result)) ||
|
||||
!result) {
|
||||
if (!IsThirdPartyChannel()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -722,6 +709,29 @@ nsHttpChannel::CheckFastBlocked()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
nsHttpChannel::IsThirdPartyChannel()
|
||||
{
|
||||
if (mIsThirdPartyChannel) {
|
||||
return *mIsThirdPartyChannel;
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
|
||||
if (!thirdPartyUtil) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isThirdPartyChannel;
|
||||
if (NS_FAILED(thirdPartyUtil->IsThirdPartyChannel(this,
|
||||
nullptr,
|
||||
&isThirdPartyChannel))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mIsThirdPartyChannel.emplace(isThirdPartyChannel);
|
||||
return *mIsThirdPartyChannel;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHttpChannel::ConnectOnTailUnblock()
|
||||
{
|
||||
|
@ -2325,13 +2335,8 @@ nsHttpChannel::ProcessResponse()
|
|||
// We consider top-level tracking resource as non-tracking if not in 3rd
|
||||
// party context.
|
||||
bool isThirdPartyAndTrackingResource = false;
|
||||
if(mIsTrackingResource) {
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
|
||||
services::GetThirdPartyUtil();
|
||||
if (thirdPartyUtil) {
|
||||
thirdPartyUtil->IsThirdPartyChannel(this, nullptr,
|
||||
&isThirdPartyAndTrackingResource);
|
||||
}
|
||||
if (mIsTrackingResource) {
|
||||
isThirdPartyAndTrackingResource = IsThirdPartyChannel();
|
||||
}
|
||||
|
||||
if (referrer) {
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "nsIRaceCacheWithNetwork.h"
|
||||
#include "mozilla/extensions/PStreamFilterParent.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
class nsDNSPrefetch;
|
||||
class nsICancelable;
|
||||
|
@ -660,6 +661,10 @@ private:
|
|||
// Check if current channel should be canceled by FastBlock rules.
|
||||
bool CheckFastBlocked();
|
||||
|
||||
// This caches the result of mozIThirdPartyUtil::IsThirdPartyChannel.
|
||||
bool IsThirdPartyChannel();
|
||||
Maybe<bool> mIsThirdPartyChannel;
|
||||
|
||||
nsCString mUsername;
|
||||
|
||||
// If non-null, warnings should be reported to this object.
|
||||
|
|
Загрузка…
Ссылка в новой задаче