Bug 1201636 - Use channel->asyncOpen2() in modules/libjar/zipwriter/nsZipWriter.cpp (r=sicking)

This commit is contained in:
Christoph Kerschbaumer 2015-09-03 13:27:46 -07:00
parent 1347197f13
commit 9aad1c1349
2 changed files with 18 additions and 4 deletions

View File

@ -13,6 +13,7 @@
#include "nsIAsyncStreamCopier.h"
#include "nsIStreamListener.h"
#include "nsIInputStreamPump.h"
#include "nsILoadInfo.h"
#include "nsComponentManagerUtils.h"
#include "nsMemory.h"
#include "nsError.h"
@ -421,7 +422,14 @@ NS_IMETHODIMP nsZipWriter::AddEntryChannel(const nsACString & aZipEntry,
return NS_ERROR_FILE_ALREADY_EXISTS;
nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = aChannel->Open(getter_AddRefs(inputStream));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
nsresult rv;
if (loadInfo && loadInfo->GetSecurityMode()) {
rv = aChannel->Open2(getter_AddRefs(inputStream));
}
else {
rv = aChannel->Open(getter_AddRefs(inputStream));
}
NS_ENSURE_SUCCESS(rv, rv);
rv = AddEntryStream(aZipEntry, aModTime, aCompression, inputStream,
@ -1007,7 +1015,13 @@ inline nsresult nsZipWriter::BeginProcessingAddition(nsZipQueueItem* aItem,
NS_ENSURE_SUCCESS(rv, rv);
}
else {
rv = aItem->mChannel->AsyncOpen(stream, nullptr);
nsCOMPtr<nsILoadInfo> loadInfo = aItem->mChannel->GetLoadInfo();
if (loadInfo && loadInfo->GetSecurityMode()) {
rv = aItem->mChannel->AsyncOpen2(stream);
}
else {
rv = aItem->mChannel->AsyncOpen(stream, nullptr);
}
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -75,7 +75,7 @@ var methods = {
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER), true);
},
stream: function method_stream(entry, source)
@ -86,7 +86,7 @@ var methods = {
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER).open(), true);
}
}