Bug 1206146 - Use channel->AsyncOpen2() in embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp (r=sicking)

This commit is contained in:
Christoph Kerschbaumer 2015-09-19 20:24:39 -07:00
parent 668ebc2ff2
commit 6e08fa5c8c
2 changed files with 20 additions and 6 deletions

View File

@ -573,7 +573,7 @@ nsWebBrowserPersist::StartUpload(nsIInputStream *aInputStream,
// NOTE: ALL data must be available in "inputstream"
nsresult rv = uploadChannel->SetUploadStream(aInputStream, aContentType, -1);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
rv = destChannel->AsyncOpen(this, nullptr);
rv = destChannel->AsyncOpen2(this);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
// add this to the upload list
@ -1307,7 +1307,7 @@ nsresult nsWebBrowserPersist::SaveURIInternal(
rv = NS_NewChannel(getter_AddRefs(inputChannel),
aURI,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aLoadGroup
static_cast<nsIInterfaceRequestor*>(this),
@ -1426,9 +1426,17 @@ nsresult nsWebBrowserPersist::SaveChannelInternal(
// but we don't need to do this in the case of a file target.
nsCOMPtr<nsIFileChannel> fc(do_QueryInterface(aChannel));
nsCOMPtr<nsIFileURL> fu(do_QueryInterface(aFile));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (fc && !fu) {
nsCOMPtr<nsIInputStream> fileInputStream, bufferedInputStream;
nsresult rv = aChannel->Open(getter_AddRefs(fileInputStream));
nsresult rv;
if (loadInfo && loadInfo->GetSecurityMode()) {
rv = aChannel->Open2(getter_AddRefs(fileInputStream));
}
else {
rv = aChannel->Open(getter_AddRefs(fileInputStream));
}
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedInputStream),
fileInputStream, BUFFERED_OUTPUT_SIZE);
@ -1439,7 +1447,13 @@ nsresult nsWebBrowserPersist::SaveChannelInternal(
}
// Read from the input channel
nsresult rv = aChannel->AsyncOpen(this, nullptr);
nsresult rv;
if (loadInfo && loadInfo->GetSecurityMode()) {
rv = aChannel->AsyncOpen2(this);
}
else {
rv = aChannel->AsyncOpen(this, nullptr);
}
if (rv == NS_ERROR_NO_CONTENT)
{
// Assume this is a protocol such as mailto: which does not feed out
@ -2771,7 +2785,7 @@ nsWebBrowserPersist::CreateChannelFromURI(nsIURI *aURI, nsIChannel **aChannel)
rv = NS_NewChannel(aChannel,
aURI,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_ARG_POINTER(*aChannel);

View File

@ -3558,7 +3558,7 @@ nsDownload::Resume()
rv = NS_NewChannel(getter_AddRefs(channel),
mSource,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aLoadGroup
ir);