mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 09:19:28 +00:00
Bug 938803 - Cancel DNS refresh requested in classes implementing nsAHttpTransaction r=mcmanus
This commit is contained in:
parent
68d26f138f
commit
14d49d77e1
@ -22,6 +22,7 @@ NullHttpTransaction::NullHttpTransaction(nsHttpConnectionInfo *ci,
|
||||
uint32_t caps)
|
||||
: mStatus(NS_OK)
|
||||
, mCaps(caps | NS_HTTP_ALLOW_KEEPALIVE)
|
||||
, mCapsToClear(0)
|
||||
, mCallbacks(callbacks)
|
||||
, mConnectionInfo(ci)
|
||||
, mRequestHead(nullptr)
|
||||
@ -76,7 +77,14 @@ NullHttpTransaction::Status()
|
||||
uint32_t
|
||||
NullHttpTransaction::Caps()
|
||||
{
|
||||
return mCaps;
|
||||
return mCaps & ~mCapsToClear;
|
||||
}
|
||||
|
||||
void
|
||||
NullHttpTransaction::SetDNSWasRefreshed()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "SetDNSWasRefreshed on main thread only!");
|
||||
mCapsToClear |= NS_HTTP_REFRESH_DNS;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
@ -41,6 +41,12 @@ private:
|
||||
|
||||
nsresult mStatus;
|
||||
uint32_t mCaps;
|
||||
// mCapsToClear holds flags that should be cleared in mCaps, e.g. unset
|
||||
// NS_HTTP_REFRESH_DNS when DNS refresh request has completed to avoid
|
||||
// redundant requests on the network. To deal with raciness, only unsetting
|
||||
// bitfields should be allowed: 'lost races' will thus err on the
|
||||
// conservative side, e.g. by going ahead with a 2nd DNS refresh.
|
||||
uint32_t mCapsToClear;
|
||||
nsRefPtr<nsAHttpConnection> mConnection;
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsRefPtr<nsHttpConnectionInfo> mConnectionInfo;
|
||||
|
@ -227,6 +227,11 @@ SpdyPush3TransactionBuffer::Caps()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SpdyPush3TransactionBuffer::SetDNSWasRefreshed()
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t
|
||||
SpdyPush3TransactionBuffer::Available()
|
||||
{
|
||||
|
@ -225,6 +225,11 @@ SpdyPush31TransactionBuffer::Caps()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SpdyPush31TransactionBuffer::SetDNSWasRefreshed()
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t
|
||||
SpdyPush31TransactionBuffer::Available()
|
||||
{
|
||||
|
@ -2578,6 +2578,11 @@ SpdySession3::Caps()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SpdySession3::SetDNSWasRefreshed()
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t
|
||||
SpdySession3::Available()
|
||||
{
|
||||
|
@ -2702,6 +2702,11 @@ SpdySession31::Caps()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SpdySession31::SetDNSWasRefreshed()
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t
|
||||
SpdySession31::Available()
|
||||
{
|
||||
|
@ -50,6 +50,9 @@ public:
|
||||
virtual nsresult Status() = 0;
|
||||
virtual uint32_t Caps() = 0;
|
||||
|
||||
// called to notify that a requested DNS cache entry was refreshed.
|
||||
virtual void SetDNSWasRefreshed() = 0;
|
||||
|
||||
// called to find out how much request data is available for writing.
|
||||
virtual uint64_t Available() = 0;
|
||||
|
||||
@ -154,6 +157,7 @@ public:
|
||||
bool IsDone(); \
|
||||
nsresult Status(); \
|
||||
uint32_t Caps(); \
|
||||
void SetDNSWasRefreshed(); \
|
||||
uint64_t Available(); \
|
||||
nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *); \
|
||||
nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *); \
|
||||
|
@ -5950,6 +5950,9 @@ nsHttpChannel::OnLookupComplete(nsICancelable *request,
|
||||
// Unset DNS cache refresh if it was requested,
|
||||
if (mCaps & NS_HTTP_REFRESH_DNS) {
|
||||
mCaps &= ~NS_HTTP_REFRESH_DNS;
|
||||
if (mTransaction) {
|
||||
mTransaction->SetDNSWasRefreshed();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -558,6 +558,17 @@ nsHttpPipeline::Caps()
|
||||
return trans ? trans->Caps() : 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpPipeline::SetDNSWasRefreshed()
|
||||
{
|
||||
nsAHttpTransaction *trans = Request(0);
|
||||
if (!trans)
|
||||
trans = Response(0);
|
||||
|
||||
if (trans)
|
||||
trans->SetDNSWasRefreshed();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
nsHttpPipeline::Available()
|
||||
{
|
||||
|
@ -98,6 +98,7 @@ nsHttpTransaction::nsHttpTransaction()
|
||||
, mPriority(0)
|
||||
, mRestartCount(0)
|
||||
, mCaps(0)
|
||||
, mCapsToClear(0)
|
||||
, mClassification(CLASS_GENERAL)
|
||||
, mPipelinePosition(0)
|
||||
, mHttpVersion(NS_HTTP_VERSION_UNKNOWN)
|
||||
@ -552,7 +553,14 @@ nsHttpTransaction::Status()
|
||||
uint32_t
|
||||
nsHttpTransaction::Caps()
|
||||
{
|
||||
return mCaps;
|
||||
return mCaps & ~mCapsToClear;
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpTransaction::SetDNSWasRefreshed()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "SetDNSWasRefreshed on main thread only!");
|
||||
mCapsToClear |= NS_HTTP_REFRESH_DNS;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
@ -210,6 +210,12 @@ private:
|
||||
|
||||
uint16_t mRestartCount; // the number of times this transaction has been restarted
|
||||
uint32_t mCaps;
|
||||
// mCapsToClear holds flags that should be cleared in mCaps, e.g. unset
|
||||
// NS_HTTP_REFRESH_DNS when DNS refresh request has completed to avoid
|
||||
// redundant requests on the network. To deal with raciness, only unsetting
|
||||
// bitfields should be allowed: 'lost races' will thus err on the
|
||||
// conservative side, e.g. by going ahead with a 2nd DNS refresh.
|
||||
uint32_t mCapsToClear;
|
||||
enum Classifier mClassification;
|
||||
int32_t mPipelinePosition;
|
||||
int64_t mMaxPipelineObjectSize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user