mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1162751 - Part 3: Wrap expensive calls in PR_LOG_TEST. r=seth
Check that logging is enabled before performing potentially expensive operations.
This commit is contained in:
parent
1c11239bb2
commit
1e0ae36c9f
@ -164,16 +164,18 @@ ProgressTracker::Notify(IProgressObserver* aObserver)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsRefPtr<Image> image = GetImage();
|
||||
if (image && image->GetURI()) {
|
||||
nsRefPtr<ImageURL> uri(image->GetURI());
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"ProgressTracker::Notify async", "uri", spec.get());
|
||||
} else {
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"ProgressTracker::Notify async", "uri", "<unknown>");
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsRefPtr<Image> image = GetImage();
|
||||
if (image && image->GetURI()) {
|
||||
nsRefPtr<ImageURL> uri(image->GetURI());
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"ProgressTracker::Notify async", "uri", spec.get());
|
||||
} else {
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"ProgressTracker::Notify async", "uri", "<unknown>");
|
||||
}
|
||||
}
|
||||
|
||||
aObserver->SetNotificationsDeferred(true);
|
||||
@ -231,13 +233,15 @@ ProgressTracker::NotifyCurrentState(IProgressObserver* aObserver)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsRefPtr<Image> image = GetImage();
|
||||
nsAutoCString spec;
|
||||
if (image && image->GetURI()) {
|
||||
image->GetURI()->GetSpec(spec);
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsRefPtr<Image> image = GetImage();
|
||||
nsAutoCString spec;
|
||||
if (image && image->GetURI()) {
|
||||
image->GetURI()->GetSpec(spec);
|
||||
}
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"ProgressTracker::NotifyCurrentState", "uri", spec.get());
|
||||
}
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"ProgressTracker::NotifyCurrentState", "uri", spec.get());
|
||||
|
||||
aObserver->SetNotificationsDeferred(true);
|
||||
|
||||
|
@ -893,18 +893,20 @@ imgCacheEntry::UpdateCache(int32_t diff /* = 0 */)
|
||||
void
|
||||
imgCacheEntry::SetHasNoProxies(bool hasNoProxies)
|
||||
{
|
||||
nsRefPtr<ImageURL> uri;
|
||||
mRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
if (uri) {
|
||||
uri->GetSpec(spec);
|
||||
}
|
||||
if (hasNoProxies) {
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheEntry::SetHasNoProxies true",
|
||||
"uri", spec.get());
|
||||
} else {
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheEntry::SetHasNoProxies false",
|
||||
"uri", spec.get());
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsRefPtr<ImageURL> uri;
|
||||
mRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
if (uri) {
|
||||
uri->GetSpec(spec);
|
||||
}
|
||||
if (hasNoProxies) {
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheEntry::SetHasNoProxies true",
|
||||
"uri", spec.get());
|
||||
} else {
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheEntry::SetHasNoProxies false",
|
||||
"uri", spec.get());
|
||||
}
|
||||
}
|
||||
|
||||
mHasNoProxies = hasNoProxies;
|
||||
@ -1075,15 +1077,17 @@ imgCacheExpirationTracker::NotifyExpired(imgCacheEntry* entry)
|
||||
// mechanism doesn't.
|
||||
nsRefPtr<imgCacheEntry> kungFuDeathGrip(entry);
|
||||
|
||||
nsRefPtr<imgRequest> req(entry->GetRequest());
|
||||
if (req) {
|
||||
nsRefPtr<ImageURL> uri;
|
||||
req->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"imgCacheExpirationTracker::NotifyExpired",
|
||||
"entry", spec.get());
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsRefPtr<imgRequest> req(entry->GetRequest());
|
||||
if (req) {
|
||||
nsRefPtr<ImageURL> uri;
|
||||
req->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"imgCacheExpirationTracker::NotifyExpired",
|
||||
"entry", spec.get());
|
||||
}
|
||||
}
|
||||
|
||||
// We can be called multiple times on the same entry. Don't do work multiple
|
||||
@ -1509,13 +1513,15 @@ imgLoader::PutIntoCache(const ImageCacheKey& aKey, imgCacheEntry* entry)
|
||||
bool
|
||||
imgLoader::SetHasNoProxies(imgRequest* aRequest, imgCacheEntry* aEntry)
|
||||
{
|
||||
nsRefPtr<ImageURL> uri;
|
||||
aRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsRefPtr<ImageURL> uri;
|
||||
aRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
|
||||
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"imgLoader::SetHasNoProxies", "uri", spec.get());
|
||||
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"imgLoader::SetHasNoProxies", "uri", spec.get());
|
||||
}
|
||||
|
||||
aEntry->SetHasNoProxies(true);
|
||||
|
||||
@ -1599,15 +1605,17 @@ imgLoader::CheckCacheLimits(imgCacheTable& cache, imgCacheQueue& queue)
|
||||
|
||||
NS_ASSERTION(entry, "imgLoader::CheckCacheLimits -- NULL entry pointer");
|
||||
|
||||
nsRefPtr<imgRequest> req(entry->GetRequest());
|
||||
if (req) {
|
||||
nsRefPtr<ImageURL> uri;
|
||||
req->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"imgLoader::CheckCacheLimits",
|
||||
"entry", spec.get());
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsRefPtr<imgRequest> req(entry->GetRequest());
|
||||
if (req) {
|
||||
nsRefPtr<ImageURL> uri;
|
||||
req->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"imgLoader::CheckCacheLimits",
|
||||
"entry", spec.get());
|
||||
}
|
||||
}
|
||||
|
||||
if (entry) {
|
||||
@ -1837,7 +1845,7 @@ imgLoader::ValidateEntry(imgCacheEntry* aEntry,
|
||||
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
|
||||
("imgLoader::ValidateEntry validating cache entry. "
|
||||
"validateRequest = %d", validateRequest));
|
||||
} else if (!key) {
|
||||
} else if (!key && PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsAutoCString spec;
|
||||
aURI->GetSpec(spec);
|
||||
|
||||
@ -2864,11 +2872,13 @@ imgCacheValidator::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
|
||||
uri = imageURL->ToIURI();
|
||||
}
|
||||
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_MSG_WITH_PARAM(GetImgLog(),
|
||||
"imgCacheValidator::OnStartRequest creating new request",
|
||||
"uri", spec.get());
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_MSG_WITH_PARAM(GetImgLog(),
|
||||
"imgCacheValidator::OnStartRequest creating new request",
|
||||
"uri", spec.get());
|
||||
}
|
||||
|
||||
int32_t corsmode = mRequest->GetCORSMode();
|
||||
ReferrerPolicy refpol = mRequest->GetReferrerPolicy();
|
||||
|
@ -258,8 +258,7 @@ imgRequest::RemoveProxy(imgRequestProxy* proxy, nsresult aStatus)
|
||||
if (mLoader) {
|
||||
mLoader->SetHasNoProxies(this, mCacheEntry);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsAutoCString spec;
|
||||
mURI->GetSpec(spec);
|
||||
LOG_MSG_WITH_PARAM(GetImgLog(),
|
||||
|
@ -861,10 +861,13 @@ imgRequestProxy::Notify(int32_t aType, const mozilla::gfx::IntRect* aRect)
|
||||
void
|
||||
imgRequestProxy::OnLoadComplete(bool aLastPart)
|
||||
{
|
||||
nsAutoCString name;
|
||||
GetName(name);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::OnLoadComplete",
|
||||
"name", name.get());
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsAutoCString name;
|
||||
GetName(name);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::OnLoadComplete",
|
||||
"name", name.get());
|
||||
}
|
||||
|
||||
// There's all sorts of stuff here that could kill us (the OnStopRequest call
|
||||
// on the listener, the removal from the loadgroup, the release of the
|
||||
// listener, etc). Don't let them do it.
|
||||
@ -904,10 +907,12 @@ imgRequestProxy::OnLoadComplete(bool aLastPart)
|
||||
void
|
||||
imgRequestProxy::BlockOnload()
|
||||
{
|
||||
nsAutoCString name;
|
||||
GetName(name);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::BlockOnload",
|
||||
"name", name.get());
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsAutoCString name;
|
||||
GetName(name);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::BlockOnload",
|
||||
"name", name.get());
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIOnloadBlocker> blocker = do_QueryInterface(mListener);
|
||||
if (blocker) {
|
||||
@ -918,10 +923,12 @@ imgRequestProxy::BlockOnload()
|
||||
void
|
||||
imgRequestProxy::UnblockOnload()
|
||||
{
|
||||
nsAutoCString name;
|
||||
GetName(name);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::UnblockOnload",
|
||||
"name", name.get());
|
||||
if (PR_LOG_TEST(GetImgLog(), PR_LOG_DEBUG)) {
|
||||
nsAutoCString name;
|
||||
GetName(name);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::UnblockOnload",
|
||||
"name", name.get());
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIOnloadBlocker> blocker = do_QueryInterface(mListener);
|
||||
if (blocker) {
|
||||
|
Loading…
Reference in New Issue
Block a user