Skip to content

Commit

Permalink
Bug 1359833 - Part 4. imgLoader should pass down the loading document…
Browse files Browse the repository at this point in the history
… to the imgRequest. r=tnikkel
  • Loading branch information
aosmond committed Jul 19, 2017
1 parent 30bf027 commit 32b12c7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
31 changes: 18 additions & 13 deletions image/imgLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ imgCacheQueue::end() const
nsresult
imgLoader::CreateNewProxyForRequest(imgRequest* aRequest,
nsILoadGroup* aLoadGroup,
nsIDocument* aLoadingDocument,
imgINotificationObserver* aObserver,
nsLoadFlags aLoadFlags,
imgRequestProxy** _retval)
Expand All @@ -1078,7 +1079,8 @@ imgLoader::CreateNewProxyForRequest(imgRequest* aRequest,
aRequest->GetURI(getter_AddRefs(uri));

// init adds itself to imgRequest's list of observers
nsresult rv = proxyRequest->Init(aRequest, aLoadGroup, uri, aObserver);
nsresult rv = proxyRequest->Init(aRequest, aLoadGroup, aLoadingDocument,
uri, aObserver);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Expand Down Expand Up @@ -1645,6 +1647,7 @@ imgLoader::ValidateRequestWithNewChannel(imgRequest* request,
nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver,
nsISupports* aCX,
nsIDocument* aLoadingDocument,
nsLoadFlags aLoadFlags,
nsContentPolicyType aLoadPolicyType,
imgRequestProxy** aProxyRequest,
Expand All @@ -1660,8 +1663,8 @@ imgLoader::ValidateRequestWithNewChannel(imgRequest* request,
// If we're currently in the middle of validating this request, just hand
// back a proxy to it; the required work will be done for us.
if (request->GetValidator()) {
rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
aLoadFlags, aProxyRequest);
rv = CreateNewProxyForRequest(request, aLoadGroup, aLoadingDocument,
aObserver, aLoadFlags, aProxyRequest);
if (NS_FAILED(rv)) {
return false;
}
Expand Down Expand Up @@ -1706,8 +1709,8 @@ imgLoader::ValidateRequestWithNewChannel(imgRequest* request,
}

RefPtr<imgRequestProxy> req;
rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
aLoadFlags, getter_AddRefs(req));
rv = CreateNewProxyForRequest(request, aLoadGroup, aLoadingDocument,
aObserver, aLoadFlags, getter_AddRefs(req));
if (NS_FAILED(rv)) {
return false;
}
Expand Down Expand Up @@ -1765,6 +1768,7 @@ imgLoader::ValidateEntry(imgCacheEntry* aEntry,
nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver,
nsISupports* aCX,
nsIDocument* aLoadingDocument,
nsLoadFlags aLoadFlags,
nsContentPolicyType aLoadPolicyType,
bool aCanMakeNewChannel,
Expand Down Expand Up @@ -1885,7 +1889,8 @@ imgLoader::ValidateEntry(imgCacheEntry* aEntry,
return ValidateRequestWithNewChannel(request, aURI, aInitialDocumentURI,
aReferrerURI, aReferrerPolicy,
aLoadGroup, aObserver,
aCX, aLoadFlags, aLoadPolicyType,
aCX, aLoadingDocument,
aLoadFlags, aLoadPolicyType,
aProxyRequest, aLoadingPrincipal,
aCORSMode);
}
Expand Down Expand Up @@ -2169,8 +2174,8 @@ imgLoader::LoadImage(nsIURI* aURI,
if (cache.Get(key, getter_AddRefs(entry)) && entry) {
if (ValidateEntry(entry, aURI, aInitialDocumentURI, aReferrerURI,
aReferrerPolicy, aLoadGroup, aObserver, aLoadingDocument,
requestFlags, aContentPolicyType, true, _retval,
aLoadingPrincipal, corsmode)) {
aLoadingDocument, requestFlags, aContentPolicyType, true,
_retval, aLoadingPrincipal, corsmode)) {
request = entry->GetRequest();

// If this entry has no proxies, its request has no reference to the
Expand Down Expand Up @@ -2295,8 +2300,8 @@ imgLoader::LoadImage(nsIURI* aURI,
request->SetLoadId(aLoadingDocument);

LOG_MSG(gImgLog, "imgLoader::LoadImage", "creating proxy request.");
rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
requestFlags, _retval);
rv = CreateNewProxyForRequest(request, aLoadGroup, aLoadingDocument,
aObserver, requestFlags, _retval);
if (NS_FAILED(rv)) {
return rv;
}
Expand Down Expand Up @@ -2417,7 +2422,7 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel,
: nsIContentPolicy::TYPE_INTERNAL_IMAGE;

if (ValidateEntry(entry, uri, nullptr, nullptr, RP_Unset,
nullptr, aObserver, aCX, requestFlags,
nullptr, aObserver, aCX, doc, requestFlags,
policyType, false, nullptr,
nullptr, imgIRequest::CORS_NONE)) {
request = entry->GetRequest();
Expand Down Expand Up @@ -2472,7 +2477,7 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel,

*listener = nullptr; // give them back a null nsIStreamListener

rv = CreateNewProxyForRequest(request, loadGroup, aObserver,
rv = CreateNewProxyForRequest(request, loadGroup, doc, aObserver,
requestFlags, _retval);
static_cast<imgRequestProxy*>(*_retval)->NotifyListener();
} else {
Expand Down Expand Up @@ -2515,7 +2520,7 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel,
// Try to add the new request into the cache.
PutIntoCache(originalURIKey, entry);

rv = CreateNewProxyForRequest(request, loadGroup, aObserver,
rv = CreateNewProxyForRequest(request, loadGroup, doc, aObserver,
requestFlags, _retval);

// Explicitly don't notify our proxy, because we're loading off the
Expand Down
6 changes: 5 additions & 1 deletion image/imgLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ class imgLoader final : public imgILoader,
ReferrerPolicy aReferrerPolicy,
nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver, nsISupports* aCX,
nsIDocument* aLoadingDocument,
nsLoadFlags aLoadFlags,
nsContentPolicyType aContentPolicyType,
bool aCanMakeNewChannel,
Expand All @@ -411,14 +412,17 @@ class imgLoader final : public imgILoader,
ReferrerPolicy aReferrerPolicy,
nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver,
nsISupports* aCX, nsLoadFlags aLoadFlags,
nsISupports* aCX,
nsIDocument* aLoadingDocument,
nsLoadFlags aLoadFlags,
nsContentPolicyType aContentPolicyType,
imgRequestProxy** aProxyRequest,
nsIPrincipal* aLoadingPrincipal,
int32_t aCORSMode);

nsresult CreateNewProxyForRequest(imgRequest* aRequest,
nsILoadGroup* aLoadGroup,
nsIDocument* aLoadingDocument,
imgINotificationObserver* aObserver,
nsLoadFlags aLoadFlags,
imgRequestProxy** _retval);
Expand Down

0 comments on commit 32b12c7

Please sign in to comment.