This source file includes following definitions.
- monotonicTimeToDocumentMilliseconds
- m_requestingDocument
- initiatorType
- redirectStart
- redirectEnd
- fetchStart
- domainLookupStart
- domainLookupEnd
- connectStart
- connectEnd
- secureConnectionStart
- requestStart
- responseStart
- responseEnd
#include "config.h"
#include "core/timing/PerformanceResourceTiming.h"
#include "core/dom/Document.h"
#include "core/loader/DocumentLoadTiming.h"
#include "core/loader/DocumentLoader.h"
#include "core/timing/ResourceTimingInfo.h"
#include "platform/network/ResourceRequest.h"
#include "platform/network/ResourceResponse.h"
namespace WebCore {
static double monotonicTimeToDocumentMilliseconds(Document* document, double seconds)
{
ASSERT(seconds >= 0.0);
return document->loader()->timing()->monotonicTimeToZeroBasedDocumentTime(seconds) * 1000.0;
}
PerformanceResourceTiming::PerformanceResourceTiming(const ResourceTimingInfo& info, Document* requestingDocument, double startTime, double lastRedirectEndTime, bool allowTimingDetails, bool allowRedirectDetails)
: PerformanceEntry(info.initialRequest().url().string(), "resource", monotonicTimeToDocumentMilliseconds(requestingDocument, startTime), monotonicTimeToDocumentMilliseconds(requestingDocument, info.loadFinishTime()))
, m_initiatorType(info.initiatorType())
, m_timing(info.finalResponse().resourceLoadTiming())
, m_lastRedirectEndTime(lastRedirectEndTime)
, m_finishTime(info.loadFinishTime())
, m_didReuseConnection(info.finalResponse().connectionReused())
, m_allowTimingDetails(allowTimingDetails)
, m_allowRedirectDetails(allowRedirectDetails)
, m_requestingDocument(requestingDocument)
{
ScriptWrappable::init(this);
}
PerformanceResourceTiming::~PerformanceResourceTiming()
{
}
AtomicString PerformanceResourceTiming::initiatorType() const
{
return m_initiatorType;
}
double PerformanceResourceTiming::redirectStart() const
{
if (!m_lastRedirectEndTime || !m_allowRedirectDetails)
return 0.0;
return PerformanceEntry::startTime();
}
double PerformanceResourceTiming::redirectEnd() const
{
if (!m_lastRedirectEndTime || !m_allowRedirectDetails)
return 0.0;
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_lastRedirectEndTime);
}
double PerformanceResourceTiming::fetchStart() const
{
if (m_lastRedirectEndTime) {
ASSERT(m_timing);
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->requestTime);
}
return PerformanceEntry::startTime();
}
double PerformanceResourceTiming::domainLookupStart() const
{
if (!m_allowTimingDetails)
return 0.0;
if (!m_timing || m_timing->dnsStart == 0.0)
return fetchStart();
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->dnsStart);
}
double PerformanceResourceTiming::domainLookupEnd() const
{
if (!m_allowTimingDetails)
return 0.0;
if (!m_timing || m_timing->dnsEnd == 0.0)
return domainLookupStart();
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->dnsEnd);
}
double PerformanceResourceTiming::connectStart() const
{
if (!m_allowTimingDetails)
return 0.0;
if (!m_timing || m_timing->connectStart == 0.0 || m_didReuseConnection)
return domainLookupEnd();
double connectStart = m_timing->connectStart;
if (m_timing->dnsEnd > 0.0)
connectStart = m_timing->dnsEnd;
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), connectStart);
}
double PerformanceResourceTiming::connectEnd() const
{
if (!m_allowTimingDetails)
return 0.0;
if (!m_timing || m_timing->connectEnd == 0.0 || m_didReuseConnection)
return connectStart();
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->connectEnd);
}
double PerformanceResourceTiming::secureConnectionStart() const
{
if (!m_allowTimingDetails)
return 0.0;
if (!m_timing || m_timing->sslStart == 0.0)
return 0.0;
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->sslStart);
}
double PerformanceResourceTiming::requestStart() const
{
if (!m_allowTimingDetails)
return 0.0;
if (!m_timing)
return connectEnd();
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->sendStart);
}
double PerformanceResourceTiming::responseStart() const
{
if (!m_allowTimingDetails)
return 0.0;
if (!m_timing)
return requestStart();
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->receiveHeadersEnd);
}
double PerformanceResourceTiming::responseEnd() const
{
if (!m_finishTime)
return responseStart();
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_finishTime);
}
}