Bug 1038756: Callsites creating a channel in /netwerk/ (r=mcmanus)

* * *
[mq]: child_parent_communication.patch
This commit is contained in:
Christoph Kerschbaumer 2014-09-21 09:40:12 -07:00
parent 84ddf42b9a
commit a298cfb2d1
11 changed files with 148 additions and 15 deletions

View File

@ -815,4 +815,6 @@ nsBufferedOutputStream::GetUnbufferedStream(nsISupports* *aStream)
return NS_OK;
}
#undef METER
////////////////////////////////////////////////////////////////////////////////

View File

@ -22,6 +22,8 @@
#include "prio.h"
#include "prprf.h"
#include <algorithm>
#include "nsIContentPolicy.h"
#include "nsContentUtils.h"
// Default values used to initialize a nsIncrementalDownload object.
#define DEFAULT_CHUNK_SIZE (4096 * 16) // bytes
@ -260,8 +262,16 @@ nsIncrementalDownload::ProcessTimeout()
// Fetch next chunk
nsCOMPtr<nsIChannel> channel;
nsresult rv = NS_NewChannel(getter_AddRefs(channel), mFinalURI, nullptr,
nullptr, this, mLoadFlags);
nsresult rv = NS_NewChannel(getter_AddRefs(channel),
mFinalURI,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aChannelPolicy
nullptr, // loadGroup
this, // aCallbacks
mLoadFlags);
if (NS_FAILED(rv))
return rv;

View File

@ -15,6 +15,8 @@
#include "nsNetUtil.h"
#include "nsProxyRelease.h"
#include "nsAutoPtr.h"
#include "nsIContentPolicy.h"
#include "nsContentUtils.h"
#include "nsIFileURL.h"
#include "nsIMIMEService.h"
@ -336,7 +338,12 @@ nsFileChannel::OpenContentStream(bool async, nsIInputStream **result,
rv = fileHandler->ReadURLFile(file, getter_AddRefs(newURI));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIChannel> newChannel;
rv = NS_NewChannel(getter_AddRefs(newChannel), newURI);
rv = NS_NewChannel(getter_AddRefs(newChannel),
newURI,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
if (NS_FAILED(rv))
return rv;

View File

@ -6,6 +6,9 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIProgressEventSink.h"
#include <algorithm>
#include "nsIContentPolicy.h"
#include "mozilla/LoadInfo.h"
#include "nsContentUtils.h"
#define RETURN_IF_FAILED(rv, step) \
PR_BEGIN_MACRO \
@ -162,7 +165,12 @@ int main(int argc, char **argv)
rv = NS_NewURI(getter_AddRefs(uri), argv[1]);
RETURN_IF_FAILED(rv, "NS_NewURI");
rv = NS_NewChannel(getter_AddRefs(chan), uri, nullptr, nullptr, callbacks);
rv = NS_NewChannel(getter_AddRefs(chan),
uri,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
RETURN_IF_FAILED(rv, "NS_OpenURI");
rv = chan->AsyncOpen(listener, nullptr);

View File

@ -12,6 +12,7 @@
#include "nsIInputStream.h"
#include "nsNetUtil.h"
#include "mozilla/unused.h"
#include "nsIScriptSecurityManager.h"
#include <stdio.h>
@ -51,7 +52,19 @@ main(int argc, char **argv)
rv = NS_NewURI(getter_AddRefs(uri), argv[1]);
RETURN_IF_FAILED(rv, "NS_NewURI");
rv = NS_OpenURI(getter_AddRefs(stream), uri);
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
RETURN_IF_FAILED(rv, "Couldn't get script security manager!");
nsCOMPtr<nsIPrincipal> systemPrincipal;
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
RETURN_IF_FAILED(rv, "Couldn't get system principal!");
rv = NS_OpenURI(getter_AddRefs(stream),
uri,
systemPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
RETURN_IF_FAILED(rv, "NS_OpenURI");
FILE* outfile = fopen(argv[2], "wb");

View File

@ -17,6 +17,7 @@
#include "nsCOMArray.h"
#include "nsIComponentRegistrar.h"
#include <algorithm>
#include "nsIScriptSecurityManager.h"
namespace TestPageLoad {
@ -298,7 +299,23 @@ nsresult auxLoad(char *uriBuf)
}
printf("\n");
uriList.AppendObject(uri);
rv = NS_NewChannel(getter_AddRefs(chan), uri, nullptr, nullptr, callbacks);
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
RETURN_IF_FAILED(rv, rv, "Couldn't get script security manager!");
nsCOMPtr<nsIPrincipal> systemPrincipal;
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
RETURN_IF_FAILED(rv, rv, "Couldn't get system principal!");
rv = NS_NewChannel(getter_AddRefs(chan),
uri,
systemPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aChannelPolicy
nullptr, // loadGroup
callbacks);
RETURN_IF_FAILED(rv, rv, "NS_NewChannel");
gKeepRunning++;
@ -342,7 +359,22 @@ int main(int argc, char **argv)
rv = NS_NewURI(getter_AddRefs(baseURI), argv[1]);
RETURN_IF_FAILED(rv, -1, "NS_NewURI");
rv = NS_NewChannel(getter_AddRefs(chan), baseURI, nullptr, nullptr, callbacks);
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
RETURN_IF_FAILED(rv, -1, "Couldn't get script security manager!");
nsCOMPtr<nsIPrincipal> systemPrincipal;
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
RETURN_IF_FAILED(rv, -1, "Couldn't get system principal!");
rv = NS_NewChannel(getter_AddRefs(chan),
baseURI,
systemPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aChannelPolicy
nullptr, // loadGroup
callbacks);
RETURN_IF_FAILED(rv, -1, "NS_OpenURI");
gKeepRunning++;

View File

@ -5,6 +5,7 @@
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsISupportsArray.h"
#include "nsContentUtils.h"
#include <algorithm>
namespace TestPerf {
@ -21,7 +22,16 @@ load_sync_1(nsISupports *element, void *data)
nsAutoCString spec;
nsresult rv;
rv = NS_OpenURI(getter_AddRefs(stream), uri, gIOService);
rv = NS_OpenURI(getter_AddRefs(stream),
uri,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aLoadGroup
nullptr, // aCallbacks
LOAD_NORMAL,
gIOService);
if (NS_FAILED(rv)) {
uri->GetAsciiSpec(spec);
fprintf(stderr, "*** failed opening %s [rv=%x]\n", spec.get(), rv);
@ -121,7 +131,17 @@ load_async_1(nsISupports *element, void *data)
if (!listener)
return true;
NS_ADDREF(listener);
nsresult rv = NS_OpenURI(listener, nullptr, uri, gIOService);
nsresult rv = NS_OpenURI(listener,
nullptr, // aContext
uri,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aLoadGroup
nullptr, // aCallbacks
gIOService);
NS_RELEASE(listener);
if (NS_SUCCEEDED(rv))
gRequestCount++;

View File

@ -52,6 +52,7 @@
#include "nsChannelProperties.h"
#include "mozilla/Attributes.h"
#include "mozilla/unused.h"
#include "nsIScriptSecurityManager.h"
#include "nsISimpleEnumerator.h"
#include "nsStringAPI.h"
@ -630,10 +631,25 @@ nsresult StartLoadingURL(const char* aUrlString)
}
NS_ADDREF(callbacks);
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> systemPrincipal;
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
NS_ENSURE_SUCCESS(rv, rv);
// Async reading thru the calls of the event sink interface
rv = NS_NewChannel(getter_AddRefs(pChannel), pURL, pService,
nullptr, // loadGroup
callbacks); // notificationCallbacks
rv = NS_NewChannel(getter_AddRefs(pChannel),
pURL,
systemPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // aChannelPolicy
nullptr, // loadGroup
callbacks,
nsIRequest::LOAD_NORMAL,
pService);
NS_RELEASE(callbacks);
if (NS_FAILED(rv)) {
LOG(("ERROR: NS_OpenURI failed for %s [rv=%x]\n", aUrlString, rv));

View File

@ -4,6 +4,7 @@
#include "nsThreadUtils.h"
#include "prlog.h"
#include "mozilla/Attributes.h"
#include "nsIScriptSecurityManager.h"
#if defined(PR_LOGGING)
//
@ -65,8 +66,20 @@ int main(int argc, char **argv)
if (NS_FAILED(rv))
return -1;
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, -1);
nsCOMPtr<nsIPrincipal> systemPrincipal;
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
NS_ENSURE_SUCCESS(rv, -1);
nsCOMPtr<nsIChannel> chan;
rv = NS_NewChannel(getter_AddRefs(chan), uri);
rv = NS_NewChannel(getter_AddRefs(chan),
uri,
systemPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
if (NS_FAILED(rv))
return -1;

View File

@ -9,6 +9,7 @@
#include <nsIChannel.h>
#include <nsIHTTPChannel.h>
#include <nsIInputStream.h>
#include "nsContentUtils.h"
#include <nsNetUtil.h>
/*
@ -56,7 +57,12 @@ main(int argc, char **argv)
rv = NS_NewURI(getter_AddRefs(c[i].uri), argv[i+1]);
RETURN_IF_FAILED(rv, "NS_NewURI");
rv = NS_OpenURI(getter_AddRefs(c[i].channel), c[i].uri, nullptr, nullptr);
rv = NS_OpenURI(getter_AddRefs(c[i].channel,
c[i].uri,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
RETURN_IF_FAILED(rv, "NS_OpenURI");
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(c[i].channel);

View File

@ -9,6 +9,7 @@
#include "nsIStreamListener.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nsContentUtils.h"
#include <algorithm>
//#include "prthread.h"
@ -49,7 +50,12 @@ createChannel( const char *url ) {
// Allocate a new input channel on this thread.
printf( "Calling NS_OpenURI...\n" );
nsresult rv = NS_OpenURI( getter_AddRefs( result ), uri, 0 );
nsresult rv = NS_OpenURI(getter_AddRefs(result),
uri,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
if ( NS_SUCCEEDED( rv ) ) {
printf( "...NS_OpenURI completed OK\n" );