mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1326339 - Store top level outer content window id in http transaction and connMgr. r=mayhemer
--HG-- extra : rebase_source : 0ad395edaa8ae7760fb0057084f353d977964234
This commit is contained in:
parent
1c309ba4b2
commit
3cf721745a
@ -131,6 +131,7 @@ struct HttpChannelOpenArgs
|
||||
nsCString channelId;
|
||||
uint64_t contentWindowId;
|
||||
nsCString preferredAlternativeType;
|
||||
uint64_t topLevelOuterContentWindowId;
|
||||
};
|
||||
|
||||
struct HttpChannelConnectArgs
|
||||
|
@ -200,6 +200,7 @@ HttpBaseChannel::HttpBaseChannel()
|
||||
, mDecodedBodySize(0)
|
||||
, mEncodedBodySize(0)
|
||||
, mContentWindowId(0)
|
||||
, mTopLevelOuterContentWindowId(0)
|
||||
, mRequireCORSPreflight(false)
|
||||
, mReportCollector(new ConsoleReportCollector())
|
||||
, mForceMainDocumentChannel(false)
|
||||
@ -3830,6 +3831,29 @@ HttpBaseChannel::EnsureRequestContextID()
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
HttpBaseChannel::EnsureTopLevelOuterContentWindowId()
|
||||
{
|
||||
if (mTopLevelOuterContentWindowId) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
GetCallback(loadContext);
|
||||
if (!loadContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIDOMWindowProxy> topWindow;
|
||||
loadContext->GetTopWindow(getter_AddRefs(topWindow));
|
||||
if (!topWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
mTopLevelOuterContentWindowId =
|
||||
nsPIDOMWindowOuter::From(topWindow)->WindowID();
|
||||
}
|
||||
|
||||
void
|
||||
HttpBaseChannel::SetCorsPreflightParameters(const nsTArray<nsCString>& aUnsafeHeaders)
|
||||
{
|
||||
|
@ -358,6 +358,11 @@ public: /* Necko internal use only... */
|
||||
mIsTrackingResource = true;
|
||||
}
|
||||
|
||||
void SetTopLevelOuterContentWindowId(uint64_t aTopLevelOuterContentWindowId)
|
||||
{
|
||||
mTopLevelOuterContentWindowId = aTopLevelOuterContentWindowId;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Handle notifying listener, removing from loadgroup if request failed.
|
||||
void DoNotifyListener();
|
||||
@ -587,6 +592,9 @@ protected:
|
||||
// originated from.
|
||||
uint64_t mContentWindowId;
|
||||
|
||||
uint64_t mTopLevelOuterContentWindowId;
|
||||
void EnsureTopLevelOuterContentWindowId();
|
||||
|
||||
bool mRequireCORSPreflight;
|
||||
nsTArray<nsCString> mUnsafeHeaders;
|
||||
|
||||
|
@ -2147,6 +2147,7 @@ HttpChannelChild::ContinueAsyncOpen()
|
||||
nsCOMPtr<nsIDocument> document = tabChild->GetDocument();
|
||||
if (document) {
|
||||
contentWindowId = document->InnerWindowID();
|
||||
mTopLevelOuterContentWindowId = document->OuterWindowID();
|
||||
}
|
||||
}
|
||||
SetTopLevelContentWindowId(contentWindowId);
|
||||
@ -2245,6 +2246,7 @@ HttpChannelChild::ContinueAsyncOpen()
|
||||
openArgs.channelId().AssignASCII(chid);
|
||||
|
||||
openArgs.contentWindowId() = contentWindowId;
|
||||
openArgs.topLevelOuterContentWindowId() = mTopLevelOuterContentWindowId;
|
||||
|
||||
if (tabChild && !tabChild->IPCOpen()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -130,7 +130,8 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs)
|
||||
a.initialRwin(), a.blockAuthPrompt(),
|
||||
a.suspendAfterSynthesizeResponse(),
|
||||
a.allowStaleCacheContent(), a.contentTypeHint(),
|
||||
a.channelId(), a.contentWindowId(), a.preferredAlternativeType());
|
||||
a.channelId(), a.contentWindowId(), a.preferredAlternativeType(),
|
||||
a.topLevelOuterContentWindowId());
|
||||
}
|
||||
case HttpChannelCreationArgs::THttpChannelConnectArgs:
|
||||
{
|
||||
@ -328,7 +329,8 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
const nsCString& aContentTypeHint,
|
||||
const nsCString& aChannelId,
|
||||
const uint64_t& aContentWindowId,
|
||||
const nsCString& aPreferredAlternativeType)
|
||||
const nsCString& aPreferredAlternativeType,
|
||||
const uint64_t& aTopLevelOuterContentWindowId)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
||||
if (!uri) {
|
||||
@ -379,6 +381,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
// Set the channelId allocated in child to the parent instance
|
||||
mChannel->SetChannelId(aChannelId);
|
||||
mChannel->SetTopLevelContentWindowId(aContentWindowId);
|
||||
mChannel->SetTopLevelOuterContentWindowId(aTopLevelOuterContentWindowId);
|
||||
|
||||
mChannel->SetWarningReporter(this);
|
||||
mChannel->SetTimingEnabled(true);
|
||||
|
@ -148,7 +148,8 @@ protected:
|
||||
const nsCString& aContentTypeHint,
|
||||
const nsCString& aChannelId,
|
||||
const uint64_t& aContentWindowId,
|
||||
const nsCString& aPreferredAlternativeType);
|
||||
const nsCString& aPreferredAlternativeType,
|
||||
const uint64_t& aTopLevelOuterContentWindowId);
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvSetPriority(const int16_t& priority) override;
|
||||
virtual mozilla::ipc::IPCResult RecvSetClassOfService(const uint32_t& cos) override;
|
||||
|
@ -992,10 +992,13 @@ nsHttpChannel::SetupTransaction()
|
||||
mCaps |= NS_HTTP_ONPUSH_LISTENER;
|
||||
}
|
||||
|
||||
EnsureTopLevelOuterContentWindowId();
|
||||
|
||||
nsCOMPtr<nsIAsyncInputStream> responseStream;
|
||||
rv = mTransaction->Init(mCaps, mConnectionInfo, &mRequestHead,
|
||||
mUploadStream, mUploadStreamHasHeaders,
|
||||
NS_GetCurrentThread(), callbacks, this,
|
||||
mTopLevelOuterContentWindowId,
|
||||
getter_AddRefs(responseStream));
|
||||
if (NS_FAILED(rv)) {
|
||||
mTransaction = nullptr;
|
||||
|
@ -87,6 +87,7 @@ nsHttpConnectionMgr::nsHttpConnectionMgr()
|
||||
, mPruningNoTraffic(false)
|
||||
, mTimeoutTickArmed(false)
|
||||
, mTimeoutTickNext(1)
|
||||
, mCurrentTopLevelOuterContentWindowId(0)
|
||||
{
|
||||
LOG(("Creating nsHttpConnectionMgr @%p\n", this));
|
||||
}
|
||||
@ -2428,6 +2429,44 @@ nsHttpConnectionMgr::ActivateTimeoutTick()
|
||||
mTimeoutTick->Init(this, 1000, nsITimer::TYPE_REPEATING_SLACK);
|
||||
}
|
||||
|
||||
class UINT64Wrapper : public ARefBase
|
||||
{
|
||||
public:
|
||||
explicit UINT64Wrapper(uint64_t aUint64) : mUint64(aUint64) {}
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(UINT64Wrapper)
|
||||
|
||||
uint64_t GetValue()
|
||||
{
|
||||
return mUint64;
|
||||
}
|
||||
private:
|
||||
uint64_t mUint64;
|
||||
virtual ~UINT64Wrapper() = default;
|
||||
};
|
||||
|
||||
nsresult
|
||||
nsHttpConnectionMgr::UpdateCurrentTopLevelOuterContentWindowId(
|
||||
uint64_t aWindowId)
|
||||
{
|
||||
RefPtr<UINT64Wrapper> windowIdWrapper = new UINT64Wrapper(aWindowId);
|
||||
return PostEvent(
|
||||
&nsHttpConnectionMgr::OnMsgUpdateCurrentTopLevelOuterContentWindowId,
|
||||
0,
|
||||
windowIdWrapper);
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpConnectionMgr::OnMsgUpdateCurrentTopLevelOuterContentWindowId(
|
||||
int32_t, ARefBase *param)
|
||||
{
|
||||
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
|
||||
mCurrentTopLevelOuterContentWindowId =
|
||||
static_cast<UINT64Wrapper*>(param)->GetValue();
|
||||
LOG(("nsHttpConnectionMgr::OnMsgUpdateCurrentTopLevelOuterContentWindowId"
|
||||
" id=%" PRIu64 "\n",
|
||||
mCurrentTopLevelOuterContentWindowId));
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpConnectionMgr::TimeoutTick()
|
||||
{
|
||||
|
@ -192,6 +192,8 @@ public:
|
||||
// public, so that the SPDY/http2 seesions can activate
|
||||
void ActivateTimeoutTick();
|
||||
|
||||
nsresult UpdateCurrentTopLevelOuterContentWindowId(uint64_t aWindowId);
|
||||
|
||||
private:
|
||||
virtual ~nsHttpConnectionMgr();
|
||||
|
||||
@ -444,6 +446,7 @@ private:
|
||||
void OnMsgUpdateRequestTokenBucket (int32_t, ARefBase *);
|
||||
void OnMsgVerifyTraffic (int32_t, ARefBase *);
|
||||
void OnMsgPruneNoTraffic (int32_t, ARefBase *);
|
||||
void OnMsgUpdateCurrentTopLevelOuterContentWindowId (int32_t, ARefBase *);
|
||||
|
||||
// Total number of active connections in all of the ConnectionEntry objects
|
||||
// that are accessed from mCT connection table.
|
||||
@ -488,6 +491,7 @@ private:
|
||||
void OnMsgPrintDiagnostics(int32_t, ARefBase *);
|
||||
|
||||
nsCString mLogData;
|
||||
uint64_t mCurrentTopLevelOuterContentWindowId;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
@ -135,6 +135,7 @@ nsHttpTransaction::nsHttpTransaction()
|
||||
, mReportedResponseHeader(false)
|
||||
, mForTakeResponseHead(nullptr)
|
||||
, mResponseHeadTaken(false)
|
||||
, mTopLevelOuterContentWindowId(0)
|
||||
, mSubmittedRatePacing(false)
|
||||
, mPassedRatePacing(false)
|
||||
, mSynchronousRatePaceRequest(false)
|
||||
@ -187,6 +188,7 @@ nsHttpTransaction::Init(uint32_t caps,
|
||||
nsIEventTarget *target,
|
||||
nsIInterfaceRequestor *callbacks,
|
||||
nsITransportEventSink *eventsink,
|
||||
uint64_t topLevelOuterContentWindowId,
|
||||
nsIAsyncInputStream **responseBody)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -198,6 +200,8 @@ nsHttpTransaction::Init(uint32_t caps,
|
||||
MOZ_ASSERT(target);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
mTopLevelOuterContentWindowId = topLevelOuterContentWindowId;
|
||||
|
||||
mActivityDistributor = do_GetService(NS_HTTPACTIVITYDISTRIBUTOR_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -74,6 +74,9 @@ public:
|
||||
// the dispatch target were notifications should be sent.
|
||||
// @param callbacks
|
||||
// the notification callbacks to be given to PSM.
|
||||
// @param topLevelOuterContentWindowId
|
||||
// indicate the top level outer content window in which
|
||||
// this transaction is being loaded.
|
||||
// @param responseBody
|
||||
// the input stream that will contain the response data. async
|
||||
// wait on this input stream for data. on first notification,
|
||||
@ -87,6 +90,7 @@ public:
|
||||
nsIEventTarget *consumerTarget,
|
||||
nsIInterfaceRequestor *callbacks,
|
||||
nsITransportEventSink *eventsink,
|
||||
uint64_t topLevelOuterContentWindowId,
|
||||
nsIAsyncInputStream **responseBody);
|
||||
|
||||
// attributes
|
||||
@ -166,6 +170,11 @@ public:
|
||||
|
||||
MOZ_MUST_USE bool Do0RTT() override;
|
||||
MOZ_MUST_USE nsresult Finish0RTT(bool aRestart, bool aAlpnChanged /* ignored */) override;
|
||||
|
||||
uint64_t TopLevelOuterContentWindowId()
|
||||
{
|
||||
return mTopLevelOuterContentWindowId;
|
||||
}
|
||||
private:
|
||||
friend class DeleteHttpTransaction;
|
||||
virtual ~nsHttpTransaction();
|
||||
@ -333,6 +342,8 @@ private:
|
||||
// The time when the transaction was submitted to the Connection Manager
|
||||
TimeStamp mPendingTime;
|
||||
|
||||
uint64_t mTopLevelOuterContentWindowId;
|
||||
|
||||
// For Rate Pacing via an EventTokenBucket
|
||||
public:
|
||||
// called by the connection manager to run this transaction through the
|
||||
|
Loading…
Reference in New Issue
Block a user