| Index: Source/core/timing/Performance.cpp
|
| diff --git a/Source/core/timing/Performance.cpp b/Source/core/timing/Performance.cpp
|
| index 50fcfad7aa0b23f245d78e0b43ad7af030a6fabf..ce498db16a4d274da4d5294cde50e4c9b3a2cf1e 100644
|
| --- a/Source/core/timing/Performance.cpp
|
| +++ b/Source/core/timing/Performance.cpp
|
| @@ -35,19 +35,22 @@
|
| #include "core/dom/Document.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/loader/DocumentLoader.h"
|
| -#include "core/timing/ResourceTimingInfo.h"
|
| #include "core/timing/PerformanceResourceTiming.h"
|
| +#include "core/timing/PerformanceSmoothnessTiming.h"
|
| #include "core/timing/PerformanceUserTiming.h"
|
| +#include "core/timing/ResourceTimingInfo.h"
|
| #include "platform/weborigin/SecurityOrigin.h"
|
| #include "wtf/CurrentTime.h"
|
|
|
| namespace blink {
|
|
|
| static const size_t defaultResourceTimingBufferSize = 150;
|
| +static const size_t defaultSmoothnessTimingBufferSize = 150;
|
|
|
| Performance::Performance(LocalFrame* frame)
|
| : DOMWindowProperty(frame)
|
| , m_resourceTimingBufferSize(defaultResourceTimingBufferSize)
|
| + , m_smoothnessTimingBufferSize(defaultSmoothnessTimingBufferSize)
|
| , m_referenceTime(frame && frame->host() ? frame->document()->loader()->timing()->referenceMonotonicTime() : 0.0)
|
| , m_userTiming(nullptr)
|
| {
|
| @@ -96,6 +99,8 @@ PerformanceEntryVector Performance::getEntries() const
|
|
|
| entries.appendVector(m_resourceTimingBuffer);
|
|
|
| + entries.appendVector(m_smoothnessTimingBuffer);
|
| +
|
| if (m_userTiming) {
|
| entries.appendVector(m_userTiming->getMarks());
|
| entries.appendVector(m_userTiming->getMeasures());
|
| @@ -113,6 +118,10 @@ PerformanceEntryVector Performance::getEntriesByType(const String& entryType)
|
| for (PerformanceEntryVector::const_iterator resource = m_resourceTimingBuffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource)
|
| entries.append(*resource);
|
|
|
| + if (equalIgnoringCase(entryType, "smoothness"))
|
| + for (PerformanceEntryVector::const_iterator smoothness = m_smoothnessTimingBuffer.begin(); smoothness != m_smoothnessTimingBuffer.end(); ++smoothness)
|
| + entries.append(*smoothness);
|
| +
|
| if (m_userTiming) {
|
| if (equalIgnoringCase(entryType, "mark"))
|
| entries.appendVector(m_userTiming->getMarks());
|
| @@ -133,6 +142,13 @@ PerformanceEntryVector Performance::getEntriesByName(const String& name, const S
|
| if ((*resource)->name() == name)
|
| entries.append(*resource);
|
|
|
| + if (entryType.isNull() || equalIgnoringCase(entryType, "smoothness")) {
|
| + for (PerformanceEntryVector::const_iterator smoothness = m_smoothnessTimingBuffer.begin(); smoothness != m_smoothnessTimingBuffer.end(); ++smoothness) {
|
| + if ((*smoothness)->name() == name)
|
| + entries.append(*smoothness);
|
| + }
|
| + }
|
| +
|
| if (m_userTiming) {
|
| if (entryType.isNull() || equalIgnoringCase(entryType, "mark"))
|
| entries.appendVector(m_userTiming->getMarks(name));
|
| @@ -156,6 +172,18 @@ void Performance::webkitSetResourceTimingBufferSize(unsigned size)
|
| dispatchEvent(Event::create(EventTypeNames::webkitresourcetimingbufferfull));
|
| }
|
|
|
| +void Performance::webkitClearSmoothnessTimings()
|
| +{
|
| + m_smoothnessTimingBuffer.clear();
|
| +}
|
| +
|
| +void Performance::webkitSetSmoothnessTimingBufferSize(unsigned size)
|
| +{
|
| + m_smoothnessTimingBufferSize = size;
|
| + if (isSmoothnessTimingBufferFull())
|
| + dispatchEvent(Event::create(EventTypeNames::webkitsmoothnesstimingbufferfull));
|
| +}
|
| +
|
| static bool passesTimingAllowCheck(const ResourceResponse& response, Document* requestingDocument, const AtomicString& originalTimingAllowOrigin)
|
| {
|
| AtomicallyInitializedStatic(AtomicString&, timingAllowOrigin = *new AtomicString("timing-allow-origin"));
|
| @@ -243,6 +271,28 @@ bool Performance::isResourceTimingBufferFull()
|
| return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize;
|
| }
|
|
|
| +void Performance::addSmoothnessTiming(const String& name, Document* initiatorDocument, unsigned sourceFrame, double startTime)
|
| +{
|
| + if (isSmoothnessTimingBufferFull())
|
| + return;
|
| +
|
| + RefPtrWillBeRawPtr<PerformanceEntry> entry = PerformanceSmoothnessTiming::create(name, initiatorDocument, sourceFrame, startTime);
|
| + addSmoothnessTimingBuffer(entry);
|
| +}
|
| +
|
| +void Performance::addSmoothnessTimingBuffer(PassRefPtrWillBeRawPtr<PerformanceEntry> entry)
|
| +{
|
| + m_smoothnessTimingBuffer.append(entry);
|
| +
|
| + if (isSmoothnessTimingBufferFull())
|
| + dispatchEvent(Event::create(EventTypeNames::webkitsmoothnesstimingbufferfull));
|
| +}
|
| +
|
| +bool Performance::isSmoothnessTimingBufferFull()
|
| +{
|
| + return m_smoothnessTimingBuffer.size() >= m_smoothnessTimingBufferSize;
|
| +}
|
| +
|
| void Performance::mark(const String& markName, ExceptionState& exceptionState)
|
| {
|
| if (!m_userTiming)
|
| @@ -281,6 +331,7 @@ void Performance::trace(Visitor* visitor)
|
| visitor->trace(m_navigation);
|
| visitor->trace(m_timing);
|
| visitor->trace(m_resourceTimingBuffer);
|
| + visitor->trace(m_smoothnessTimingBuffer);
|
| visitor->trace(m_userTiming);
|
| EventTargetWithInlineData::trace(visitor);
|
| DOMWindowProperty::trace(visitor);
|
|
|