Commit 0c0aa712 authored by simonjam@chromium.org's avatar 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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1ca4f2e3
......@@ -396,6 +396,7 @@ SET(WebCore_IDL_FILES
page/PerformanceEntry.idl
page/PerformanceEntryList.idl
page/PerformanceNavigation.idl
page/PerformanceResourceTiming.idl
page/PerformanceTiming.idl
page/Screen.idl
page/SpeechInputEvent.idl
......@@ -1087,6 +1088,7 @@ SET(WebCore_SOURCES
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
......@@ -425,6 +425,7 @@ IDL_BINDINGS += \
$$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 \
......
......@@ -957,6 +957,7 @@ dom_binding_idls += \
$(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 \
......@@ -3042,6 +3043,8 @@ webcore_sources += \
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 \
......
......@@ -208,6 +208,7 @@ v8 {
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 \
......@@ -1050,6 +1051,7 @@ SOURCES += \
page/PerformanceEntry.cpp \
page/PerformanceEntryList.cpp \
page/PerformanceNavigation.cpp \
page/PerformanceResourceTiming.cpp \
page/PerformanceTiming.cpp \
page/PrintContext.cpp \
page/Screen.cpp \
......
......@@ -140,6 +140,7 @@ LIST(APPEND WebCore_SOURCES
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
......
......@@ -1167,6 +1167,7 @@
'page/PerformanceEntry.idl',
'page/PerformanceEntryList.idl',
'page/PerformanceNavigation.idl',
'page/PerformanceResourceTiming.idl',
'page/PerformanceTiming.idl',
'page/PointerLock.idl',
'page/Screen.idl',
......@@ -2335,6 +2336,7 @@
'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',
......@@ -3072,6 +3074,8 @@
'page/PerformanceEntryList.h',
'page/PerformanceNavigation.cpp',
'page/PerformanceNavigation.h',
'page/PerformanceResourceTiming.cpp',
'page/PerformanceResourceTiming.h',
'page/PerformanceTiming.cpp',
'page/PerformanceTiming.h',
'page/PointerLock.cpp',
......
......@@ -26878,6 +26878,14 @@
RelativePath="..\page\PerformanceNavigation.h"
>
</File>
<File
RelativePath="..\page\PerformanceResourceTiming.cpp"
>
</File>
<File
RelativePath="..\page\PerformanceResourceTiming.h"
>
</File>
<File
RelativePath="..\page\PerformanceTiming.cpp"
>
......@@ -2898,6 +2898,8 @@
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 */; };
......@@ -9960,6 +9962,9 @@
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>"; };
......@@ -15619,6 +15624,9 @@
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 */,
......@@ -24161,6 +24169,7 @@
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 */,
......@@ -27394,6 +27403,7 @@
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 */,
/*
* 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)
......@@ -227,6 +227,8 @@ namespace WebCore {
\
macro(webkitnetworkinfochange) \
\
macro(webkitresourcetimingbufferfull) \
\
// end of DOM_EVENT_NAMES_FOR_EACH
......
......@@ -22,6 +22,7 @@ NetworkInfoConnection conditional=NETWORK_INFO
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
......
......@@ -34,8 +34,11 @@
#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)
......@@ -49,6 +52,22 @@ Performance::Performance(Frame* frame)
{
}
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);
......@@ -75,23 +94,77 @@ PerformanceTiming* Performance::timing() const
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());
......
......@@ -34,6 +34,7 @@
#if ENABLE(WEB_TIMING)
#include "DOMWindowProperty.h"
#include "EventTarget.h"
#include "MemoryInfo.h"
#include "PerformanceEntryList.h"
#include "PerformanceNavigation.h"
......@@ -45,9 +46,17 @@
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;
......@@ -60,11 +69,35 @@ public:
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
};
}
......
......@@ -33,6 +33,7 @@ module window {
// See: http://dev.w3.org/2006/webapi/WebTiming/
interface [
Conditional=WEB_TIMING,
EventTarget,
OmitConstructor
] Performance {
readonly attribute PerformanceNavigation navigation;
......@@ -44,6 +45,13 @@ module window {
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();
};
......
......@@ -43,6 +43,10 @@ PerformanceEntry::PerformanceEntry(const String& name, const String& entryType,
{
}
PerformanceEntry::~PerformanceEntry()
{
}
String PerformanceEntry::name() const
{
return m_name;
......
......@@ -42,11 +42,15 @@ namespace WebCore {
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);
......
......@@ -34,6 +34,7 @@ module window {
interface [
Conditional=WEB_TIMING,
Conditional=PERFORMANCE_TIMELINE,
CustomToJSObject,
OmitConstructor
] PerformanceEntry {
readonly attribute DOMString name;
......
......@@ -62,6 +62,11 @@ void PerformanceEntryList::append(PassRefPtr<PerformanceEntry> entry)
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)
......@@ -51,6 +51,7 @@ public:
PerformanceEntry* item(unsigned index);
void append(PassRefPtr<PerformanceEntry>);
void appendAll(const Vector<RefPtr<PerformanceEntry> >&);
private:
PerformanceEntryList();
......
/*
* 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