Bug 1222297 - Use channel->Open2() in netwerk/base/nsNetUtil.cpp (r=sicking)

This commit is contained in:
Christoph Kerschbaumer 2015-11-08 18:54:38 -08:00
parent 74469a968f
commit 6dda3cbb55
4 changed files with 16 additions and 58 deletions

View File

@ -164,9 +164,7 @@ LoadProperties(const nsString& aName,
uriStr.StripWhitespace(); // that may come from aName
uriStr.AppendLiteral(".properties");
return NS_LoadPersistentPropertiesFromURISpec(getter_AddRefs(aProperties),
NS_ConvertUTF16toUTF8(uriStr),
nsContentUtils::GetSystemPrincipal(),
nsIContentPolicy::TYPE_OTHER);
NS_ConvertUTF16toUTF8(uriStr));
}
class nsPropertiesTable final : public nsGlyphTable {

View File

@ -224,9 +224,7 @@ InitOperators(void)
nsCOMPtr<nsIPersistentProperties> mathfontProp;
rv = NS_LoadPersistentPropertiesFromURISpec(
getter_AddRefs(mathfontProp),
NS_LITERAL_CSTRING("resource://gre/res/fonts/mathfont.properties"),
nsContentUtils::GetSystemPrincipal(),
nsIContentPolicy::TYPE_OTHER);
NS_LITERAL_CSTRING("resource://gre/res/fonts/mathfont.properties"));
if (NS_FAILED(rv)) return rv;

View File

@ -11,6 +11,7 @@
#include "nsNetUtil.inl"
#include "mozIApplicationClearPrivateDataParams.h"
#include "nsCategoryCache.h"
#include "nsContentUtils.h"
#include "nsHashKeys.h"
#include "nsHttp.h"
#include "nsIAsyncStreamCopier.h"
@ -1153,25 +1154,22 @@ NS_ReadInputStreamToString(nsIInputStream *aInputStream,
#endif
nsresult
NS_LoadPersistentPropertiesFromURI(nsIPersistentProperties **outResult,
nsIURI *aUri,
nsIPrincipal *aLoadingPrincipal,
nsContentPolicyType aContentPolicyType,
nsIIOService *aIoService /* = nullptr */)
NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties **outResult,
const nsACString &aSpec)
{
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), aSpec);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIChannel> channel;
nsresult rv = NS_NewChannel(getter_AddRefs(channel),
aUri,
aLoadingPrincipal,
nsILoadInfo::SEC_NORMAL,
aContentPolicyType,
nullptr, // aLoadGroup
nullptr, // aCallbacks
nsIRequest::LOAD_NORMAL,
aIoService);
rv = NS_NewChannel(getter_AddRefs(channel),
uri,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> in;
rv = channel->Open(getter_AddRefs(in));
rv = channel->Open2(getter_AddRefs(in));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPersistentProperties> properties =
@ -1182,30 +1180,6 @@ NS_LoadPersistentPropertiesFromURI(nsIPersistentProperties **outResult,
properties.swap(*outResult);
return NS_OK;
}
nsresult
NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties **outResult,
const nsACString &aSpec,
nsIPrincipal *aLoadingPrincipal,
nsContentPolicyType aContentPolicyType,
const char *aCharset /* = nullptr */,
nsIURI *aBaseURI /* = nullptr */,
nsIIOService *aIoService /* = nullptr */)
{
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri),
aSpec,
aCharset,
aBaseURI,
aIoService);
NS_ENSURE_SUCCESS(rv, rv);
return NS_LoadPersistentPropertiesFromURI(outResult,
uri,
aLoadingPrincipal,
aContentPolicyType,
aIoService);
}
bool

View File

@ -599,21 +599,9 @@ nsresult NS_ReadInputStreamToString(nsIInputStream *aInputStream,
#endif
nsresult
NS_LoadPersistentPropertiesFromURI(nsIPersistentProperties **outResult,
nsIURI *aUri,
nsIPrincipal *aLoadingPrincipal,
nsContentPolicyType aContentPolicyType,
nsIIOService *aIoService = nullptr);
nsresult
NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties **outResult,
const nsACString &aSpec,
nsIPrincipal *aLoadingPrincipal,
nsContentPolicyType aContentPolicyType,
const char *aCharset = nullptr,
nsIURI *aBaseURI = nullptr,
nsIIOService *aIoService = nullptr);
const nsACString &aSpec);
/**
* NS_QueryNotificationCallbacks implements the canonical algorithm for