Bug 1087442 - Attach LoadInfo inside each individual ProtocolHandler - toolkit/ changes (r=gcp)

This commit is contained in:
Christoph Kerschbaumer 2014-12-11 20:46:59 -08:00
parent 814c3da537
commit 03d8c2da80
2 changed files with 25 additions and 8 deletions

View File

@ -279,7 +279,7 @@ nsAnnoProtocolHandler::NewChannel2(nsIURI* aURI,
if (!annoName.EqualsLiteral(FAVICON_ANNOTATION_NAME)) if (!annoName.EqualsLiteral(FAVICON_ANNOTATION_NAME))
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
return NewFaviconChannel(aURI, annoURI, _retval); return NewFaviconChannel(aURI, annoURI, aLoadInfo, _retval);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -328,7 +328,7 @@ nsAnnoProtocolHandler::ParseAnnoURI(nsIURI* aURI,
nsresult nsresult
nsAnnoProtocolHandler::NewFaviconChannel(nsIURI *aURI, nsIURI *aAnnotationURI, nsAnnoProtocolHandler::NewFaviconChannel(nsIURI *aURI, nsIURI *aAnnotationURI,
nsIChannel **_channel) nsILoadInfo* aLoadInfo, nsIChannel **_channel)
{ {
// Create our pipe. This will give us our input stream and output stream // Create our pipe. This will give us our input stream and output stream
// that will be written to when we get data from the database. // that will be written to when we get data from the database.
@ -343,12 +343,26 @@ nsAnnoProtocolHandler::NewFaviconChannel(nsIURI *aURI, nsIURI *aAnnotationURI,
// Create our channel. We'll call SetContentType with the right type when // Create our channel. We'll call SetContentType with the right type when
// we know what it actually is. // we know what it actually is.
nsCOMPtr<nsIChannel> channel; nsCOMPtr<nsIChannel> channel;
rv = NS_NewInputStreamChannel(getter_AddRefs(channel), // Bug 1087720 (and Bug 1099296):
aURI, // Once all callsites have been updated to call NewChannel2() instead of NewChannel()
inputStream, // we should have a non-null loadInfo consistently. Until then we have to brach on the
nsContentUtils::GetSystemPrincipal(), // loadInfo and provide default arguments to create a NewInputStreamChannel.
nsILoadInfo::SEC_NORMAL, if (aLoadInfo) {
nsIContentPolicy::TYPE_OTHER); rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
aURI,
inputStream,
EmptyCString(), // aContentType
EmptyCString(), // aContentCharset
aLoadInfo);
}
else {
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURI,
inputStream,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
}
NS_ENSURE_SUCCESS(rv, GetDefaultIcon(_channel)); NS_ENSURE_SUCCESS(rv, GetDefaultIcon(_channel));
// Now we go ahead and get our data asynchronously for the favicon. // Now we go ahead and get our data asynchronously for the favicon.

View File

@ -41,10 +41,13 @@ protected:
* @param aAnnotationURI * @param aAnnotationURI
* The URI that holds the data needed to get the favicon from the * The URI that holds the data needed to get the favicon from the
* database. * database.
* @param aLoadInfo
* The loadinfo that requested the resource load.
* @returns (via _channel) the channel that will obtain the favicon data. * @returns (via _channel) the channel that will obtain the favicon data.
*/ */
nsresult NewFaviconChannel(nsIURI *aURI, nsresult NewFaviconChannel(nsIURI *aURI,
nsIURI *aAnnotationURI, nsIURI *aAnnotationURI,
nsILoadInfo *aLoadInfo,
nsIChannel **_channel); nsIChannel **_channel);
}; };