Changeset 63689 in webkit


Ignore:
Timestamp:
Jul 19, 2010 2:55:13 PM (14 years ago)
Author:
tonyg@chromium.org
Message:

2010-07-17 Tony Gentilcore <tonyg@chromium.org>

Reviewed by Darin Fisher.

[Web Timing] Move times to DocumentLoader and fix bugs in mark points
https://bugs.webkit.org/show_bug.cgi?id=42512

  • fast/dom/script-tests/webtiming-navigate-within-document.js: Added. Previously, navigating within a document via a fragment would reset navigationStart. This test verifies that no times are changed after navigating within a document. (checkTimingNotChanged): (): (loadHandler):
  • fast/dom/webtiming-expected.txt: Test now passes because when correcting for clock skew, requestTime is set to fetchStart when it is less than fetchStart. Previously it was 0, now it is fetchStart. This, unfortunately, hides the fact that test_shell isn't populating the ResourceLoadTiming API. I'll think of a way to test that when I make the change to cause test_shell to fill the ResourceLoadTiming.
  • fast/dom/webtiming-navigate-within-document-expected.txt: Added.
  • fast/dom/webtiming-navigate-within-document.html: Added.
  • platform/gtk/Skipped: Skip new test on platform where Web Timing is not enabled.
  • platform/mac/Skipped: Skip new test on platform where Web Timing is not enabled.
  • platform/qt/Skipped: Skip new test on platform where Web Timing is not enabled.
  • platform/win/Skipped: Skip new test on platform where Web Timing is not enabled.

2010-07-17 Tony Gentilcore <tonyg@chromium.org>

Reviewed by Darin Fisher.

[Web Timing] Move times to DocumentLoader and fix bugs in mark points
https://bugs.webkit.org/show_bug.cgi?id=42512

Test: fast/dom/webtiming-navigate-within-document.html

  • loader/DocumentLoader.h: Move the FrameLoadTimeline (now call DocumentLoadTiming) to the DocumentLoader. (WebCore::DocumentLoader::documentLoadTiming):
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::stopLoading): Set unloadEventEnd on the provisional DocumentLoader. Add some ASSERTs to tighten things up. (WebCore::FrameLoader::loadWithDocumentLoader): This was not the right place to set navigationStart. Setting it here caused it to be set before the unload form prompt and caused it to be reset when navigating within the document. (WebCore::FrameLoader::finishedLoading): Set responseEnd on the active DocumentLoader. (WebCore::FrameLoader::continueLoadAfterWillSubmitForm): This is the right place for navigationStart as defined by the spec.
  • loader/FrameLoader.h: Get rid of FrameLoadTimeline.
  • loader/FrameLoaderTypes.h: Rename FrameLoadTimeline to DocumentLoadTiming. It is even more apparent this doesn't belong in this file now. I am planning to submit a patch moving it out ASAP, but didn't want to muddy this patch with all those build files. (WebCore::DocumentLoadTiming::DocumentLoadTiming):
  • loader/MainResourceLoader.cpp: (WebCore::MainResourceLoader::willSendRequest): Move fetchStart out of this method to load(), and rewrite setting of redirectStart, redirectEnd, and redirectCount to be more readable. (WebCore::MainResourceLoader::load): Set fetchStart slightly earlier here and tighten it up with some ASSERTs.
  • page/DOMWindow.cpp: (WebCore::DOMWindow::dispatchLoadEvent): Set loadEventStart and loadEventEnd on the DocumentLoader.
  • page/Navigation.cpp: (WebCore::Navigation::redirectCount): Retrieve redirectCount from the DocumentLoader.
  • page/Timing.cpp: (WebCore::getPossiblySkewedTimeInKnownRange): The skew problem turned out to be due to the fact that chromium's currentTime() implementation only syncs to the system time every 60 seconds. So absolute times across threads may be skewed slightly. I resolved this temporarily by clipping the time from another thread into a known bound. A better long term solution is probably to add a currentTimeFromSystemTime() method and call that for web timing marks. (WebCore::Timing::navigationStart): (WebCore::Timing::unloadEventEnd): (WebCore::Timing::redirectStart): (WebCore::Timing::redirectEnd): (WebCore::Timing::fetchStart): (WebCore::Timing::domainLookupStart): (WebCore::Timing::domainLookupEnd): (WebCore::Timing::connectStart): (WebCore::Timing::connectEnd): (WebCore::Timing::requestStart): (WebCore::Timing::requestEnd): (WebCore::Timing::responseStart): (WebCore::Timing::responseEnd): (WebCore::Timing::loadEventStart): (WebCore::Timing::loadEventEnd): (WebCore::Timing::documentLoader): (WebCore::Timing::documentLoadTiming): (WebCore::Timing::resourceLoadTiming): (WebCore::Timing::resourceLoadTimeRelativeToAbsolute): Ensure requestTime is in the range of fetchStart to responseEnd.
  • page/Timing.h:
Location:
trunk
Files:
3 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r63686 r63689  
     12010-07-17  Tony Gentilcore  <tonyg@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [Web Timing] Move times to DocumentLoader and fix bugs in mark points
     6        https://bugs.webkit.org/show_bug.cgi?id=42512
     7
     8        * fast/dom/script-tests/webtiming-navigate-within-document.js: Added. Previously, navigating within a document via a fragment would reset navigationStart. This test verifies that no times are changed after navigating within a document.
     9        (checkTimingNotChanged):
     10        ():
     11        (loadHandler):
     12        * fast/dom/webtiming-expected.txt: Test now passes because when correcting for clock skew, requestTime is set to fetchStart when it is less than fetchStart. Previously it was 0, now it is fetchStart. This, unfortunately, hides the fact that test_shell isn't populating the ResourceLoadTiming API. I'll think of a way to test that when I make the change to cause test_shell to fill the ResourceLoadTiming.
     13        * fast/dom/webtiming-navigate-within-document-expected.txt: Added.
     14        * fast/dom/webtiming-navigate-within-document.html: Added.
     15        * platform/gtk/Skipped: Skip new test on platform where Web Timing is not enabled.
     16        * platform/mac/Skipped: Skip new test on platform where Web Timing is not enabled.
     17        * platform/qt/Skipped: Skip new test on platform where Web Timing is not enabled.
     18        * platform/win/Skipped: Skip new test on platform where Web Timing is not enabled.
     19
    1202010-07-19  Eric Carlson  <eric.carlson@apple.com>
    221
  • trunk/LayoutTests/fast/dom/webtiming-expected.txt

    r63559 r63689  
    1414PASS timing.connectStart is >= timing.domainLookupEnd
    1515PASS timing.connectEnd is >= timing.connectStart
    16 FAIL timing.requestStart should be >= timing.connectEnd. Was 0 (of type number).
     16PASS timing.requestStart is >= timing.connectEnd
    1717PASS timing.requestEnd is >= timing.requestStart
    1818PASS timing.responseStart is >= timing.requestEnd
     
    2929PASS timing.connectStart is >= timing.domainLookupEnd
    3030PASS timing.connectEnd is >= timing.connectStart
    31 FAIL timing.requestStart should be >= timing.connectEnd. Was 0 (of type number).
     31PASS timing.requestStart is >= timing.connectEnd
    3232PASS timing.requestEnd is >= timing.requestStart
    3333PASS timing.responseStart is >= timing.requestEnd
     
    4545PASS timing.connectStart is >= timing.domainLookupEnd
    4646PASS timing.connectEnd is >= timing.connectStart
    47 FAIL timing.requestStart should be >= timing.connectEnd. Was 0 (of type number).
     47PASS timing.requestStart is >= timing.connectEnd
    4848PASS timing.requestEnd is >= timing.requestStart
    4949PASS timing.responseStart is >= timing.requestEnd
  • trunk/LayoutTests/platform/gtk/Skipped

    r63616 r63689  
    58655865fast/dom/navigation-type-reload.html
    58665866fast/dom/webtiming.html
     5867fast/dom/webtiming-navigate-within-document.html
    58675868http/tests/misc/webtiming-one-redirect.php
    58685869http/tests/misc/webtiming-two-redirects.php
  • trunk/LayoutTests/platform/mac/Skipped

    r63623 r63689  
    291291fast/dom/navigation-type-reload.html
    292292fast/dom/webtiming.html
     293fast/dom/webtiming-navigate-within-document.html
    293294http/tests/misc/webtiming-one-redirect.php
    294295http/tests/misc/webtiming-two-redirects.php
  • trunk/LayoutTests/platform/qt/Skipped

    r63679 r63689  
    54505450fast/dom/navigation-type-reload.html
    54515451fast/dom/webtiming.html
     5452fast/dom/webtiming-navigate-within-document.html
    54525453http/tests/misc/webtiming-one-redirect.php
    54535454http/tests/misc/webtiming-two-redirects.php
  • trunk/LayoutTests/platform/win/Skipped

    r63616 r63689  
    959959fast/dom/navigation-type-reload.html
    960960fast/dom/webtiming.html
     961fast/dom/webtiming-navigate-within-document.html
    961962http/tests/misc/webtiming-one-redirect.php
    962963http/tests/misc/webtiming-two-redirects.php
  • trunk/WebCore/ChangeLog

    r63688 r63689  
     12010-07-17  Tony Gentilcore  <tonyg@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [Web Timing] Move times to DocumentLoader and fix bugs in mark points
     6        https://bugs.webkit.org/show_bug.cgi?id=42512
     7
     8        Test: fast/dom/webtiming-navigate-within-document.html
     9
     10        * loader/DocumentLoader.h: Move the FrameLoadTimeline (now call DocumentLoadTiming) to the DocumentLoader.
     11        (WebCore::DocumentLoader::documentLoadTiming):
     12        * loader/FrameLoader.cpp:
     13        (WebCore::FrameLoader::stopLoading): Set unloadEventEnd on the provisional DocumentLoader. Add some ASSERTs to tighten things up.
     14        (WebCore::FrameLoader::loadWithDocumentLoader): This was not the right place to set navigationStart. Setting it here caused it to be set before the unload form prompt and caused it to be reset when navigating within the document.
     15        (WebCore::FrameLoader::finishedLoading): Set responseEnd on the active DocumentLoader.
     16        (WebCore::FrameLoader::continueLoadAfterWillSubmitForm): This is the right place for navigationStart as defined by the spec.
     17        * loader/FrameLoader.h: Get rid of FrameLoadTimeline.
     18        * loader/FrameLoaderTypes.h: Rename FrameLoadTimeline to DocumentLoadTiming. It is even more apparent this doesn't belong in this file now. I am planning to submit a patch moving it out ASAP, but didn't want to muddy this patch with all those build files.
     19        (WebCore::DocumentLoadTiming::DocumentLoadTiming):
     20        * loader/MainResourceLoader.cpp:
     21        (WebCore::MainResourceLoader::willSendRequest): Move fetchStart out of this method to load(), and rewrite setting of redirectStart, redirectEnd, and redirectCount to be more readable.
     22        (WebCore::MainResourceLoader::load): Set fetchStart slightly earlier here and tighten it up with some ASSERTs.
     23        * page/DOMWindow.cpp:
     24        (WebCore::DOMWindow::dispatchLoadEvent): Set loadEventStart and loadEventEnd on the DocumentLoader.
     25        * page/Navigation.cpp:
     26        (WebCore::Navigation::redirectCount): Retrieve redirectCount from the DocumentLoader.
     27        * page/Timing.cpp:
     28        (WebCore::getPossiblySkewedTimeInKnownRange): The skew problem turned out to be due to the fact that chromium's currentTime() implementation only syncs to the system time every 60 seconds. So absolute times across threads may be skewed slightly. I resolved this temporarily by clipping the time from another thread into a known bound. A better long term solution is probably to add a currentTimeFromSystemTime() method and call that for web timing marks.
     29        (WebCore::Timing::navigationStart):
     30        (WebCore::Timing::unloadEventEnd):
     31        (WebCore::Timing::redirectStart):
     32        (WebCore::Timing::redirectEnd):
     33        (WebCore::Timing::fetchStart):
     34        (WebCore::Timing::domainLookupStart):
     35        (WebCore::Timing::domainLookupEnd):
     36        (WebCore::Timing::connectStart):
     37        (WebCore::Timing::connectEnd):
     38        (WebCore::Timing::requestStart):
     39        (WebCore::Timing::requestEnd):
     40        (WebCore::Timing::responseStart):
     41        (WebCore::Timing::responseEnd):
     42        (WebCore::Timing::loadEventStart):
     43        (WebCore::Timing::loadEventEnd):
     44        (WebCore::Timing::documentLoader):
     45        (WebCore::Timing::documentLoadTiming):
     46        (WebCore::Timing::resourceLoadTiming):
     47        (WebCore::Timing::resourceLoadTimeRelativeToAbsolute): Ensure requestTime is in the range of fetchStart to responseEnd.
     48        * page/Timing.h:
     49
    1502010-07-19  Chris Marrin  <cmarrin@apple.com>
    251
  • trunk/WebCore/loader/DocumentLoader.h

    r60657 r63689  
    206206        void takeMemoryCacheLoadsForClientNotification(Vector<String>& loads);
    207207
     208        DocumentLoadTiming* timing() { return &m_documentLoadTiming; }
     209
    208210#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    209211        ApplicationCacheHost* applicationCacheHost() const { return m_applicationCacheHost.get(); }
     
    295297        bool m_didCreateGlobalHistoryEntry;
    296298
     299        DocumentLoadTiming m_documentLoadTiming;
     300
    297301#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    298302        friend class ApplicationCacheHost;  // for substitute resource delivery
  • trunk/WebCore/loader/FrameLoader.cpp

    r63620 r63689  
    450450                    if (!m_frame->document()->inPageCache())
    451451                        m_frame->domWindow()->dispatchEvent(Event::create(eventNames().unloadEvent, false, false), m_frame->domWindow()->document());
    452                     m_frameLoadTimeline.unloadEventEnd = currentTime();
     452                    if (m_provisionalDocumentLoader) {
     453                        DocumentLoadTiming* timing = m_provisionalDocumentLoader->timing();
     454                        ASSERT(timing->navigationStart);
     455                        ASSERT(!timing->unloadEventEnd);
     456                        timing->unloadEventEnd = currentTime();
     457                        ASSERT(timing->unloadEventEnd >= timing->navigationStart);
     458                    }
    453459                }
    454460                m_pageDismissalEventBeingDispatched = false;
     
    15011507        return;
    15021508
    1503     m_frameLoadTimeline = FrameLoadTimeline();
    1504     m_frameLoadTimeline.navigationStart = currentTime();
    1505 
    15061509    policyChecker()->setLoadType(type);
    15071510    RefPtr<FormState> formState = prpFormState;
     
    22162219    RefPtr<Frame> protect(m_frame);
    22172220
    2218     ASSERT(!m_frameLoadTimeline.responseEnd);
    2219     m_frameLoadTimeline.responseEnd = currentTime();
    2220 
    22212221    RefPtr<DocumentLoader> dl = activeDocumentLoader();
     2222    ASSERT(!dl->timing()->responseEnd);
     2223    dl->timing()->responseEnd = currentTime();
    22222224    dl->finishedLoading();
    22232225    if (!dl->mainDocumentError().isNull() || !dl->frameLoader())
     
    25092511        notifier()->assignIdentifierToInitialRequest(identifier, m_provisionalDocumentLoader.get(), m_provisionalDocumentLoader->originalRequest());
    25102512    }
     2513
     2514    ASSERT(!m_provisionalDocumentLoader->timing()->navigationStart);
     2515    m_provisionalDocumentLoader->timing()->navigationStart = currentTime();
    25112516
    25122517    if (!m_provisionalDocumentLoader->startLoadingMainResource(identifier))
  • trunk/WebCore/loader/FrameLoader.h

    r62984 r63689  
    194194
    195195    FrameLoadType loadType() const;
    196     FrameLoadTimeline* frameLoadTimeline() { return &m_frameLoadTimeline; }
    197196
    198197    CachePolicy subresourceCachePolicy() const;
     
    447446    FrameState m_state;
    448447    FrameLoadType m_loadType;
    449     FrameLoadTimeline m_frameLoadTimeline;
    450448
    451449    // Document loaders for the three phases of frame loading. Note that while
  • trunk/WebCore/loader/FrameLoaderTypes.h

    r63326 r63689  
    6161    };
    6262
    63     // FIXME: Move this to a new header file.
    64     struct FrameLoadTimeline {
    65         FrameLoadTimeline()
     63    // FIXME: Move to DocumentLoadTiming.h.
     64    struct DocumentLoadTiming {
     65        DocumentLoadTiming()
    6666            : navigationStart(0.0)
    6767            , unloadEventEnd(0.0)
  • trunk/WebCore/loader/MainResourceLoader.cpp

    r63332 r63689  
    160160    RefPtr<MainResourceLoader> protect(this);
    161161
    162     FrameLoadTimeline* frameLoadTimeline = frameLoader()->frameLoadTimeline();
    163     double fetchTime = currentTime();
    164     if (double fetchStart = frameLoadTimeline->fetchStart) {
    165         if (!frameLoadTimeline->redirectCount++)
    166             frameLoadTimeline->redirectStart = fetchStart;
    167         frameLoadTimeline->redirectEnd = fetchTime;
    168     }
    169     frameLoadTimeline->fetchStart = fetchTime;
     162    ASSERT(documentLoader()->timing()->fetchStart);
     163    if (!redirectResponse.isNull()) {
     164        DocumentLoadTiming* documentLoadTiming = documentLoader()->timing();
     165        documentLoadTiming->redirectCount++;
     166        if (!documentLoadTiming->redirectStart)
     167            documentLoadTiming->redirectStart = documentLoadTiming->fetchStart;
     168        documentLoadTiming->redirectEnd = currentTime();
     169        documentLoadTiming->fetchStart = documentLoadTiming->redirectEnd;
     170    }
    170171
    171172    // Update cookie policy base URL as URL changes, except for subframes, which use the
     
    543544    m_substituteData = substituteData;
    544545
     546    ASSERT(documentLoader()->timing()->navigationStart);
     547    ASSERT(!documentLoader()->timing()->fetchStart);
     548    documentLoader()->timing()->fetchStart = currentTime();
    545549    ResourceRequest request(r);
    546550
  • trunk/WebCore/page/DOMWindow.cpp

    r63312 r63689  
    3636#include "Chrome.h"
    3737#include "Console.h"
     38#include "DocumentLoader.h"
    3839#include "DOMApplicationCache.h"
    3940#include "DOMSelection.h"
     
    14391440void DOMWindow::dispatchLoadEvent()
    14401441{
    1441     if (m_frame)
    1442         m_frame->loader()->frameLoadTimeline()->loadEventStart = currentTime();
     1442    if (DocumentLoader* documentLoader = m_frame ? m_frame->loader()->documentLoader() : 0)
     1443        documentLoader->timing()->loadEventStart = currentTime();
    14431444    dispatchEvent(Event::create(eventNames().loadEvent, false, false), document());
    1444     if (m_frame)
    1445         m_frame->loader()->frameLoadTimeline()->loadEventEnd = currentTime();
     1445    if (DocumentLoader* documentLoader = m_frame ? m_frame->loader()->documentLoader() : 0)
     1446        documentLoader->timing()->loadEventEnd = currentTime();
    14461447
    14471448    // For load events, send a separate load event to the enclosing frame only.
  • trunk/WebCore/page/Navigation.cpp

    r63356 r63689  
    8080        return 0;
    8181
    82     return m_frame->loader()->frameLoadTimeline()->redirectCount;
     82    DocumentLoader* loader = m_frame->loader()->documentLoader();
     83    if (!loader)
     84        return 0;
     85
     86    return loader->timing()->redirectCount;
    8387}
    8488
  • trunk/WebCore/page/Timing.cpp

    r63569 r63689  
    4141namespace WebCore {
    4242
    43 static unsigned long long toIntegerMilliseconds(double milliseconds)
    44 {
    45     ASSERT(milliseconds >= 0);
    46     return static_cast<unsigned long long>(milliseconds * 1000.0);
     43static unsigned long long toIntegerMilliseconds(double seconds)
     44{
     45    ASSERT(seconds >= 0);
     46    return static_cast<unsigned long long>(seconds * 1000.0);
     47}
     48
     49static double getPossiblySkewedTimeInKnownRange(double skewedTime, double lowerBound, double upperBound)
     50{
     51#if PLATFORM(CHROMIUM)
     52    // The chromium port's currentTime() implementation only syncs with the
     53    // system clock every 60 seconds. So it is possible for timing marks
     54    // collected in different threads or processes to have a small skew.
     55    // FIXME: It may be possible to add a currentTimeFromSystemTime() method
     56    // that eliminates the skew.
     57    if (skewedTime <= lowerBound)
     58        return lowerBound;
     59
     60    if (skewedTime >= upperBound)
     61        return upperBound;
     62#else
     63    ASSERT_UNUSED(lowerBound, skewedTime >= lowerBound);
     64    ASSERT_UNUSED(upperBound, skewedTime <= upperBound);
     65#endif
     66
     67    return skewedTime;
    4768}
    4869
     
    6485unsigned long long Timing::navigationStart() const
    6586{
    66     if (!m_frame)
    67         return 0;
    68 
    69     return toIntegerMilliseconds(m_frame->loader()->frameLoadTimeline()->navigationStart);
     87    DocumentLoadTiming* timing = documentLoadTiming();
     88    if (!timing)
     89        return 0;
     90
     91    return toIntegerMilliseconds(timing->navigationStart);
    7092}
    7193
    7294unsigned long long Timing::unloadEventEnd() const
    7395{
    74     if (!m_frame)
    75         return 0;
    76 
    77     return toIntegerMilliseconds(m_frame->loader()->frameLoadTimeline()->unloadEventEnd);
     96    DocumentLoadTiming* timing = documentLoadTiming();
     97    if (!timing)
     98        return 0;
     99
     100    return toIntegerMilliseconds(timing->unloadEventEnd);
    78101}
    79102   
    80103unsigned long long Timing::redirectStart() const
    81104{
    82     if (!m_frame)
    83         return 0;
    84        
    85     return toIntegerMilliseconds(m_frame->loader()->frameLoadTimeline()->redirectStart);
     105    DocumentLoadTiming* timing = documentLoadTiming();
     106    if (!timing)
     107        return 0;
     108
     109    return toIntegerMilliseconds(timing->redirectStart);
    86110}
    87111   
    88112unsigned long long Timing::redirectEnd() const
    89113{
    90     if (!m_frame)
    91         return 0;
    92        
    93     return toIntegerMilliseconds(m_frame->loader()->frameLoadTimeline()->redirectEnd);
     114    DocumentLoadTiming* timing = documentLoadTiming();
     115    if (!timing)
     116        return 0;
     117
     118    return toIntegerMilliseconds(timing->redirectEnd);
    94119}
    95120
    96121unsigned long long Timing::fetchStart() const
    97122{
    98     if (!m_frame)
    99         return 0;
    100 
    101     return toIntegerMilliseconds(m_frame->loader()->frameLoadTimeline()->fetchStart);
     123    DocumentLoadTiming* timing = documentLoadTiming();
     124    if (!timing)
     125        return 0;
     126
     127    return toIntegerMilliseconds(timing->fetchStart);
    102128}
    103129
     
    114140        return fetchStart();
    115141
    116     return toIntegerMilliseconds(timing->requestTime) + dnsStart;
     142    return resourceLoadTimeRelativeToAbsolute(dnsStart);
    117143}
    118144
     
    129155        return domainLookupStart();
    130156
    131     return toIntegerMilliseconds(timing->requestTime) + dnsEnd;
     157    return resourceLoadTimeRelativeToAbsolute(dnsEnd);
    132158}
    133159
     
    144170        return domainLookupEnd();
    145171
    146     return toIntegerMilliseconds(timing->requestTime) + connectStart;
     172    return resourceLoadTimeRelativeToAbsolute(connectStart);
    147173}
    148174
     
    159185        return connectStart();
    160186
    161     return toIntegerMilliseconds(timing->requestTime) + connectEnd;
     187    return resourceLoadTimeRelativeToAbsolute(connectEnd);
    162188}
    163189
     
    169195
    170196    ASSERT(timing->sendStart >= 0);
    171     return toIntegerMilliseconds(timing->requestTime) + timing->sendStart;
     197    return resourceLoadTimeRelativeToAbsolute(timing->sendStart);
    172198}
    173199
     
    179205
    180206    ASSERT(timing->sendEnd >= 0);
    181     return toIntegerMilliseconds(timing->requestTime) + timing->sendEnd;
     207    return resourceLoadTimeRelativeToAbsolute(timing->sendEnd);
    182208}
    183209
     
    195221    // headers larger than a single packet, this time will be too late.
    196222    ASSERT(timing->receiveHeadersEnd >= 0);
    197     return toIntegerMilliseconds(timing->requestTime) + timing->receiveHeadersEnd;
     223    return resourceLoadTimeRelativeToAbsolute(timing->receiveHeadersEnd);
    198224}
    199225
    200226unsigned long long Timing::responseEnd() const
    201227{
     228    DocumentLoadTiming* timing = documentLoadTiming();
     229    if (!timing)
     230        return 0;
     231
     232    return toIntegerMilliseconds(timing->responseEnd);
     233}
     234
     235unsigned long long Timing::loadEventStart() const
     236{
     237    DocumentLoadTiming* timing = documentLoadTiming();
     238    if (!timing)
     239        return 0;
     240
     241    return toIntegerMilliseconds(timing->loadEventStart);
     242}
     243
     244unsigned long long Timing::loadEventEnd() const
     245{
     246    DocumentLoadTiming* timing = documentLoadTiming();
     247    if (!timing)
     248        return 0;
     249
     250    return toIntegerMilliseconds(timing->loadEventEnd);
     251}
     252
     253DocumentLoader* Timing::documentLoader() const
     254{
    202255    if (!m_frame)
    203256        return 0;
    204257
    205     return toIntegerMilliseconds(m_frame->loader()->frameLoadTimeline()->responseEnd);
    206 }
    207 
    208 unsigned long long Timing::loadEventStart() const
    209 {
    210     if (!m_frame)
    211         return 0;
    212 
    213     return toIntegerMilliseconds(m_frame->loader()->frameLoadTimeline()->loadEventStart);
    214 }
    215 
    216 unsigned long long Timing::loadEventEnd() const
    217 {
    218     if (!m_frame)
    219         return 0;
    220 
    221     return toIntegerMilliseconds(m_frame->loader()->frameLoadTimeline()->loadEventEnd);
     258    return m_frame->loader()->documentLoader();
     259}
     260
     261DocumentLoadTiming* Timing::documentLoadTiming() const
     262{
     263    DocumentLoader* loader = documentLoader();
     264    if (!loader)
     265        return 0;
     266
     267    return loader->timing();
    222268}
    223269
    224270ResourceLoadTiming* Timing::resourceLoadTiming() const
    225271{
    226     DocumentLoader* documentLoader = m_frame->loader()->documentLoader();
    227     if (!documentLoader)
    228         return 0;
    229 
    230     return documentLoader->response().resourceLoadTiming();
     272    DocumentLoader* loader = documentLoader();
     273    if (!loader)
     274        return 0;
     275
     276    return loader->response().resourceLoadTiming();
     277}
     278
     279unsigned long long Timing::resourceLoadTimeRelativeToAbsolute(int relativeSeconds) const
     280{
     281    ASSERT(relativeSeconds >= 0);
     282    ResourceLoadTiming* resourceTiming = resourceLoadTiming();
     283    ASSERT(resourceTiming);
     284    DocumentLoadTiming* documentTiming = documentLoadTiming();
     285    ASSERT(documentTiming);
     286
     287    // The ResourceLoadTiming API's requestTime is the base time to which all
     288    // other marks are relative. So to get an absolute time, we must add it to
     289    // the relative marks.
     290    //
     291    // Since ResourceLoadTimings came from the network platform layer, we must
     292    // check them for skew because they may be from another thread/process.
     293    double baseTime = getPossiblySkewedTimeInKnownRange(resourceTiming->requestTime, documentTiming->fetchStart, documentTiming->responseEnd);
     294    return toIntegerMilliseconds(baseTime) + relativeSeconds;
    231295}
    232296
  • trunk/WebCore/page/Timing.h

    r63426 r63689  
    3939namespace WebCore {
    4040
     41struct DocumentLoadTiming;
     42class DocumentLoader;
    4143class Frame;
    4244class ResourceLoadTiming;
     
    6870    Timing(Frame*);
    6971
     72    DocumentLoader* documentLoader() const;
     73    DocumentLoadTiming* documentLoadTiming() const;
    7074    ResourceLoadTiming* resourceLoadTiming() const;
     75    unsigned long long resourceLoadTimeRelativeToAbsolute(int) const;
    7176
    7277    Frame* m_frame;
Note: See TracChangeset for help on using the changeset viewer.