mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1163196 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj
Check that logging is enabled before performing potentially expensive operations.
This commit is contained in:
parent
1f5e3508bb
commit
d69a9e6570
@ -51,7 +51,8 @@ GetCspContextLog()
|
||||
return gCspContextPRLog;
|
||||
}
|
||||
|
||||
#define CSPCONTEXTLOG(args) PR_LOG(GetCspContextLog(), 4, args)
|
||||
#define CSPCONTEXTLOG(args) PR_LOG(GetCspContextLog(), PR_LOG_DEBUG, args)
|
||||
#define CSPCONTEXTLOGENABLED() PR_LOG_TEST(GetCspContextLog(), PR_LOG_DEBUG)
|
||||
|
||||
static const uint32_t CSP_CACHE_URI_CUTOFF_SIZE = 512;
|
||||
|
||||
@ -105,10 +106,10 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
|
||||
nsISupports* aExtra,
|
||||
int16_t* outDecision)
|
||||
{
|
||||
{
|
||||
nsAutoCString spec;
|
||||
aContentLocation->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::ShouldLoad, aContentLocation: %s", spec.get()));
|
||||
if (CSPCONTEXTLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aContentLocation->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::ShouldLoad, aContentLocation: %s", spec.get()));
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
@ -193,10 +194,10 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
|
||||
mShouldLoadCache.Put(cacheKey, *outDecision);
|
||||
}
|
||||
|
||||
{
|
||||
nsAutoCString spec;
|
||||
aContentLocation->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::ShouldLoad, decision: %s, aContentLocation: %s", *outDecision ? "load" : "deny", spec.get()));
|
||||
if (CSPCONTEXTLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aContentLocation->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::ShouldLoad, decision: %s, aContentLocation: %s", *outDecision ? "load" : "deny", spec.get()));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1107,10 +1108,10 @@ nsCSPContext::PermitsAncestry(nsIDocShell* aDocShell, bool* outPermitsAncestry)
|
||||
// there was one.
|
||||
uriClone->SetUserPass(EmptyCString());
|
||||
|
||||
{
|
||||
nsAutoCString spec;
|
||||
uriClone->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::PermitsAncestry, found ancestor: %s", spec.get()));
|
||||
if (CSPCONTEXTLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
uriClone->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::PermitsAncestry, found ancestor: %s", spec.get()));
|
||||
}
|
||||
ancestorsArray.AppendElement(uriClone);
|
||||
}
|
||||
@ -1127,10 +1128,10 @@ nsCSPContext::PermitsAncestry(nsIDocShell* aDocShell, bool* outPermitsAncestry)
|
||||
// restriction not placed on subresource loads.
|
||||
|
||||
for (uint32_t a = 0; a < ancestorsArray.Length(); a++) {
|
||||
{
|
||||
nsAutoCString spec;
|
||||
ancestorsArray[a]->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::PermitsAncestry, checking ancestor: %s", spec.get()));
|
||||
if (CSPCONTEXTLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
ancestorsArray[a]->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::PermitsAncestry, checking ancestor: %s", spec.get()));
|
||||
}
|
||||
// omit the ancestor URI in violation reports if cross-origin as per spec
|
||||
// (it is a violation of the same-origin policy).
|
||||
@ -1174,12 +1175,12 @@ nsCSPContext::Permits(nsIURI* aURI,
|
||||
true, // send violation reports
|
||||
true); // send blocked URI in violation reports
|
||||
|
||||
{
|
||||
nsAutoCString spec;
|
||||
aURI->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::Permits, aUri: %s, aDir: %d, isAllowed: %s",
|
||||
spec.get(), aDir,
|
||||
*outPermits ? "allow" : "deny"));
|
||||
if (CSPCONTEXTLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aURI->GetSpec(spec);
|
||||
CSPCONTEXTLOG(("nsCSPContext::Permits, aUri: %s, aDir: %d, isAllowed: %s",
|
||||
spec.get(), aDir,
|
||||
*outPermits ? "allow" : "deny"));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -28,7 +28,8 @@ GetCspParserLog()
|
||||
return gCspParserPRLog;
|
||||
}
|
||||
|
||||
#define CSPPARSERLOG(args) PR_LOG(GetCspParserLog(), 4, args)
|
||||
#define CSPPARSERLOG(args) PR_LOG(GetCspParserLog(), PR_LOG_DEBUG, args)
|
||||
#define CSPPARSERLOGENABLED() PR_LOG_TEST(GetCspParserLog(), PR_LOG_DEBUG)
|
||||
|
||||
static const char16_t COLON = ':';
|
||||
static const char16_t SEMICOLON = ';';
|
||||
@ -1078,7 +1079,7 @@ nsCSPParser::parseContentSecurityPolicy(const nsAString& aPolicyString,
|
||||
bool aReportOnly,
|
||||
uint64_t aInnerWindowID)
|
||||
{
|
||||
{
|
||||
if (CSPPARSERLOGENABLED()) {
|
||||
CSPPARSERLOG(("nsCSPParser::parseContentSecurityPolicy, policy: %s",
|
||||
NS_ConvertUTF16toUTF8(aPolicyString).get()));
|
||||
nsAutoCString spec;
|
||||
@ -1124,7 +1125,7 @@ nsCSPParser::parseContentSecurityPolicy(const nsAString& aPolicyString,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
{
|
||||
if (CSPPARSERLOGENABLED()) {
|
||||
nsString parsedPolicy;
|
||||
policy->toString(parsedPolicy);
|
||||
CSPPARSERLOG(("nsCSPParser::parseContentSecurityPolicy, parsedPolicy: %s",
|
||||
|
@ -109,7 +109,7 @@ CSPService::ShouldLoad(uint32_t aContentType,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
{
|
||||
if (PR_LOG_TEST(gCspPRLog, PR_LOG_DEBUG)) {
|
||||
nsAutoCString location;
|
||||
aContentLocation->GetSpec(location);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
@ -204,7 +204,7 @@ CSPService::ShouldLoad(uint32_t aContentType,
|
||||
principal->GetCsp(getter_AddRefs(csp));
|
||||
|
||||
if (csp) {
|
||||
{
|
||||
if (PR_LOG_TEST(gCspPRLog, PR_LOG_DEBUG)) {
|
||||
uint32_t numPolicies = 0;
|
||||
nsresult rv = csp->GetPolicyCount(&numPolicies);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -228,7 +228,7 @@ CSPService::ShouldLoad(uint32_t aContentType,
|
||||
aDecision);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (PR_LOG_TEST(gCspPRLog, PR_LOG_DEBUG)) {
|
||||
nsAutoCString uriSpec;
|
||||
aContentLocation->GetSpec(uriSpec);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
@ -316,7 +316,7 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
|
||||
originalUri, // aMimeTypeGuess
|
||||
&aDecision);
|
||||
|
||||
if (newUri) {
|
||||
if (newUri && PR_LOG_TEST(gCspPRLog, PR_LOG_DEBUG)) {
|
||||
nsAutoCString newUriSpec("None");
|
||||
newUri->GetSpec(newUriSpec);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
|
@ -23,7 +23,8 @@ GetCspUtilsLog()
|
||||
return gCspUtilsPRLog;
|
||||
}
|
||||
|
||||
#define CSPUTILSLOG(args) PR_LOG(GetCspUtilsLog(), 4, args)
|
||||
#define CSPUTILSLOG(args) PR_LOG(GetCspUtilsLog(), PR_LOG_DEBUG, args)
|
||||
#define CSPUTILSLOGENABLED() PR_LOG_TEST(GetCspUtilsLog(), PR_LOG_DEBUG)
|
||||
|
||||
void
|
||||
CSP_GetLocalizedStr(const char16_t* aName,
|
||||
@ -267,7 +268,7 @@ nsCSPBaseSrc::~nsCSPBaseSrc()
|
||||
bool
|
||||
nsCSPBaseSrc::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
|
||||
{
|
||||
{
|
||||
if (CSPUTILSLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aUri->GetSpec(spec);
|
||||
CSPUTILSLOG(("nsCSPBaseSrc::permits, aUri: %s", spec.get()));
|
||||
@ -302,7 +303,7 @@ nsCSPSchemeSrc::~nsCSPSchemeSrc()
|
||||
bool
|
||||
nsCSPSchemeSrc::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
|
||||
{
|
||||
{
|
||||
if (CSPUTILSLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aUri->GetSpec(spec);
|
||||
CSPUTILSLOG(("nsCSPSchemeSrc::permits, aUri: %s", spec.get()));
|
||||
@ -338,7 +339,7 @@ nsCSPHostSrc::~nsCSPHostSrc()
|
||||
bool
|
||||
nsCSPHostSrc::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
|
||||
{
|
||||
{
|
||||
if (CSPUTILSLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aUri->GetSpec(spec);
|
||||
CSPUTILSLOG(("nsCSPHostSrc::permits, aUri: %s", spec.get()));
|
||||
@ -588,7 +589,7 @@ nsCSPNonceSrc::~nsCSPNonceSrc()
|
||||
bool
|
||||
nsCSPNonceSrc::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
|
||||
{
|
||||
{
|
||||
if (CSPUTILSLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aUri->GetSpec(spec);
|
||||
CSPUTILSLOG(("nsCSPNonceSrc::permits, aUri: %s, aNonce: %s",
|
||||
@ -716,7 +717,7 @@ nsCSPDirective::~nsCSPDirective()
|
||||
bool
|
||||
nsCSPDirective::permits(nsIURI* aUri, const nsAString& aNonce, bool aWasRedirected) const
|
||||
{
|
||||
{
|
||||
if (CSPUTILSLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aUri->GetSpec(spec);
|
||||
CSPUTILSLOG(("nsCSPDirective::permits, aUri: %s", spec.get()));
|
||||
@ -826,7 +827,7 @@ nsCSPPolicy::permits(CSPDirective aDir,
|
||||
bool aSpecific,
|
||||
nsAString& outViolatedDirective) const
|
||||
{
|
||||
{
|
||||
if (CSPUTILSLOGENABLED()) {
|
||||
nsAutoCString spec;
|
||||
aUri->GetSpec(spec);
|
||||
CSPUTILSLOG(("nsCSPPolicy::permits, aUri: %s, aDir: %d, aSpecific: %s",
|
||||
|
Loading…
Reference in New Issue
Block a user