Bug 1598516 - Add DocumentChannel MOZ_LOGs. r=jya

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-11-25 20:23:27 +00:00
parent 9631fb7196
commit e6d9c278a0
6 changed files with 64 additions and 7 deletions

View File

@ -31,6 +31,9 @@
using namespace mozilla::dom;
using namespace mozilla::ipc;
extern mozilla::LazyLogModule gDocumentChannelLog;
#define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
namespace mozilla {
namespace net {
@ -74,12 +77,18 @@ DocumentChannelChild::DocumentChannelChild(
mLoadFlags(aLoadFlags),
mURI(aLoadState->URI()),
mLoadInfo(aLoadInfo) {
LOG(("DocumentChannelChild ctor [this=%p, uri=%s]", this,
aLoadState->URI()->GetSpecOrDefault().get()));
RefPtr<nsHttpHandler> handler = nsHttpHandler::GetInstance();
uint64_t channelId;
Unused << handler->NewChannelId(channelId);
mChannelId = channelId;
}
DocumentChannelChild::~DocumentChannelChild() {
LOG(("DocumentChannelChild dtor [this=%p]", this));
}
NS_IMETHODIMP
DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
nsresult rv = NS_OK;
@ -204,6 +213,8 @@ IPCResult DocumentChannelChild::RecvFailedAsyncOpen(
}
void DocumentChannelChild::ShutdownListeners(nsresult aStatusCode) {
LOG(("DocumentChannelChild ShutdownListeners [this=%p, status=%" PRIx32 "]",
this, static_cast<uint32_t>(aStatusCode)));
mStatus = aStatusCode;
nsCOMPtr<nsIStreamListener> l = mListener;
@ -255,6 +266,9 @@ IPCResult DocumentChannelChild::RecvDeleteSelf() {
IPCResult DocumentChannelChild::RecvRedirectToRealChannel(
const RedirectToRealChannelArgs& aArgs,
RedirectToRealChannelResolver&& aResolve) {
LOG(("DocumentChannelChild RecvRedirectToRealChannel [this=%p, uri=%s]", this,
aArgs.uri()->GetSpecOrDefault().get()));
RefPtr<dom::Document> loadingDocument;
mLoadInfo->GetLoadingDocument(getter_AddRefs(loadingDocument));
@ -692,3 +706,5 @@ DocumentChannelChild::SetChannelId(uint64_t aChannelId) {
} // namespace net
} // namespace mozilla
#undef LOG

View File

@ -70,7 +70,7 @@ class DocumentChannelChild final : public nsHashPropertyBag,
private:
void ShutdownListeners(nsresult aStatusCode);
~DocumentChannelChild() = default;
~DocumentChannelChild();
nsCOMPtr<nsIChannel> mRedirectChannel;
nsTArray<DocumentChannelRedirect> mRedirects;

View File

@ -7,12 +7,29 @@
#include "DocumentChannelParent.h"
extern mozilla::LazyLogModule gDocumentChannelLog;
#define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
namespace mozilla {
namespace net {
DocumentChannelParent::DocumentChannelParent(
const dom::PBrowserOrId& aIframeEmbedding, nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus) {
LOG(("DocumentChannelParent ctor [this=%p]", this));
mParent = new DocumentLoadListener(aIframeEmbedding, aLoadContext,
aOverrideStatus, this);
}
DocumentChannelParent::~DocumentChannelParent() {
LOG(("DocumentChannelParent dtor [this=%p]", this));
}
bool DocumentChannelParent::Init(const DocumentChannelCreationArgs& aArgs) {
RefPtr<nsDocShellLoadState> loadState =
new nsDocShellLoadState(aArgs.loadState());
LOG(("DocumentChannelParent Init [this=%p, uri=%s]", this,
loadState->URI()->GetSpecOrDefault().get()));
RefPtr<class LoadInfo> loadInfo;
nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo(Some(aArgs.loadInfo()),
@ -43,3 +60,5 @@ DocumentChannelParent::RedirectToRealChannel(uint32_t aRedirectFlags,
} // namespace net
} // namespace mozilla
#undef LOG

View File

@ -25,10 +25,8 @@ class DocumentChannelParent final : public ADocumentChannelBridge,
explicit DocumentChannelParent(const dom::PBrowserOrId& aIframeEmbedding,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus) {
mParent = new DocumentLoadListener(aIframeEmbedding, aLoadContext,
aOverrideStatus, this);
}
PBOverrideStatus aOverrideStatus);
bool Init(const DocumentChannelCreationArgs& aArgs);
// PDocumentChannelParent
@ -70,7 +68,7 @@ class DocumentChannelParent final : public ADocumentChannelBridge,
RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
RedirectToRealChannel(uint32_t aRedirectFlags, uint32_t aLoadFlags) override;
~DocumentChannelParent() = default;
~DocumentChannelParent();
RefPtr<DocumentLoadListener> mParent;
};

View File

@ -27,6 +27,9 @@
#include "nsIPrompt.h"
#include "nsIWindowWatcher.h"
mozilla::LazyLogModule gDocumentChannelLog("DocumentChannel");
#define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
using namespace mozilla::dom;
namespace mozilla {
@ -52,6 +55,7 @@ DocumentLoadListener::DocumentLoadListener(const PBrowserOrId& aIframeEmbedding,
PBOverrideStatus aOverrideStatus,
ADocumentChannelBridge* aBridge)
: mLoadContext(aLoadContext), mPBOverride(aOverrideStatus) {
LOG(("DocumentLoadListener ctor [this=%p]", this));
RefPtr<dom::BrowserParent> parent;
if (aIframeEmbedding.type() == PBrowserOrId::TPBrowserParent) {
parent =
@ -61,6 +65,10 @@ DocumentLoadListener::DocumentLoadListener(const PBrowserOrId& aIframeEmbedding,
mDocumentChannelBridge = aBridge;
}
DocumentLoadListener::~DocumentLoadListener() {
LOG(("DocumentLoadListener dtor [this=%p]", this));
}
bool DocumentLoadListener::Open(
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
const nsString* aInitiatorType, nsLoadFlags aLoadFlags, uint32_t aLoadType,
@ -69,6 +77,8 @@ bool DocumentLoadListener::Open(
const Maybe<PrincipalInfo>& aContentBlockingAllowListPrincipal,
const nsString& aCustomUserAgent, const uint64_t& aChannelId,
const TimeStamp& aAsyncOpenTime, nsresult* aRv) {
LOG(("DocumentLoadListener Open [this=%p, uri=%s]", this,
aLoadState->URI()->GetSpecOrDefault().get()));
if (!nsDocShell::CreateChannelForLoadState(
aLoadState, aLoadInfo, mParentChannelListener, nullptr,
aInitiatorType, aLoadFlags, aLoadType, aCacheKey, aIsActive,
@ -144,6 +154,8 @@ bool DocumentLoadListener::Open(
}
void DocumentLoadListener::DocumentChannelBridgeDisconnected() {
LOG(("DocumentLoadListener DocumentChannelBridgeDisconnected [this=%p]",
this));
// The nsHttpChannel may have a reference to this parent, release it
// to avoid circular references.
RefPtr<nsHttpChannel> httpChannelImpl = do_QueryObject(mChannel);
@ -172,6 +184,10 @@ void DocumentLoadListener::Resume() {
}
void DocumentLoadListener::RedirectToRealChannelFinished(nsresult aRv) {
LOG(
("DocumentLoadListener RedirectToRealChannelFinished [this=%p, "
"aRv=%" PRIx32 " ]",
this, static_cast<uint32_t>(aRv)));
if (NS_FAILED(aRv)) {
FinishReplacementChannelSetup(false);
return;
@ -492,6 +508,8 @@ void DocumentLoadListener::TriggerCrossProcessSwitch() {
MOZ_ASSERT(!mDoingProcessSwitch, "Already in the middle of switching?");
MOZ_ASSERT(NS_IsMainThread());
LOG(("DocumentLoadListener TriggerCrossProcessSwitch [this=%p]", this));
mDoingProcessSwitch = true;
RefPtr<DocumentLoadListener> self = this;
@ -511,6 +529,7 @@ RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
DocumentLoadListener::RedirectToRealChannel(
uint32_t aRedirectFlags, uint32_t aLoadFlags,
const Maybe<uint64_t>& aDestinationProcess) {
LOG(("DocumentLoadListener RedirectToRealChannel [this=%p]", this));
if (aDestinationProcess) {
dom::ContentParent* cp =
dom::ContentProcessManager::GetSingleton()->GetContentProcessById(
@ -607,6 +626,7 @@ void DocumentLoadListener::TriggerRedirectToRealChannel(
NS_IMETHODIMP
DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
LOG(("DocumentLoadListener OnStartRequest [this=%p]", this));
nsCOMPtr<nsHttpChannel> channel = do_QueryInterface(aRequest);
mChannel = do_QueryInterface(aRequest);
MOZ_DIAGNOSTIC_ASSERT(mChannel);
@ -673,6 +693,7 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
NS_IMETHODIMP
DocumentLoadListener::OnStopRequest(nsIRequest* aRequest,
nsresult aStatusCode) {
LOG(("DocumentLoadListener OnStopRequest [this=%p]", this));
mStopRequestValue = Some(aStatusCode);
return NS_OK;
@ -682,6 +703,7 @@ NS_IMETHODIMP
DocumentLoadListener::OnDataAvailable(nsIRequest* aRequest,
nsIInputStream* aInputStream,
uint64_t aOffset, uint32_t aCount) {
LOG(("DocumentLoadListener OnDataAvailable [this=%p]", this));
// This isn't supposed to happen, since we suspended the channel, but
// sometimes Suspend just doesn't work. This can happen when we're routing
// through nsUnknownDecoder to sniff the content type, and it doesn't handle
@ -948,3 +970,5 @@ DocumentLoadListener::GetCrossOriginOpenerPolicy(
} // namespace net
} // namespace mozilla
#undef LOG

View File

@ -153,7 +153,7 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
uint32_t aLoadFlags);
protected:
virtual ~DocumentLoadListener() = default;
virtual ~DocumentLoadListener();
// Initiates the switch from DocumentChannel to the real protocol-specific
// channel, and ensures that RedirectToRealChannelFinished is called when