Backed out changeset 53c0f65599fe (bug 938803) for asserting too much

This commit is contained in:
Wes Kocher 2013-11-26 19:45:16 -06:00
parent 6c5b337fd8
commit a5649eecf1
4 changed files with 6 additions and 62 deletions

View File

@ -6,7 +6,6 @@
#include "nsDNSPrefetch.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsThreadUtils.h"
#include "nsIDNSListener.h"
#include "nsIDNSService.h"
@ -31,11 +30,8 @@ nsDNSPrefetch::Shutdown()
return NS_OK;
}
nsDNSPrefetch::nsDNSPrefetch(nsIURI *aURI,
nsIDNSListener *aListener,
bool storeTiming)
nsDNSPrefetch::nsDNSPrefetch(nsIURI *aURI, bool storeTiming)
: mStoreTiming(storeTiming)
, mListener(do_GetWeakReference(aListener))
{
aURI->GetAsciiHost(mHostname);
}
@ -57,11 +53,8 @@ nsDNSPrefetch::Prefetch(uint16_t flags)
// then our timing will be useless. However, in such a case,
// mEndTimestamp will be a null timestamp and callers should check
// TimingsValid() before using the timing.
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
return sDNSService->AsyncResolve(mHostname,
flags | nsIDNSService::RESOLVE_SPECULATE,
this, mainThread,
getter_AddRefs(tmpOutstanding));
return sDNSService->AsyncResolve(mHostname, flags | nsIDNSService::RESOLVE_SPECULATE,
this, nullptr, getter_AddRefs(tmpOutstanding));
}
nsresult
@ -93,14 +86,7 @@ nsDNSPrefetch::OnLookupComplete(nsICancelable *request,
nsIDNSRecord *rec,
nsresult status)
{
MOZ_ASSERT(NS_IsMainThread(), "Expecting DNS callback on main thread.");
if (mStoreTiming) {
if (mStoreTiming)
mEndTimestamp = mozilla::TimeStamp::Now();
}
nsCOMPtr<nsIDNSListener> listener = do_QueryReferent(mListener);
if (listener) {
listener->OnLookupComplete(request, rec, status);
}
return NS_OK;
}

View File

@ -6,7 +6,6 @@
#ifndef nsDNSPrefetch_h___
#define nsDNSPrefetch_h___
#include "nsWeakReference.h"
#include "nsString.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Attributes.h"
@ -22,7 +21,7 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIDNSLISTENER
nsDNSPrefetch(nsIURI *aURI, nsIDNSListener *aListener, bool storeTiming);
nsDNSPrefetch(nsIURI *aURI, bool storeTiming);
bool TimingsValid() const {
return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull();
}
@ -43,7 +42,6 @@ private:
bool mStoreTiming;
mozilla::TimeStamp mStartTimestamp;
mozilla::TimeStamp mEndTimestamp;
nsWeakPtr mListener;
nsresult Prefetch(uint16_t flags);
};

View File

@ -4302,8 +4302,6 @@ NS_INTERFACE_MAP_BEGIN(nsHttpChannel)
NS_INTERFACE_MAP_ENTRY(nsITimedChannel)
NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableRequest)
NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableStreamListener)
NS_INTERFACE_MAP_ENTRY(nsIDNSListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END_INHERITING(HttpBaseChannel)
//-----------------------------------------------------------------------------
@ -4536,7 +4534,7 @@ nsHttpChannel::BeginConnect()
// timing we used.
LOG(("nsHttpChannel::BeginConnect [this=%p] prefetching%s\n",
this, mCaps & NS_HTTP_REFRESH_DNS ? ", refresh requested" : ""));
mDNSPrefetch = new nsDNSPrefetch(mURI, this, mTimingEnabled);
mDNSPrefetch = new nsDNSPrefetch(mURI, mTimingEnabled);
mDNSPrefetch->PrefetchHigh(mCaps & NS_HTTP_REFRESH_DNS);
}
@ -5921,39 +5919,6 @@ nsHttpChannel::PopRedirectAsyncFunc(nsContinueRedirectionFunc func)
mRedirectFuncStack.TruncateLength(mRedirectFuncStack.Length() - 1);
}
//-----------------------------------------------------------------------------
// nsIDNSListener functions
//-----------------------------------------------------------------------------
NS_IMETHODIMP
nsHttpChannel::OnLookupComplete(nsICancelable *request,
nsIDNSRecord *rec,
nsresult status)
{
MOZ_ASSERT(NS_IsMainThread(), "Expecting DNS callback on main thread.");
MOZ_ASSERT(mDNSPrefetch, "Expecting an nsDNSPrefetch object.");
LOG(("nsHttpChannel::OnLookupComplete [this=%p] prefetch complete%s: "
"%s status[0x%x]\n",
this, mCaps & NS_HTTP_REFRESH_DNS ? ", refresh requested" : "",
NS_SUCCEEDED(status) ? "success" : "failure", status));
// We no longer need the dns prefetch object
if (mDNSPrefetch && mDNSPrefetch->TimingsValid()) {
mTransactionTimings.domainLookupStart =
mDNSPrefetch->StartTimestamp();
mTransactionTimings.domainLookupEnd =
mDNSPrefetch->EndTimestamp();
}
mDNSPrefetch = nullptr;
// Unset DNS cache refresh if it was requested,
if (mCaps & NS_HTTP_REFRESH_DNS) {
mCaps &= ~NS_HTTP_REFRESH_DNS;
}
return NS_OK;
}
//-----------------------------------------------------------------------------
// nsHttpChannel internal functions

View File

@ -12,7 +12,6 @@
#include "nsICachingChannel.h"
#include "nsICacheEntry.h"
#include "nsICacheEntryOpenCallback.h"
#include "nsIDNSListener.h"
#include "nsIApplicationCacheChannel.h"
#include "nsIProtocolProxyCallback.h"
#include "nsIHttpAuthenticableChannel.h"
@ -20,7 +19,6 @@
#include "nsITimedChannel.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsWeakReference.h"
#include "TimingStruct.h"
#include "AutoClose.h"
#include "mozilla/Telemetry.h"
@ -53,8 +51,6 @@ class nsHttpChannel : public HttpBaseChannel
, public nsITimedChannel
, public nsIThreadRetargetableRequest
, public nsIThreadRetargetableStreamListener
, public nsIDNSListener
, public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS_INHERITED
@ -72,7 +68,6 @@ public:
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
NS_DECL_NSITIMEDCHANNEL
NS_DECL_NSITHREADRETARGETABLEREQUEST
NS_DECL_NSIDNSLISTENER
// nsIHttpAuthenticableChannel. We can't use
// NS_DECL_NSIHTTPAUTHENTICABLECHANNEL because it duplicates cancel() and