зеркало из 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",
|
LOG(("nsHttpChannel %p tracking resource=%d, cos=%u",
|
||||||
this, isTrackingResource, mClassOfService));
|
this, isTrackingResource, mClassOfService));
|
||||||
|
|
||||||
if (isTrackingResource) {
|
if (isTrackingResource && IsThirdPartyChannel()) {
|
||||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
|
AddClassFlags(nsIClassOfService::Tail);
|
||||||
services::GetThirdPartyUtil();
|
|
||||||
bool result = false;
|
|
||||||
if (thirdPartyUtil &&
|
|
||||||
NS_SUCCEEDED(thirdPartyUtil->IsThirdPartyChannel(this, nullptr,
|
|
||||||
&result)) &&
|
|
||||||
result) {
|
|
||||||
|
|
||||||
AddClassFlags(nsIClassOfService::Tail);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WaitingForTailUnblock()) {
|
if (WaitingForTailUnblock()) {
|
||||||
|
@ -694,11 +685,7 @@ nsHttpChannel::CheckFastBlocked()
|
||||||
Preferences::AddUintVarCache(&sFastBlockTimeout, "browser.fastblock.timeout");
|
Preferences::AddUintVarCache(&sFastBlockTimeout, "browser.fastblock.timeout");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
|
if (!IsThirdPartyChannel()) {
|
||||||
bool result = false;
|
|
||||||
if (!thirdPartyUtil ||
|
|
||||||
NS_FAILED(thirdPartyUtil->IsThirdPartyChannel(this, nullptr, &result)) ||
|
|
||||||
!result) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,6 +709,29 @@ nsHttpChannel::CheckFastBlocked()
|
||||||
return true;
|
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
|
nsresult
|
||||||
nsHttpChannel::ConnectOnTailUnblock()
|
nsHttpChannel::ConnectOnTailUnblock()
|
||||||
{
|
{
|
||||||
|
@ -2325,13 +2335,8 @@ nsHttpChannel::ProcessResponse()
|
||||||
// We consider top-level tracking resource as non-tracking if not in 3rd
|
// We consider top-level tracking resource as non-tracking if not in 3rd
|
||||||
// party context.
|
// party context.
|
||||||
bool isThirdPartyAndTrackingResource = false;
|
bool isThirdPartyAndTrackingResource = false;
|
||||||
if(mIsTrackingResource) {
|
if (mIsTrackingResource) {
|
||||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
|
isThirdPartyAndTrackingResource = IsThirdPartyChannel();
|
||||||
services::GetThirdPartyUtil();
|
|
||||||
if (thirdPartyUtil) {
|
|
||||||
thirdPartyUtil->IsThirdPartyChannel(this, nullptr,
|
|
||||||
&isThirdPartyAndTrackingResource);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (referrer) {
|
if (referrer) {
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "nsIRaceCacheWithNetwork.h"
|
#include "nsIRaceCacheWithNetwork.h"
|
||||||
#include "mozilla/extensions/PStreamFilterParent.h"
|
#include "mozilla/extensions/PStreamFilterParent.h"
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
|
#include "mozilla/Maybe.h"
|
||||||
|
|
||||||
class nsDNSPrefetch;
|
class nsDNSPrefetch;
|
||||||
class nsICancelable;
|
class nsICancelable;
|
||||||
|
@ -660,6 +661,10 @@ private:
|
||||||
// Check if current channel should be canceled by FastBlock rules.
|
// Check if current channel should be canceled by FastBlock rules.
|
||||||
bool CheckFastBlocked();
|
bool CheckFastBlocked();
|
||||||
|
|
||||||
|
// This caches the result of mozIThirdPartyUtil::IsThirdPartyChannel.
|
||||||
|
bool IsThirdPartyChannel();
|
||||||
|
Maybe<bool> mIsThirdPartyChannel;
|
||||||
|
|
||||||
nsCString mUsername;
|
nsCString mUsername;
|
||||||
|
|
||||||
// If non-null, warnings should be reported to this object.
|
// If non-null, warnings should be reported to this object.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче