Bug 1616716 - Remove BrowserParent from DocumentLoadListener. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D63429

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2020-02-26 02:56:21 +00:00
Родитель b76b3f5d8c
Коммит aa0c8f3ec7
3 изменённых файлов: 38 добавлений и 29 удалений

Просмотреть файл

@ -6,10 +6,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DocumentChannelParent.h"
#include "mozilla/dom/BrowserParent.h"
extern mozilla::LazyLogModule gDocumentChannelLog;
#define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
using namespace mozilla::dom;
namespace mozilla {
namespace net {
@ -17,8 +20,8 @@ DocumentChannelParent::DocumentChannelParent(BrowserParent* aBrowser,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus) {
LOG(("DocumentChannelParent ctor [this=%p]", this));
mParent =
new DocumentLoadListener(aBrowser, aLoadContext, aOverrideStatus, this);
mParent = new DocumentLoadListener(aBrowser->GetBrowsingContext(),
aLoadContext, aOverrideStatus, this);
}
DocumentChannelParent::~DocumentChannelParent() {
@ -38,13 +41,14 @@ bool DocumentChannelParent::Init(BrowserParent* aBrowser,
MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = NS_ERROR_UNEXPECTED;
if (!mParent->Open(
aBrowser, loadState, loadInfo, aArgs.loadFlags(), aArgs.loadType(),
aArgs.cacheKey(), aArgs.isActive(), aArgs.isTopLevelDoc(),
aArgs.hasNonEmptySandboxingFlags(), aArgs.topWindowURI(),
aArgs.contentBlockingAllowListPrincipal(), aArgs.channelId(),
aArgs.asyncOpenTime(), aArgs.documentOpenFlags(),
aArgs.pluginsAllowed(), aArgs.timing().refOr(nullptr), &rv)) {
if (!mParent->Open(aBrowser->GetBrowsingContext(), loadState, loadInfo,
aArgs.loadFlags(), aArgs.loadType(), aArgs.cacheKey(),
aArgs.isActive(), aArgs.isTopLevelDoc(),
aArgs.hasNonEmptySandboxingFlags(), aArgs.topWindowURI(),
aArgs.contentBlockingAllowListPrincipal(),
aArgs.channelId(), aArgs.asyncOpenTime(),
aArgs.documentOpenFlags(), aArgs.pluginsAllowed(),
aArgs.timing().refOr(nullptr), &rv)) {
return SendFailedAsyncOpen(rv);
}

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/MozPromiseInlines.h" // For MozPromise::FromDomPromise
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ClientChannelHelper.h"
#include "mozilla/dom/ContentParent.h"
@ -234,14 +233,14 @@ NS_INTERFACE_MAP_BEGIN(DocumentLoadListener)
NS_INTERFACE_MAP_ENTRY_CONCRETE(DocumentLoadListener)
NS_INTERFACE_MAP_END
DocumentLoadListener::DocumentLoadListener(BrowserParent* aBrowser,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus,
ADocumentChannelBridge* aBridge)
DocumentLoadListener::DocumentLoadListener(
CanonicalBrowsingContext* aProcessTopBrowsingContext,
nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus,
ADocumentChannelBridge* aBridge)
: mLoadContext(aLoadContext), mPBOverride(aOverrideStatus) {
LOG(("DocumentLoadListener ctor [this=%p]", this));
mParentChannelListener = new ParentChannelListener(
this, aBrowser->GetBrowsingContext(), aLoadContext->UsePrivateBrowsing());
this, aProcessTopBrowsingContext, aLoadContext->UsePrivateBrowsing());
mDocumentChannelBridge = aBridge;
}
@ -250,10 +249,11 @@ DocumentLoadListener::~DocumentLoadListener() {
}
bool DocumentLoadListener::Open(
BrowserParent* aBrowser, nsDocShellLoadState* aLoadState,
LoadInfo* aLoadInfo, nsLoadFlags aLoadFlags, uint32_t aLoadType,
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc,
bool aHasNonEmptySandboxingFlags, const Maybe<URIParams>& aTopWindowURI,
CanonicalBrowsingContext* aProcessTopBrowsingContext,
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aLoadType, uint32_t aCacheKey,
bool aIsActive, bool aIsTopLevelDoc, bool aHasNonEmptySandboxingFlags,
const Maybe<URIParams>& aTopWindowURI,
const Maybe<PrincipalInfo>& aContentBlockingAllowListPrincipal,
const uint64_t& aChannelId, const TimeStamp& aAsyncOpenTime,
const Maybe<uint32_t>& aDocumentOpenFlags, bool aPluginsAllowed,
@ -315,7 +315,7 @@ bool DocumentLoadListener::Open(
RefPtr<ParentProcessDocumentOpenInfo> openInfo =
new ParentProcessDocumentOpenInfo(mParentChannelListener,
aPluginsAllowed, *aDocumentOpenFlags,
aBrowser->GetBrowsingContext());
aProcessTopBrowsingContext);
openInfo->Prepare();
*aRv = mChannel->AsyncOpen(openInfo);

Просмотреть файл

@ -14,7 +14,7 @@
#include "mozilla/net/PDocumentChannelParent.h"
#include "mozilla/net/ParentChannelListener.h"
#include "mozilla/net/ADocumentChannelBridge.h"
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "nsDOMNavigationTiming.h"
#include "nsIInterfaceRequestor.h"
#include "nsIObserver.h"
@ -63,18 +63,23 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
public nsIProcessSwitchRequestor,
public nsIMultiPartChannelListener {
public:
explicit DocumentLoadListener(dom::BrowserParent* aBrowser,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus,
ADocumentChannelBridge* aBridge);
// aProcessTopBrowsingContext should be the top BrowsingContext in the same
// process as the load, which would be the owner of the BrowserParent (if
// has been created).
// This is weird legacy behaviour, that will be cleaned up with bug 1618057.
explicit DocumentLoadListener(
dom::CanonicalBrowsingContext* aProcessTopBrowsingContext,
nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus,
ADocumentChannelBridge* aBridge);
// Creates the channel, and then calls AsyncOpen on it.
// Must be the same BrowserParent as was passed to the constructor, we
// Must be the same BrowsingContext as was passed to the constructor, we
// expect Necko to pass it again so that we don't need a member var for
// it.
bool Open(dom::BrowserParent* aBrowser, nsDocShellLoadState* aLoadState,
LoadInfo* aLoadInfo, nsLoadFlags aLoadFlags, uint32_t aLoadType,
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc,
bool Open(dom::CanonicalBrowsingContext* aProcessTopBrowsingContext,
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aLoadType, uint32_t aCacheKey,
bool aIsActive, bool aIsTopLevelDoc,
bool aHasNonEmptySandboxingFlags,
const Maybe<ipc::URIParams>& aTopWindowURI,
const Maybe<ipc::PrincipalInfo>& aContentBlockingAllowListPrincipal,