page/PerformanceEntry.idl
page/PerformanceEntryList.idl
page/PerformanceNavigation.idl
+ page/PerformanceResourceTiming.idl
page/PerformanceTiming.idl
page/Screen.idl
page/SpeechInputEvent.idl
page/PerformanceEntry.cpp
page/PerformanceEntryList.cpp
page/PerformanceNavigation.cpp
+ page/PerformanceResourceTiming.cpp
page/PerformanceTiming.cpp
page/PrintContext.cpp
page/Screen.cpp
+2012-06-21 James Simonsen <simonjam@chromium.org>
+
+ [Resource Timing] Implement Resource Timing interface
+ https://bugs.webkit.org/show_bug.cgi?id=61152
+
+ This patch implements the Resource Timing interface. It doesn't do anything
+ useful, because nothing populates the timeline yet. There are also some gaps
+ in the implementation, which have been filed as bugs.
+
+ http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/ResourceTiming/Overview.html
+
+ Reviewed by Tony Gentilcore.
+
+ No new tests. Feature is disabled on all platforms.
+
+ * CMakeLists.txt:
+ * DerivedSources.pri:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * UseV8.cmake:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/v8/custom/V8PerformanceEntryCustom.cpp:
+ (WebCore):
+ (WebCore::toV8): Support PerformanceEntry polymorphism.
+ * dom/EventNames.h:
+ (WebCore):
+ * dom/EventTargetFactory.in:
+ * page/Performance.cpp:
+ (WebCore::Performance::~Performance):
+ (WebCore):
+ (WebCore::Performance::interfaceName): Reqired for EventTarget.
+ (WebCore::Performance::scriptExecutionContext): Ditto.
+ (WebCore::Performance::webkitGetEntries): Return "resource" entries.
+ (WebCore::Performance::webkitGetEntriesByType): Ditto.
+ (WebCore::Performance::webkitGetEntriesByName): Ditto.
+ (WebCore::Performance::webkitClearResourceTimings): New.
+ (WebCore::Performance::webkitSetResourceTimingBufferSize): New. Unimplemented.
+ (WebCore::Performance::addResourceTiming): This is how resources in WebCore will report to the timeline.
+ (WebCore::Performance::eventTargetData): Required for EventTarget.
+ (WebCore::Performance::ensureEventTargetData): Ditto.
+ * page/Performance.h:
+ (Performance):
+ (WebCore::Performance::refEventTarget):
+ (WebCore::Performance::derefEventTarget):
+ * page/Performance.idl:
+ * page/PerformanceEntry.cpp:
+ (WebCore::PerformanceEntry::~PerformanceEntry):
+ (WebCore):
+ * page/PerformanceEntry.h:
+ (PerformanceEntry):
+ (WebCore::PerformanceEntry::isResource):
+ * page/PerformanceEntry.idl:
+ * page/PerformanceResourceTiming.cpp: Added.
+ (WebCore):
+ (WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
+ (WebCore::PerformanceResourceTiming::initiatorType):
+ (WebCore::PerformanceResourceTiming::redirectStart):
+ (WebCore::PerformanceResourceTiming::redirectEnd):
+ (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::monotonicTimeToDocumentMilliseconds):
+ (WebCore::PerformanceResourceTiming::resourceTimeToMilliseconds):
+ * page/PerformanceResourceTiming.h: Added.
+ (WebCore):
+ (PerformanceResourceTiming):
+ (WebCore::PerformanceResourceTiming::create):
+ (WebCore::PerformanceResourceTiming::isResource):
+ * page/PerformanceResourceTiming.idl: Added.
+
2012-06-21 Hans Wennborg <hans@chromium.org>
Speech JavaScript API: Remove FIXMEs about whether events bubble and are cancelable
$$PWD/page/PerformanceEntry.idl \
$$PWD/page/PerformanceEntryList.idl \
$$PWD/page/PerformanceNavigation.idl \
+ $$PWD/page/PerformanceResourceTiming.idl \
$$PWD/page/PerformanceTiming.idl \
$$PWD/page/Screen.idl \
$$PWD/page/SpeechInputEvent.idl \
$(WebCore)/page/PerformanceEntry.idl \
$(WebCore)/page/PerformanceEntryList.idl \
$(WebCore)/page/PerformanceNavigation.idl \
+ $(WebCore)/page/PerformanceResourceTiming.idl \
$(WebCore)/page/PerformanceTiming.idl \
$(WebCore)/page/Screen.idl \
$(WebCore)/page/SpeechInputEvent.idl \
Source/WebCore/page/PerformanceEntryList.h \
Source/WebCore/page/PerformanceNavigation.cpp \
Source/WebCore/page/PerformanceNavigation.h \
+ Source/WebCore/page/PerformanceResourceTiming.cpp \
+ Source/WebCore/page/PerformanceResourceTiming.h \
Source/WebCore/page/PerformanceTiming.cpp \
Source/WebCore/page/PerformanceTiming.h \
Source/WebCore/page/PointerLock.h \
bindings/v8/custom/V8NodeCustom.cpp \
bindings/v8/custom/V8NodeListCustom.cpp \
bindings/v8/custom/V8PerformanceCustom.cpp \
+ bindings/v8/custom/V8PerformanceEntryCustom.cpp \
bindings/v8/custom/V8SQLResultSetRowListCustom.cpp \
bindings/v8/custom/V8SQLTransactionCustom.cpp \
bindings/v8/custom/V8WebSocketCustom.cpp \
page/PerformanceEntry.cpp \
page/PerformanceEntryList.cpp \
page/PerformanceNavigation.cpp \
+ page/PerformanceResourceTiming.cpp \
page/PerformanceTiming.cpp \
page/PrintContext.cpp \
page/Screen.cpp \
bindings/v8/custom/V8NotificationCustom.cpp
bindings/v8/custom/V8NotificationCenterCustom.cpp
bindings/v8/custom/V8PerformanceCustom.cpp
+ bindings/v8/custom/V8PerformanceEntryCustom.cpp
bindings/v8/custom/V8PopStateEventCustom.cpp
bindings/v8/custom/V8SQLResultSetRowListCustom.cpp
bindings/v8/custom/V8SQLTransactionCustom.cpp
'page/PerformanceEntry.idl',
'page/PerformanceEntryList.idl',
'page/PerformanceNavigation.idl',
+ 'page/PerformanceResourceTiming.idl',
'page/PerformanceTiming.idl',
'page/PointerLock.idl',
'page/Screen.idl',
'bindings/v8/custom/V8NotificationCustom.cpp',
'bindings/v8/custom/V8NotificationCenterCustom.cpp',
'bindings/v8/custom/V8PerformanceCustom.cpp',
+ 'bindings/v8/custom/V8PerformanceEntryCustom.cpp',
'bindings/v8/custom/V8PopStateEventCustom.cpp',
'bindings/v8/custom/V8SQLResultSetRowListCustom.cpp',
'bindings/v8/custom/V8SQLTransactionCustom.cpp',
'page/PerformanceEntryList.h',
'page/PerformanceNavigation.cpp',
'page/PerformanceNavigation.h',
+ 'page/PerformanceResourceTiming.cpp',
+ 'page/PerformanceResourceTiming.h',
'page/PerformanceTiming.cpp',
'page/PerformanceTiming.h',
'page/PointerLock.cpp',
>
</File>
<File
+ RelativePath="..\page\PerformanceResourceTiming.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\page\PerformanceResourceTiming.h"
+ >
+ </File>
+ <File
RelativePath="..\page\PerformanceTiming.cpp"
>
</File>
861C2EA413FB4FDD00062ABB /* DocumentLoadTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 861C2EA313FB4FDD00062ABB /* DocumentLoadTiming.cpp */; };
861C2EA613FB4FFF00062ABB /* ResourceLoadTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 861C2EA513FB4FFF00062ABB /* ResourceLoadTiming.cpp */; };
86243D0111BC31F700CC006A /* JSArrayBufferViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */; };
+ 86512EDE154A2AEF00A90426 /* PerformanceResourceTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86512EDB154A2AEE00A90426 /* PerformanceResourceTiming.cpp */; };
+ 86512EDF154A2AEF00A90426 /* PerformanceResourceTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 86512EDC154A2AEF00A90426 /* PerformanceResourceTiming.h */; };
86BE340015058CB200CE0FD8 /* PerformanceEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86BE33FA15058CB200CE0FD8 /* PerformanceEntry.cpp */; };
86BE340115058CB200CE0FD8 /* PerformanceEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 86BE33FB15058CB200CE0FD8 /* PerformanceEntry.h */; };
86BE340315058CB200CE0FD8 /* PerformanceEntryList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86BE33FD15058CB200CE0FD8 /* PerformanceEntryList.cpp */; };
861C2EA313FB4FDD00062ABB /* DocumentLoadTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoadTiming.cpp; sourceTree = "<group>"; };
861C2EA513FB4FFF00062ABB /* ResourceLoadTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadTiming.cpp; sourceTree = "<group>"; };
86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferViewHelper.h; sourceTree = "<group>"; };
+ 86512EDB154A2AEE00A90426 /* PerformanceResourceTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceResourceTiming.cpp; sourceTree = "<group>"; };
+ 86512EDC154A2AEF00A90426 /* PerformanceResourceTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceResourceTiming.h; sourceTree = "<group>"; };
+ 86512EDD154A2AEF00A90426 /* PerformanceResourceTiming.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PerformanceResourceTiming.idl; sourceTree = "<group>"; };
86BE33FA15058CB200CE0FD8 /* PerformanceEntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceEntry.cpp; sourceTree = "<group>"; };
86BE33FB15058CB200CE0FD8 /* PerformanceEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceEntry.h; sourceTree = "<group>"; };
86BE33FC15058CB200CE0FD8 /* PerformanceEntry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PerformanceEntry.idl; sourceTree = "<group>"; };
8AF4E55211DC5A36000ED3DE /* PerformanceNavigation.cpp */,
8AF4E55311DC5A36000ED3DE /* PerformanceNavigation.h */,
8AF4E55411DC5A36000ED3DE /* PerformanceNavigation.idl */,
+ 86512EDB154A2AEE00A90426 /* PerformanceResourceTiming.cpp */,
+ 86512EDC154A2AEF00A90426 /* PerformanceResourceTiming.h */,
+ 86512EDD154A2AEF00A90426 /* PerformanceResourceTiming.idl */,
8AF4E55811DC5A63000ED3DE /* PerformanceTiming.cpp */,
8AF4E55911DC5A63000ED3DE /* PerformanceTiming.h */,
8AF4E55A11DC5A63000ED3DE /* PerformanceTiming.idl */,
86BE340115058CB200CE0FD8 /* PerformanceEntry.h in Headers */,
86BE340415058CB200CE0FD8 /* PerformanceEntryList.h in Headers */,
8AF4E55611DC5A36000ED3DE /* PerformanceNavigation.h in Headers */,
+ 86512EDF154A2AEF00A90426 /* PerformanceResourceTiming.h in Headers */,
8AF4E55C11DC5A63000ED3DE /* PerformanceTiming.h in Headers */,
49D5DC2E0F423A73008F20FD /* PerspectiveTransformOperation.h in Headers */,
D0FF2A5E11F8C45A007E74E0 /* PingLoader.h in Headers */,
86BE340015058CB200CE0FD8 /* PerformanceEntry.cpp in Sources */,
86BE340315058CB200CE0FD8 /* PerformanceEntryList.cpp in Sources */,
8AF4E55511DC5A36000ED3DE /* PerformanceNavigation.cpp in Sources */,
+ 86512EDE154A2AEF00A90426 /* PerformanceResourceTiming.cpp in Sources */,
8AF4E55B11DC5A63000ED3DE /* PerformanceTiming.cpp in Sources */,
49D5DC2D0F423A73008F20FD /* PerspectiveTransformOperation.cpp in Sources */,
D0FF2A5D11F8C45A007E74E0 /* PingLoader.cpp in Sources */,
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PerformanceEntry.h"
+
+#if ENABLE(PERFORMANCE_TIMELINE)
+
+#include "Performance.h"
+#include "PerformanceResourceTiming.h"
+
+#include "V8PerformanceEntry.h"
+#include "V8PerformanceResourceTiming.h"
+
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(PerformanceEntry* impl, v8::Isolate* isolate)
+{
+ if (!impl)
+ return v8::Null();
+
+#if ENABLE(RESOURCE_TIMING)
+ if (impl->isResource())
+ return toV8(static_cast<PerformanceResourceTiming*>(impl), isolate);
+#endif
+
+ return V8PerformanceEntry::wrap(impl);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(PERFORMANCE_TIMELINE)
\
macro(webkitnetworkinfochange) \
\
+ macro(webkitresourcetimingbufferfull) \
+ \
// end of DOM_EVENT_NAMES_FOR_EACH
Node
Notification conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS
PeerConnection00 conditional=MEDIA_STREAM
+Performance conditional=WEB_TIMING
SharedWorker conditional=SHARED_WORKERS
SharedWorkerContext conditional=SHARED_WORKERS
SpeechRecognition conditional=SCRIPTED_SPEECH
#include "Document.h"
#include "DocumentLoader.h"
#include "MemoryInfo.h"
+#include "PerformanceEntry.h"
#include "PerformanceNavigation.h"
+#include "PerformanceResourceTiming.h"
#include "PerformanceTiming.h"
+#include "ResourceResponse.h"
#include <wtf/CurrentTime.h>
#if ENABLE(WEB_TIMING)
{
}
+Performance::~Performance()
+{
+}
+
+const AtomicString& Performance::interfaceName() const
+{
+ return eventNames().interfaceForPerformance;
+}
+
+ScriptExecutionContext* Performance::scriptExecutionContext() const
+{
+ if (!frame())
+ return 0;
+ return frame()->document();
+}
+
PassRefPtr<MemoryInfo> Performance::memory() const
{
return MemoryInfo::create(m_frame);
PassRefPtr<PerformanceEntryList> Performance::webkitGetEntries() const
{
RefPtr<PerformanceEntryList> entries = PerformanceEntryList::create();
+
+#if ENABLE(RESOURCE_TIMING)
+ entries->appendAll(m_resourceTimingBuffer);
+#endif // ENABLE(RESOURCE_TIMING)
+
return entries;
}
-PassRefPtr<PerformanceEntryList> Performance::webkitGetEntriesByType(const String&)
+PassRefPtr<PerformanceEntryList> Performance::webkitGetEntriesByType(const String& entryType)
{
RefPtr<PerformanceEntryList> entries = PerformanceEntryList::create();
+
+#if ENABLE(RESOURCE_TIMING)
+ if (equalIgnoringCase(entryType, "resource"))
+ for (Vector<RefPtr<PerformanceEntry> >::const_iterator resource = m_resourceTimingBuffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource)
+ entries->append(*resource);
+#endif // ENABLE(RESOURCE_TIMING)
+
return entries;
}
-PassRefPtr<PerformanceEntryList> Performance::webkitGetEntriesByName(const String&, const String&)
+PassRefPtr<PerformanceEntryList> Performance::webkitGetEntriesByName(const String& name, const String& entryType)
{
RefPtr<PerformanceEntryList> entries = PerformanceEntryList::create();
+
+#if ENABLE(RESOURCE_TIMING)
+ if (entryType.isNull() || equalIgnoringCase(entryType, "resource"))
+ for (Vector<RefPtr<PerformanceEntry> >::const_iterator resource = m_resourceTimingBuffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource)
+ if ((*resource)->name() == name)
+ entries->append(*resource);
+#endif // ENABLE(RESOURCE_TIMING)
+
return entries;
}
#endif // ENABLE(PERFORMANCE_TIMELINE)
+#if ENABLE(RESOURCE_TIMING)
+
+void Performance::webkitClearResourceTimings()
+{
+ m_resourceTimingBuffer.clear();
+}
+
+void Performance::webkitSetResourceTimingBufferSize(unsigned int)
+{
+ // FIXME: Implement this.
+}
+
+void Performance::addResourceTiming(const ResourceRequest& request, const ResourceResponse& response, double finishTime, Document* requestingDocument)
+{
+ if (!response.resourceLoadTiming())
+ return;
+
+ RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(request, response, finishTime, requestingDocument);
+ // FIXME: Need to enforce buffer limits.
+ m_resourceTimingBuffer.append(entry);
+}
+
+#endif // ENABLE(RESOURCE_TIMING)
+
+EventTargetData* Performance::eventTargetData()
+{
+ return &m_eventTargetData;
+}
+
+EventTargetData* Performance::ensureEventTargetData()
+{
+ return &m_eventTargetData;
+}
+
double Performance::webkitNow() const
{
return 1000.0 * m_frame->document()->loader()->timing()->convertMonotonicTimeToZeroBasedDocumentTime(monotonicallyIncreasingTime());
#if ENABLE(WEB_TIMING)
#include "DOMWindowProperty.h"
+#include "EventTarget.h"
#include "MemoryInfo.h"
#include "PerformanceEntryList.h"
#include "PerformanceNavigation.h"
namespace WebCore {
-class Performance : public RefCounted<Performance>, public DOMWindowProperty {
+class Document;
+class ResourceRequest;
+class ResourceResponse;
+
+class Performance : public RefCounted<Performance>, public DOMWindowProperty, public EventTarget {
public:
static PassRefPtr<Performance> create(Frame* frame) { return adoptRef(new Performance(frame)); }
+ ~Performance();
+
+ virtual const AtomicString& interfaceName() const;
+ virtual ScriptExecutionContext* scriptExecutionContext() const;
PassRefPtr<MemoryInfo> memory() const;
PerformanceNavigation* navigation() const;
PassRefPtr<PerformanceEntryList> webkitGetEntriesByName(const String& name, const String& entryType);
#endif
+#if ENABLE(RESOURCE_TIMING)
+ void webkitClearResourceTimings();
+ void webkitSetResourceTimingBufferSize(unsigned int);
+
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull);
+
+ void addResourceTiming(const ResourceRequest&, const ResourceResponse&, double finishTime, Document*);
+#endif
+
+ using RefCounted<Performance>::ref;
+ using RefCounted<Performance>::deref;
+
private:
explicit Performance(Frame*);
+ virtual void refEventTarget() { ref(); }
+ virtual void derefEventTarget() { deref(); }
+ virtual EventTargetData* eventTargetData();
+ virtual EventTargetData* ensureEventTargetData();
+
+ EventTargetData m_eventTargetData;
+ ScriptExecutionContext *m_scriptExecutionContext;
+
mutable RefPtr<PerformanceNavigation> m_navigation;
mutable RefPtr<PerformanceTiming> m_timing;
+
+#if ENABLE(RESOURCE_TIMING)
+ Vector<RefPtr<PerformanceEntry> > m_resourceTimingBuffer;
+#endif
};
}
// See: http://dev.w3.org/2006/webapi/WebTiming/
interface [
Conditional=WEB_TIMING,
+ EventTarget,
OmitConstructor
] Performance {
readonly attribute PerformanceNavigation navigation;
PerformanceEntryList webkitGetEntriesByType(in DOMString entryType);
PerformanceEntryList webkitGetEntriesByName(in DOMString name, in [Optional=DefaultIsNullString] DOMString entryType);
#endif
+
+#if defined(ENABLE_RESOURCE_TIMING) && ENABLE_RESOURCE_TIMING
+ void webkitClearResourceTimings();
+ void webkitSetResourceTimingBufferSize(in unsigned long maxSize);
+
+ attribute EventListener onwebkitresourcetimingbufferfull;
+#endif
// See http://www.w3.org/TR/hr-time/ for details.
double webkitNow();
};
{
}
+PerformanceEntry::~PerformanceEntry()
+{
+}
+
String PerformanceEntry::name() const
{
return m_name;
class PerformanceEntry : public RefCounted<PerformanceEntry> {
public:
+ virtual ~PerformanceEntry();
+
String name() const;
String entryType() const;
double startTime() const;
double duration() const;
+ virtual bool isResource() { return false; }
+
protected:
PerformanceEntry(const String& name, const String& entryType, double startTime, double duration);
interface [
Conditional=WEB_TIMING,
Conditional=PERFORMANCE_TIMELINE,
+ CustomToJSObject,
OmitConstructor
] PerformanceEntry {
readonly attribute DOMString name;
m_entries.append(entry);
}
+void PerformanceEntryList::appendAll(const Vector<RefPtr<PerformanceEntry> >& entries)
+{
+ m_entries.append(entries);
+}
+
} // namespace WebCore
#endif // ENABLE(WEB_TIMING) && ENABLE(PERFORMANCE_TIMELINE)
PerformanceEntry* item(unsigned index);
void append(PassRefPtr<PerformanceEntry>);
+ void appendAll(const Vector<RefPtr<PerformanceEntry> >&);
private:
PerformanceEntryList();
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PerformanceResourceTiming.h"
+
+#if ENABLE(RESOURCE_TIMING)
+
+#include "Document.h"
+#include "DocumentLoadTiming.h"
+#include "DocumentLoader.h"
+#include "KURL.h"
+#include "ResourceRequest.h"
+#include "ResourceResponse.h"
+#include "SecurityOrigin.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+PerformanceResourceTiming::PerformanceResourceTiming(const ResourceRequest& request, const ResourceResponse& response, double finishTime, Document* requestingDocument)
+ : PerformanceEntry(request.url().string(), "resource", response.resourceLoadTiming()->requestTime, finishTime)
+ , m_timing(response.resourceLoadTiming())
+ , m_finishTime(finishTime)
+ , m_requestingDocument(requestingDocument)
+{
+}
+
+PerformanceResourceTiming::~PerformanceResourceTiming()
+{
+}
+
+String PerformanceResourceTiming::initiatorType() const
+{
+ // FIXME: This should be decided by the resource type.
+ return "other";
+}
+
+// FIXME: Need to enforce same-origin policy on these.
+
+double PerformanceResourceTiming::redirectStart() const
+{
+ // FIXME: Need to track and report redirects for resources.
+ return 0;
+}
+
+double PerformanceResourceTiming::redirectEnd() const
+{
+ return 0;
+}
+
+double PerformanceResourceTiming::fetchStart() const
+{
+ return monotonicTimeToDocumentMilliseconds(m_timing->requestTime);
+}
+
+double PerformanceResourceTiming::domainLookupStart() const
+{
+ if (m_timing->dnsStart < 0)
+ return fetchStart();
+
+ return resourceTimeToDocumentMilliseconds(m_timing->dnsStart);
+}
+
+double PerformanceResourceTiming::domainLookupEnd() const
+{
+ if (m_timing->dnsEnd < 0)
+ return domainLookupStart();
+
+ return resourceTimeToDocumentMilliseconds(m_timing->dnsEnd);
+}
+
+double PerformanceResourceTiming::connectStart() const
+{
+ if (m_timing->connectStart < 0) // Connection was reused.
+ return domainLookupEnd();
+
+ // connectStart includes any DNS time, so we may need to trim that off.
+ int connectStart = m_timing->connectStart;
+ if (m_timing->dnsEnd >= 0)
+ connectStart = m_timing->dnsEnd;
+
+ return resourceTimeToDocumentMilliseconds(connectStart);
+}
+
+double PerformanceResourceTiming::connectEnd() const
+{
+ if (m_timing->connectEnd < 0) // Connection was reused.
+ return connectStart();
+
+ return resourceTimeToDocumentMilliseconds(m_timing->connectEnd);
+}
+
+double PerformanceResourceTiming::secureConnectionStart() const
+{
+ if (m_timing->sslStart < 0) // Secure connection not negotiated.
+ return 0;
+
+ return resourceTimeToDocumentMilliseconds(m_timing->sslStart);
+}
+
+double PerformanceResourceTiming::requestStart() const
+{
+ return resourceTimeToDocumentMilliseconds(m_timing->sendStart);
+}
+
+double PerformanceResourceTiming::responseStart() const
+{
+ // 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;
+}
+
+double PerformanceResourceTiming::resourceTimeToDocumentMilliseconds(int deltaMilliseconds) const
+{
+ return monotonicTimeToDocumentMilliseconds(m_timing->requestTime) + deltaMilliseconds;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(RESOURCE_TIMING)
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PerformanceResourceTiming_h
+#define PerformanceResourceTiming_h
+
+#if ENABLE(RESOURCE_TIMING)
+
+#include "PerformanceEntry.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class Document;
+class KURL;
+class ResourceLoadTiming;
+class ResourceRequest;
+class ResourceResponse;
+
+class PerformanceResourceTiming : public PerformanceEntry {
+public:
+ static PassRefPtr<PerformanceResourceTiming> create(const ResourceRequest& request, const ResourceResponse& response, double finishTime, Document* requestingDocument)
+ {
+ return adoptRef(new PerformanceResourceTiming(request, response, finishTime, requestingDocument));
+ }
+
+ String initiatorType() const;
+
+ double redirectStart() const;
+ double redirectEnd() const;
+ double fetchStart() const;
+ double domainLookupStart() const;
+ double domainLookupEnd() const;
+ double connectStart() const;
+ double connectEnd() const;
+ double secureConnectionStart() const;
+ double requestStart() const;
+ double responseStart() const;
+ double responseEnd() const;
+
+ virtual bool isResource() { return true; }
+
+private:
+ PerformanceResourceTiming(const ResourceRequest&, const ResourceResponse&, double finishTime, Document*);
+ ~PerformanceResourceTiming();
+
+ double monotonicTimeToDocumentMilliseconds(double seconds) const;
+ double resourceTimeToDocumentMilliseconds(int deltaMilliseconds) const;
+
+ RefPtr<ResourceLoadTiming> m_timing;
+ double m_finishTime;
+ RefPtr<Document> m_requestingDocument;
+};
+
+}
+
+#endif // ENABLE(RESOURCE_TIMING)
+
+#endif // !defined(PerformanceResourceTiming_h)
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module window {
+
+ // See: https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/ResourceTiming/Overview.html
+ interface [
+ Conditional=RESOURCE_TIMING,
+ OmitConstructor
+ ] PerformanceResourceTiming : PerformanceEntry {
+ readonly attribute DOMString initiatorType;
+
+ readonly attribute double redirectStart;
+ readonly attribute double redirectEnd;
+ readonly attribute double fetchStart;
+ readonly attribute double domainLookupStart;
+ readonly attribute double domainLookupEnd;
+ readonly attribute double connectStart;
+ readonly attribute double connectEnd;
+ readonly attribute double secureConnectionStart;
+ readonly attribute double requestStart;
+ readonly attribute double responseStart;
+ readonly attribute double responseEnd;
+ };
+}