diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 946f3f00b925..5d8417841a6b 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -2206,6 +2206,7 @@ HttpBaseChannel::RedirectTo(nsIURI *targetURI) nsAutoCString spec; targetURI->GetAsciiSpec(spec); LOG(("HttpBaseChannel::RedirectTo [this=%p, uri=%s]", this, spec.get())); + LogCallingScriptLocation(this); // We cannot redirect after OnStartRequest of the listener // has been called, since to redirect we have to switch channels diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 9c1ff479000c..1343681354fb 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -2356,6 +2356,8 @@ HttpChannelChild::Cancel(nsresult status) { LOG(("HttpChannelChild::Cancel [this=%p, status=%" PRIx32 "]\n", this, static_cast(status))); + LogCallingScriptLocation(this); + MOZ_ASSERT(NS_IsMainThread()); if (!mCanceled) { @@ -2467,18 +2469,7 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) "security flags in loadInfo but asyncOpen2() not called"); LOG(("HttpChannelChild::AsyncOpen [this=%p uri=%s]\n", this, mSpec.get())); - - if (LOG4_ENABLED()) { - JSContext* cx = nsContentUtils::GetCurrentJSContext(); - if (cx) { - nsAutoCString fileNameString; - uint32_t line = 0, col = 0; - if (nsJSUtils::GetCallingLocation(cx, fileNameString, &line, &col)) { - LOG(("HttpChannelChild %p source script=%s:%u:%u", - this, fileNameString.get(), line, col)); - } - } - } + LogCallingScriptLocation(this); #ifdef DEBUG AssertPrivateBrowsingId(); diff --git a/netwerk/protocol/http/HttpLog.h b/netwerk/protocol/http/HttpLog.h index 21f29cdcdd9c..4dfe6f303aa2 100644 --- a/netwerk/protocol/http/HttpLog.h +++ b/netwerk/protocol/http/HttpLog.h @@ -36,6 +36,7 @@ // namespace mozilla { namespace net { +void LogCallingScriptLocation(void* instance); extern LazyLogModule gHttpLog; } } diff --git a/netwerk/protocol/http/nsHttp.cpp b/netwerk/protocol/http/nsHttp.cpp index 5fe963ee9f12..a1deb342243f 100644 --- a/netwerk/protocol/http/nsHttp.cpp +++ b/netwerk/protocol/http/nsHttp.cpp @@ -835,5 +835,25 @@ ParsedHeaderValueListList::ParsedHeaderValueListList(const nsCString &fullHeader Tokenize(mFull.BeginReading(), mFull.Length(), ',', consumer); } +void LogCallingScriptLocation(void* instance) +{ + if (!LOG4_ENABLED()) { + return; + } + + JSContext* cx = nsContentUtils::GetCurrentJSContext(); + if (!cx) { + return; + } + + nsAutoCString fileNameString; + uint32_t line = 0, col = 0; + if (!nsJSUtils::GetCallingLocation(cx, fileNameString, &line, &col)) { + return; + } + + LOG(("%p called from script: %s:%u:%u", instance, fileNameString.get(), line, col)); +} + } // namespace net } // namespace mozilla