Bug 1467223 - Part 4: Add support for piping redirected channels through nsDocShell's loading functions, r=qdot
This code largely skips the logic in load methods, and tries to simply get the channel opened & connected to the correct listener ASAP, without breaking any loading state. Depends on D15610 Differential Revision: https://phabricator.services.mozilla.com/D15611
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIChildChannel.h"
|
||||
|
||||
#include "mozilla/OriginAttributes.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
@@ -66,6 +67,44 @@ nsDocShellLoadState::nsDocShellLoadState(DocShellLoadStateInit& aLoadState) {
|
||||
|
||||
nsDocShellLoadState::~nsDocShellLoadState() {}
|
||||
|
||||
nsresult nsDocShellLoadState::CreateFromPendingChannel(
|
||||
nsIChildChannel* aPendingChannel, nsDocShellLoadState** aResult) {
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aPendingChannel);
|
||||
if (NS_WARN_IF(!channel)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Create the nsDocShellLoadState object with default state pulled from the
|
||||
// passed-in channel.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(uri);
|
||||
loadState->mPendingRedirectedChannel = aPendingChannel;
|
||||
|
||||
// Pull relevant state from the channel, and store it on the
|
||||
// nsDocShellLoadState.
|
||||
nsCOMPtr<nsIURI> originalUri;
|
||||
rv = channel->GetOriginalURI(getter_AddRefs(originalUri));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
loadState->SetOriginalURI(originalUri);
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
if (NS_WARN_IF(!loadInfo)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
loadState->SetTriggeringPrincipal(loadInfo->TriggeringPrincipal());
|
||||
|
||||
// Return the newly created loadState.
|
||||
loadState.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIURI* nsDocShellLoadState::Referrer() const { return mReferrer; }
|
||||
|
||||
void nsDocShellLoadState::SetReferrer(nsIURI* aReferrer) {
|
||||
|
||||
Reference in New Issue
Block a user