Commit 11d3e453 authored by simonjam@chromium.org's avatar simonjam@chromium.org

[Resource Timing] Populate PerformanceResourceTiming structs with timing data

https://bugs.webkit.org/show_bug.cgi?id=102862

Reviewed by Tony Gentilcore.

This allows CachedResourceLoader to pass in all of the necessary values and populates
them in the PerformanceResourceTiming struct. A follow up patch will actually call
addResourceTiming() as necessary.

Tests: http/tests/w3c/webperf/submission/resource-timing

* page/Performance.cpp:
(WebCore::Performance::addResourceTiming): Accept all necessary timing data.
* page/Performance.h:
(WebCore):
(Performance):
* page/PerformanceEntry.cpp:
(WebCore::PerformanceEntry::PerformanceEntry):
* page/PerformanceEntry.h:
(PerformanceEntry):
* page/PerformanceResourceTiming.cpp:
(WebCore::monotonicTimeToDocumentMilliseconds):
(WebCore):
(WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
(WebCore::PerformanceResourceTiming::initiatorType): Return the spec'd values.
(WebCore::PerformanceResourceTiming::fetchStart):
(WebCore::PerformanceResourceTiming::domainLookupStart):
(WebCore::PerformanceResourceTiming::domainLookupEnd):
(WebCore::PerformanceResourceTiming::connectStart):
(WebCore::PerformanceResourceTiming::connectEnd):
(WebCore::PerformanceResourceTiming::secureConnectionStart):
(WebCore::PerformanceResourceTiming::requestStart):
(WebCore::PerformanceResourceTiming::responseStart):
(WebCore::PerformanceResourceTiming::responseEnd):
(WebCore::PerformanceResourceTiming::resourceTimeToDocumentMilliseconds):
* page/PerformanceResourceTiming.h:
(WebCore::PerformanceResourceTiming::create):
(PerformanceResourceTiming):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135458 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1949f329
2012-11-20 James Simonsen <simonjam@chromium.org>
[Resource Timing] Populate PerformanceResourceTiming structs with timing data
https://bugs.webkit.org/show_bug.cgi?id=102862
Reviewed by Tony Gentilcore.
This allows CachedResourceLoader to pass in all of the necessary values and populates
them in the PerformanceResourceTiming struct. A follow up patch will actually call
addResourceTiming() as necessary.
Tests: http/tests/w3c/webperf/submission/resource-timing
* page/Performance.cpp:
(WebCore::Performance::addResourceTiming): Accept all necessary timing data.
* page/Performance.h:
(WebCore):
(Performance):
* page/PerformanceEntry.cpp:
(WebCore::PerformanceEntry::PerformanceEntry):
* page/PerformanceEntry.h:
(PerformanceEntry):
* page/PerformanceResourceTiming.cpp:
(WebCore::monotonicTimeToDocumentMilliseconds):
(WebCore):
(WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
(WebCore::PerformanceResourceTiming::initiatorType): Return the spec'd values.
(WebCore::PerformanceResourceTiming::fetchStart):
(WebCore::PerformanceResourceTiming::domainLookupStart):
(WebCore::PerformanceResourceTiming::domainLookupEnd):
(WebCore::PerformanceResourceTiming::connectStart):
(WebCore::PerformanceResourceTiming::connectEnd):
(WebCore::PerformanceResourceTiming::secureConnectionStart):
(WebCore::PerformanceResourceTiming::requestStart):
(WebCore::PerformanceResourceTiming::responseStart):
(WebCore::PerformanceResourceTiming::responseEnd):
(WebCore::PerformanceResourceTiming::resourceTimeToDocumentMilliseconds):
* page/PerformanceResourceTiming.h:
(WebCore::PerformanceResourceTiming::create):
(PerformanceResourceTiming):
2012-11-21 Hajime Morrita <morrita@google.com>
[Shadow DOM][V8] Assertion failure when shadow host is reclaimed before ShadowRoot
......@@ -185,12 +185,12 @@ void Performance::webkitSetResourceTimingBufferSize(unsigned size)
dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullEvent, false, false));
}
void Performance::addResourceTiming(const ResourceRequest& request, const ResourceResponse& response, double finishTime, Document* requestingDocument)
void Performance::addResourceTiming(const String& initiatorName, Document* initiatorDocument, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime)
{
if (!response.resourceLoadTiming() || isResourceTimingBufferFull())
if (isResourceTimingBufferFull())
return;
RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(request, response, finishTime, requestingDocument);
RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(initiatorName, request, response, initiationTime, finishTime, initiatorDocument);
m_resourceTimingBuffer.append(entry);
......
......@@ -49,8 +49,6 @@
namespace WebCore {
class Document;
class PerformanceEntry;
class PerformanceEntryList;
class ResourceRequest;
class ResourceResponse;
class UserTiming;
......@@ -80,7 +78,7 @@ public:
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull);
void addResourceTiming(const ResourceRequest&, const ResourceResponse&, double finishTime, Document*);
void addResourceTiming(const String& initiatorName, Document*, const ResourceRequest&, const ResourceResponse&, double initiationTime, double finishTime);
#endif
using RefCounted<Performance>::ref;
......
......@@ -35,11 +35,11 @@
namespace WebCore {
PerformanceEntry::PerformanceEntry(const String& name, const String& entryType, double startTime, double duration)
PerformanceEntry::PerformanceEntry(const String& name, const String& entryType, double startTime, double finishTime)
: m_name(name)
, m_entryType(entryType)
, m_startTime(startTime)
, m_duration(duration)
, m_duration(finishTime - startTime)
{
}
......
......@@ -58,7 +58,7 @@ public:
}
protected:
PerformanceEntry(const String& name, const String& entryType, double startTime, double duration);
PerformanceEntry(const String& name, const String& entryType, double startTime, double finishTime);
private:
const String m_name;
......
......@@ -44,8 +44,15 @@
namespace WebCore {
PerformanceResourceTiming::PerformanceResourceTiming(const ResourceRequest& request, const ResourceResponse& response, double finishTime, Document* requestingDocument)
: PerformanceEntry(request.url().string(), "resource", response.resourceLoadTiming()->requestTime, finishTime)
double monotonicTimeToDocumentMilliseconds(Document* document, double seconds)
{
ASSERT(seconds >= 0.0);
return document->loader()->timing()->monotonicTimeToZeroBasedDocumentTime(seconds) * 1000.0;
}
PerformanceResourceTiming::PerformanceResourceTiming(const AtomicString& initiatorType, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime, Document* requestingDocument)
: PerformanceEntry(request.url().string(), "resource", monotonicTimeToDocumentMilliseconds(requestingDocument, initiationTime), monotonicTimeToDocumentMilliseconds(requestingDocument, finishTime))
, m_initiatorType(initiatorType)
, m_timing(response.resourceLoadTiming())
, m_finishTime(finishTime)
, m_requestingDocument(requestingDocument)
......@@ -56,10 +63,9 @@ PerformanceResourceTiming::~PerformanceResourceTiming()
{
}
String PerformanceResourceTiming::initiatorType() const
AtomicString PerformanceResourceTiming::initiatorType() const
{
// FIXME: This should be decided by the resource type.
return "other";
return m_initiatorType;
}
// FIXME: Need to enforce same-origin policy on these.
......@@ -77,12 +83,13 @@ double PerformanceResourceTiming::redirectEnd() const
double PerformanceResourceTiming::fetchStart() const
{
return monotonicTimeToDocumentMilliseconds(m_timing->requestTime);
// FIXME: This should be different depending on redirects.
return (startTime());
}
double PerformanceResourceTiming::domainLookupStart() const
{
if (m_timing->dnsStart < 0)
if (!m_timing || m_timing->dnsStart < 0)
return fetchStart();
return resourceTimeToDocumentMilliseconds(m_timing->dnsStart);
......@@ -90,7 +97,7 @@ double PerformanceResourceTiming::domainLookupStart() const
double PerformanceResourceTiming::domainLookupEnd() const
{
if (m_timing->dnsEnd < 0)
if (!m_timing || m_timing->dnsEnd < 0)
return domainLookupStart();
return resourceTimeToDocumentMilliseconds(m_timing->dnsEnd);
......@@ -98,7 +105,7 @@ double PerformanceResourceTiming::domainLookupEnd() const
double PerformanceResourceTiming::connectStart() const
{
if (m_timing->connectStart < 0) // Connection was reused.
if (!m_timing || m_timing->connectStart < 0) // Connection was reused.
return domainLookupEnd();
// connectStart includes any DNS time, so we may need to trim that off.
......@@ -111,7 +118,7 @@ double PerformanceResourceTiming::connectStart() const
double PerformanceResourceTiming::connectEnd() const
{
if (m_timing->connectEnd < 0) // Connection was reused.
if (!m_timing || m_timing->connectEnd < 0) // Connection was reused.
return connectStart();
return resourceTimeToDocumentMilliseconds(m_timing->connectEnd);
......@@ -119,37 +126,39 @@ double PerformanceResourceTiming::connectEnd() const
double PerformanceResourceTiming::secureConnectionStart() const
{
if (m_timing->sslStart < 0) // Secure connection not negotiated.
return 0;
if (!m_timing || m_timing->sslStart < 0) // Secure connection not negotiated.
return 0.0;
return resourceTimeToDocumentMilliseconds(m_timing->sslStart);
}
double PerformanceResourceTiming::requestStart() const
{
if (!m_timing)
return connectEnd();
return resourceTimeToDocumentMilliseconds(m_timing->sendStart);
}
double PerformanceResourceTiming::responseStart() const
{
if (!m_timing)
return requestStart();
// FIXME: This number isn't exactly correct. See the notes in PerformanceTiming::responseStart().
return resourceTimeToDocumentMilliseconds(m_timing->receiveHeadersEnd);
}
double PerformanceResourceTiming::responseEnd() const
{
return monotonicTimeToDocumentMilliseconds(m_finishTime);
}
double PerformanceResourceTiming::monotonicTimeToDocumentMilliseconds(double seconds) const
{
ASSERT(seconds >= 0.0);
return m_requestingDocument->loader()->timing()->convertMonotonicTimeToDocumentTime(seconds) * 1000.0;
if (!m_timing)
return responseStart();
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_finishTime);
}
double PerformanceResourceTiming::resourceTimeToDocumentMilliseconds(int deltaMilliseconds) const
{
return monotonicTimeToDocumentMilliseconds(m_timing->requestTime) + deltaMilliseconds;
if (!deltaMilliseconds)
return 0.0;
return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->requestTime) + deltaMilliseconds;
}
} // namespace WebCore
......
......@@ -48,12 +48,12 @@ class ResourceResponse;
class PerformanceResourceTiming : public PerformanceEntry {
public:
static PassRefPtr<PerformanceResourceTiming> create(const ResourceRequest& request, const ResourceResponse& response, double finishTime, Document* requestingDocument)
static PassRefPtr<PerformanceResourceTiming> create(const AtomicString& initiatorType, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime, Document* requestingDocument)
{
return adoptRef(new PerformanceResourceTiming(request, response, finishTime, requestingDocument));
return adoptRef(new PerformanceResourceTiming(initiatorType, request, response, initiationTime, finishTime, requestingDocument));
}
String initiatorType() const;
AtomicString initiatorType() const;
double redirectStart() const;
double redirectEnd() const;
......@@ -70,12 +70,12 @@ public:
virtual bool isResource() { return true; }
private:
PerformanceResourceTiming(const ResourceRequest&, const ResourceResponse&, double finishTime, Document*);
PerformanceResourceTiming(const AtomicString& initatorType, const ResourceRequest&, const ResourceResponse&, double initiationTime, double finishTime, Document*);
~PerformanceResourceTiming();
double monotonicTimeToDocumentMilliseconds(double seconds) const;
double resourceTimeToDocumentMilliseconds(int deltaMilliseconds) const;
AtomicString m_initiatorType;
RefPtr<ResourceLoadTiming> m_timing;
double m_finishTime;
RefPtr<Document> m_requestingDocument;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment