Bug 675615 - Fix web timing to support keep-alive connections, r=Olli.Pettay
authorIgor Bazarny <igor.bazarny@gmail.com>
Mon, 08 Aug 2011 14:20:03 +0200
changeset 74393 820ac76cec76798d483e2701ef970fc874358215
parent 74392 9547e620e57184f0071001d40fd6d59f60a43737
child 74394 93c6106409528963bf87dcbba66ddceeaafff6b2
push idunknown
push userunknown
push dateunknown
reviewersOlli.Pettay
bugs675615
milestone8.0a1
Bug 675615 - Fix web timing to support keep-alive connections, r=Olli.Pettay
dom/base/nsDOMNavigationTiming.cpp
dom/base/nsDOMNavigationTiming.h
dom/base/nsPerformance.cpp
--- a/dom/base/nsDOMNavigationTiming.cpp
+++ b/dom/base/nsDOMNavigationTiming.cpp
@@ -86,16 +86,27 @@ nsDOMNavigationTiming::TimeStampToDOM(mo
     *aResult = 0;
     return NS_OK;
   }
   mozilla::TimeDuration duration = aStamp - mNavigationStartTimeStamp;
   *aResult = mNavigationStart + static_cast<PRInt32>(duration.ToMilliseconds());
   return NS_OK;
 }
 
+nsresult 
+nsDOMNavigationTiming::TimeStampToDOMOrFetchStart(mozilla::TimeStamp aStamp, 
+                                                  DOMTimeMilliSec* aResult)
+{
+  if (!aStamp.IsNull()) {
+    return TimeStampToDOM(aStamp, aResult);
+  } else {
+    return GetFetchStart(aResult);
+  }
+}
+
 DOMTimeMilliSec nsDOMNavigationTiming::DurationFromStart(){
   DOMTimeMilliSec result; 
   TimeStampToDOM(mozilla::TimeStamp::Now(), &result);
   return result;
 }
 
 void
 nsDOMNavigationTiming::NotifyNavigationStart()
--- a/dom/base/nsDOMNavigationTiming.h
+++ b/dom/base/nsDOMNavigationTiming.h
@@ -87,16 +87,18 @@ public:
   // Document changes state to 'loading' before connecting to timing
   void SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue);
   void NotifyDOMLoading(nsIURI* aURI);
   void NotifyDOMInteractive(nsIURI* aURI);
   void NotifyDOMComplete(nsIURI* aURI);
   void NotifyDOMContentLoadedStart(nsIURI* aURI);
   void NotifyDOMContentLoadedEnd(nsIURI* aURI);
   nsresult TimeStampToDOM(mozilla::TimeStamp aStamp, DOMTimeMilliSec* aResult);
+  nsresult TimeStampToDOMOrFetchStart(mozilla::TimeStamp aStamp, 
+                                      DOMTimeMilliSec* aResult);
 
 private:
   nsDOMNavigationTiming(const nsDOMNavigationTiming &){};
   ~nsDOMNavigationTiming();
 
   void Clear();
   PRBool ReportRedirects();
 
--- a/dom/base/nsPerformance.cpp
+++ b/dom/base/nsPerformance.cpp
@@ -109,93 +109,93 @@ nsPerformanceTiming::GetFetchStart(DOMTi
 NS_IMETHODIMP
 nsPerformanceTiming::GetDomainLookupStart(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetDomainLookupStart(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetDomainLookupEnd(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetDomainLookupEnd(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetConnectStart(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetConnectStart(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetConnectEnd(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetConnectEnd(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetRequestStart(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetRequestStart(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetResponseStart(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetResponseStart(&stamp);
   mozilla::TimeStamp cacheStamp;
   mChannel->GetCacheReadStart(&cacheStamp);
   if (stamp.IsNull() || (!cacheStamp.IsNull() && cacheStamp < stamp)) {
     stamp = cacheStamp;
   }
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetResponseEnd(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetResponseEnd(&stamp);
   mozilla::TimeStamp cacheStamp;
   mChannel->GetCacheReadEnd(&cacheStamp);
   if (stamp.IsNull() || (!cacheStamp.IsNull() && cacheStamp < stamp)) {
     stamp = cacheStamp;
   }
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetDomLoading(DOMTimeMilliSec* aTime)
 {
   return mDOMTiming->GetDomLoading(aTime);
 }