[Resource Timing] Implement Resource Timing interface
authorsimonjam@chromium.org <simonjam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jun 2012 21:15:19 +0000 (21:15 +0000)
committersimonjam@chromium.org <simonjam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jun 2012 21:15:19 +0000 (21:15 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@120962 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.pri
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/UseV8.cmake
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/v8/custom/V8PerformanceEntryCustom.cpp [new file with mode: 0644]
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventTargetFactory.in
Source/WebCore/page/Performance.cpp
Source/WebCore/page/Performance.h
Source/WebCore/page/Performance.idl
Source/WebCore/page/PerformanceEntry.cpp
Source/WebCore/page/PerformanceEntry.h
Source/WebCore/page/PerformanceEntry.idl
Source/WebCore/page/PerformanceEntryList.cpp
Source/WebCore/page/PerformanceEntryList.h
Source/WebCore/page/PerformanceResourceTiming.cpp [new file with mode: 0644]
Source/WebCore/page/PerformanceResourceTiming.h [new file with mode: 0644]
Source/WebCore/page/PerformanceResourceTiming.idl [new file with mode: 0644]

index ec7f6d7..3f6f232 100644 (file)
@@ -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
index 62c5d8d..a36cf46 100644 (file)
@@ -1,3 +1,81 @@
+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
index 3e5fa4d..48ed801 100644 (file)
@@ -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 \
index 9d15978..cbd008c 100644 (file)
@@ -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 \
index 20f0be6..4f999f7 100644 (file)
@@ -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 \
index fffc26b..2cfc25a 100755 (executable)
@@ -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
index 7a5f84a..7d2cf44 100644 (file)
             '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',
index fedcce8..0d10e62 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\page\PerformanceResourceTiming.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\page\PerformanceResourceTiming.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\page\PerformanceTiming.cpp"
                                >
                        </File>
index 2de77fd..a11ae19 100644 (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 */,
diff --git a/Source/WebCore/bindings/v8/custom/V8PerformanceEntryCustom.cpp b/Source/WebCore/bindings/v8/custom/V8PerformanceEntryCustom.cpp
new file mode 100644 (file)
index 0000000..74df9c7
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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)
index d8f5fdb..3056d4a 100644 (file)
@@ -227,6 +227,8 @@ namespace WebCore {
     \
     macro(webkitnetworkinfochange) \
     \
+    macro(webkitresourcetimingbufferfull) \
+    \
 
 // end of DOM_EVENT_NAMES_FOR_EACH
 
index f01b811..3ec6db9 100644 (file)
@@ -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
index 5bf23b6..9033930 100644 (file)
 #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());
index aa4c792..deae0ae 100644 (file)
@@ -34,6 +34,7 @@
 #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;
@@ -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
 };
 
 }
index 663b742..fc9ffdf 100644 (file)
@@ -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();
     };
index ac523c6..ad69547 100644 (file)
@@ -43,6 +43,10 @@ PerformanceEntry::PerformanceEntry(const String& name, const String& entryType,
 {
 }
 
+PerformanceEntry::~PerformanceEntry()
+{
+}
+
 String PerformanceEntry::name() const
 {
     return m_name;
index 8666e43..6d96721 100644 (file)
@@ -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);
 
index a788bd9..9e10fe0 100644 (file)
@@ -34,6 +34,7 @@ module window {
     interface [
         Conditional=WEB_TIMING,
         Conditional=PERFORMANCE_TIMELINE,
+        CustomToJSObject,
         OmitConstructor
     ] PerformanceEntry {
         readonly attribute DOMString name;
index a4e09a3..9f273bc 100644 (file)
@@ -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)
index 0ecf9ba..8f76267 100644 (file)
@@ -51,6 +51,7 @@ public:
     PerformanceEntry* item(unsigned index);
 
     void append(PassRefPtr<PerformanceEntry>);
+    void appendAll(const Vector<RefPtr<PerformanceEntry> >&);
 
 private:
     PerformanceEntryList();
diff --git a/Source/WebCore/page/PerformanceResourceTiming.cpp b/Source/WebCore/page/PerformanceResourceTiming.cpp
new file mode 100644 (file)
index 0000000..0976add
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * 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)
diff --git a/Source/WebCore/page/PerformanceResourceTiming.h b/Source/WebCore/page/PerformanceResourceTiming.h
new file mode 100644 (file)
index 0000000..082b892
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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)
diff --git a/Source/WebCore/page/PerformanceResourceTiming.idl b/Source/WebCore/page/PerformanceResourceTiming.idl
new file mode 100644 (file)
index 0000000..3e0ad59
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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;
+    };
+}