Bug 1039846 - Patch 7: Create channel with a loadgroup. r=baku,bkelly

--HG--
extra : rebase_source : 2d2eb74428a28dac2cda779cc48dae1ed1367f26
This commit is contained in:
Nikhil Marathe 2015-01-08 08:55:05 -08:00
parent ec4d0e58dc
commit 824a826c42
3 changed files with 16 additions and 6 deletions

View File

@ -174,7 +174,8 @@ public:
}
nsCOMPtr<nsIPrincipal> principal = mResolver->GetWorkerPrivate()->GetPrincipal();
nsRefPtr<FetchDriver> fetch = new FetchDriver(mRequest, principal);
nsCOMPtr<nsILoadGroup> loadGroup = mResolver->GetWorkerPrivate()->GetLoadGroup();
nsRefPtr<FetchDriver> fetch = new FetchDriver(mRequest, principal, loadGroup);
nsresult rv = fetch->Fetch(mResolver);
// Right now we only support async fetch, which should never directly fail.
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -229,7 +230,9 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
}
nsRefPtr<MainThreadFetchResolver> resolver = new MainThreadFetchResolver(p);
nsRefPtr<FetchDriver> fetch = new FetchDriver(r, doc->NodePrincipal());
nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();
nsRefPtr<FetchDriver> fetch =
new FetchDriver(r, doc->NodePrincipal(), loadGroup);
aRv = fetch->Fetch(resolver);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;

View File

@ -32,8 +32,10 @@ namespace dom {
NS_IMPL_ISUPPORTS(FetchDriver, nsIStreamListener)
FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal)
FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
nsILoadGroup* aLoadGroup)
: mPrincipal(aPrincipal)
, mLoadGroup(aLoadGroup)
, mRequest(aRequest)
, mFetchRecursionCount(0)
, mResponseAvailableCalled(false)
@ -333,16 +335,19 @@ FetchDriver::HttpNetworkFetch()
FailWithNetworkError();
return rv;
}
MOZ_ASSERT(mLoadGroup);
nsCOMPtr<nsIChannel> chan;
rv = NS_NewChannel(getter_AddRefs(chan),
uri,
mPrincipal,
nsILoadInfo::SEC_NORMAL,
mRequest->GetContext(),
nullptr, /* FIXME(nsm): loadgroup */
mLoadGroup,
nullptr, /* aCallbacks */
nsIRequest::LOAD_NORMAL,
ios);
mLoadGroup = nullptr;
if (NS_WARN_IF(NS_FAILED(rv))) {
FailWithNetworkError();
return rv;

View File

@ -13,8 +13,8 @@
#include "mozilla/DebugOnly.h"
class nsIOutputStream;
class nsILoadGroup;
class nsIPrincipal;
class nsPIDOMWindow;
namespace mozilla {
namespace dom {
@ -42,11 +42,13 @@ public:
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
explicit FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal);
explicit FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
nsILoadGroup* aLoadGroup);
NS_IMETHOD Fetch(FetchDriverObserver* aObserver);
private:
nsCOMPtr<nsIPrincipal> mPrincipal;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsRefPtr<InternalRequest> mRequest;
nsRefPtr<InternalResponse> mResponse;
nsCOMPtr<nsIOutputStream> mPipeOutputStream;