Changeset 102961 in webkit


Ignore:
Timestamp:
Dec 15, 2011 10:45:29 AM (12 years ago)
Author:
simonjam@chromium.org
Message:

[Navigation Timing] Use monotonicallyIncreasingTime() instead of currentTime()
https://bugs.webkit.org/show_bug.cgi?id=58354

Reviewed by Pavel Feldman.

Source/WebCore:

No new tests. Relies on existing webtiming-* tests.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/Document.cpp: Use monotonic times.

(WebCore::Document::setReadyState):
(WebCore::Document::finishedParsing):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::didFinishLoadingImpl): Convert monotonicFinishTime to wall time if needed.

  • inspector/InspectorResourceAgent.cpp:

(WebCore::buildObjectForTiming): Convert monotonic requestTime to wall time.
(WebCore::buildObjectForResourceResponse): Plumbing for above.
(WebCore::buildObjectForCachedResource): Ditto.
(WebCore::InspectorResourceAgent::willSendRequest): Ditto.
(WebCore::InspectorResourceAgent::didReceiveResponse): Ditto.
(WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache): Ditto.

  • loader/DocumentLoadTiming.cpp: Added.

(WebCore::DocumentLoadTiming::DocumentLoadTiming):
(WebCore::DocumentLoadTiming::setNavigationStart): Determine reference time and root reference time.
(WebCore::DocumentLoadTiming::addRedirect): Moved logic from MainResourceLoader.
(WebCore::DocumentLoadTiming::convertMonotonicTimeToDocumentTime): Helper to compute wall time from monotonic time.

  • loader/DocumentLoadTiming.h: Turned into class. Made times monotonic.

(WebCore::DocumentLoadTiming::setUnloadEventStart):
(WebCore::DocumentLoadTiming::setUnloadEventEnd):
(WebCore::DocumentLoadTiming::setRedirectStart):
(WebCore::DocumentLoadTiming::setRedirectEnd):
(WebCore::DocumentLoadTiming::setFetchStart):
(WebCore::DocumentLoadTiming::setResponseEnd):
(WebCore::DocumentLoadTiming::setLoadEventStart):
(WebCore::DocumentLoadTiming::setLoadEventEnd):
(WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument):
(WebCore::DocumentLoadTiming::navigationStart):
(WebCore::DocumentLoadTiming::unloadEventStart):
(WebCore::DocumentLoadTiming::unloadEventEnd):
(WebCore::DocumentLoadTiming::redirectStart):
(WebCore::DocumentLoadTiming::redirectEnd):
(WebCore::DocumentLoadTiming::redirectCount):
(WebCore::DocumentLoadTiming::fetchStart):
(WebCore::DocumentLoadTiming::responseEnd):
(WebCore::DocumentLoadTiming::loadEventStart):
(WebCore::DocumentLoadTiming::loadEventEnd):
(WebCore::DocumentLoadTiming::hasCrossOriginRedirect):
(WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::stopLoading):
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::continueLoadAfterWillSubmitForm):
(WebCore::FrameLoader::loadProvisionalItemFromCachedPage):

  • loader/MainResourceLoader.cpp:

(WebCore::MainResourceLoader::continueAfterNavigationPolicy):
(WebCore::MainResourceLoader::willSendRequest): Moved logic to DocumentLoadTiming.
(WebCore::MainResourceLoader::didReceiveData): Use monotonic time.
(WebCore::MainResourceLoader::didFinishLoading): Ditto.
(WebCore::MainResourceLoader::load):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::dispatchLoadEvent):

  • page/DOMWindow.h: Removed dispatchTimedEvent. It doesn't really help in the new model.
  • page/PerformanceNavigation.cpp:

(WebCore::PerformanceNavigation::redirectCount):

  • page/PerformanceTiming.cpp: Removed skew correction code. This should never happen now.

(WebCore::PerformanceTiming::navigationStart):
(WebCore::PerformanceTiming::unloadEventStart):
(WebCore::PerformanceTiming::unloadEventEnd):
(WebCore::PerformanceTiming::redirectStart):
(WebCore::PerformanceTiming::redirectEnd):
(WebCore::PerformanceTiming::fetchStart):
(WebCore::PerformanceTiming::responseEnd):
(WebCore::PerformanceTiming::domLoading):
(WebCore::PerformanceTiming::domInteractive):
(WebCore::PerformanceTiming::domContentLoadedEventStart):
(WebCore::PerformanceTiming::domContentLoadedEventEnd):
(WebCore::PerformanceTiming::domComplete):
(WebCore::PerformanceTiming::loadEventStart):
(WebCore::PerformanceTiming::loadEventEnd):
(WebCore::PerformanceTiming::resourceLoadTimeRelativeToAbsolute): Used for ResourceLoadTiming.
(WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds): Used for DocumentTiming and DocumentLoadTiming.

  • page/PerformanceTiming.h:
  • platform/network/ResourceLoadTiming.cpp:

(WebCore::ResourceLoadTiming::convertResourceLoadTimeToDocumentTime):

  • platform/network/ResourceLoadTiming.h: Added helper function to convert to wall times. Added instructions for use.

LayoutTests:

  • fast/dom/script-tests/webtiming.js: Current monotonic time is unknown until performance.now() is available. Use 0 until then.
Location:
trunk
Files:
1 added
21 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r102957 r102961  
     12011-12-15  James Simonsen  <simonjam@chromium.org>
     2
     3        [Navigation Timing] Use monotonicallyIncreasingTime() instead of currentTime()
     4        https://bugs.webkit.org/show_bug.cgi?id=58354
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * fast/dom/script-tests/webtiming.js: Current monotonic time is unknown until performance.now() is available. Use 0 until then.
     9
    1102011-12-15  Kenneth Russell  <kbr@google.com>
    211
  • trunk/LayoutTests/fast/dom/script-tests/webtiming.js

    r102908 r102961  
    77// Get the order of magnitude correct without a chance for flakiness.
    88var oneHourMilliseconds = 60 * 60 * 1000;
    9 var currentUTC = (new Date()).getTime();
     9var currentUTC = 0;  // FIXME: Use performance.now() when available.
    1010var oneHourAgoUTC = currentUTC - oneHourMilliseconds;
    1111
  • trunk/Source/WebCore/CMakeLists.txt

    r102942 r102961  
    916916    loader/CrossOriginAccessControl.cpp
    917917    loader/CrossOriginPreflightResultCache.cpp
     918    loader/DocumentLoadTiming.cpp
    918919    loader/DocumentLoader.cpp
    919920    loader/DocumentThreadableLoader.cpp
     
    11781179    platform/network/ResourceErrorBase.cpp
    11791180    platform/network/ResourceHandle.cpp
     1181    platform/network/ResourceLoadTiming.cpp
    11801182    platform/network/ResourceRequestBase.cpp
    11811183    platform/network/ResourceResponseBase.cpp
  • trunk/Source/WebCore/ChangeLog

    r102958 r102961  
     12011-12-15  James Simonsen  <simonjam@chromium.org>
     2
     3        [Navigation Timing] Use monotonicallyIncreasingTime() instead of currentTime()
     4        https://bugs.webkit.org/show_bug.cgi?id=58354
     5
     6        Reviewed by Pavel Feldman.
     7
     8        No new tests. Relies on existing webtiming-* tests.
     9
     10        * CMakeLists.txt:
     11        * GNUmakefile.list.am:
     12        * WebCore.gypi:
     13        * WebCore.pro:
     14        * WebCore.vcproj/WebCore.vcproj:
     15        * WebCore.xcodeproj/project.pbxproj:
     16        * dom/Document.cpp: Use monotonic times.
     17        (WebCore::Document::setReadyState):
     18        (WebCore::Document::finishedParsing):
     19        * inspector/InspectorInstrumentation.cpp:
     20        (WebCore::InspectorInstrumentation::didFinishLoadingImpl): Convert monotonicFinishTime to wall time if needed.
     21        * inspector/InspectorResourceAgent.cpp:
     22        (WebCore::buildObjectForTiming): Convert monotonic requestTime to wall time.
     23        (WebCore::buildObjectForResourceResponse): Plumbing for above.
     24        (WebCore::buildObjectForCachedResource): Ditto.
     25        (WebCore::InspectorResourceAgent::willSendRequest): Ditto.
     26        (WebCore::InspectorResourceAgent::didReceiveResponse): Ditto.
     27        (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache): Ditto.
     28        * loader/DocumentLoadTiming.cpp: Added.
     29        (WebCore::DocumentLoadTiming::DocumentLoadTiming):
     30        (WebCore::DocumentLoadTiming::setNavigationStart): Determine reference time and root reference time.
     31        (WebCore::DocumentLoadTiming::addRedirect): Moved logic from MainResourceLoader.
     32        (WebCore::DocumentLoadTiming::convertMonotonicTimeToDocumentTime): Helper to compute wall time from monotonic time.
     33        * loader/DocumentLoadTiming.h: Turned into class. Made times monotonic.
     34        (WebCore::DocumentLoadTiming::setUnloadEventStart):
     35        (WebCore::DocumentLoadTiming::setUnloadEventEnd):
     36        (WebCore::DocumentLoadTiming::setRedirectStart):
     37        (WebCore::DocumentLoadTiming::setRedirectEnd):
     38        (WebCore::DocumentLoadTiming::setFetchStart):
     39        (WebCore::DocumentLoadTiming::setResponseEnd):
     40        (WebCore::DocumentLoadTiming::setLoadEventStart):
     41        (WebCore::DocumentLoadTiming::setLoadEventEnd):
     42        (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument):
     43        (WebCore::DocumentLoadTiming::navigationStart):
     44        (WebCore::DocumentLoadTiming::unloadEventStart):
     45        (WebCore::DocumentLoadTiming::unloadEventEnd):
     46        (WebCore::DocumentLoadTiming::redirectStart):
     47        (WebCore::DocumentLoadTiming::redirectEnd):
     48        (WebCore::DocumentLoadTiming::redirectCount):
     49        (WebCore::DocumentLoadTiming::fetchStart):
     50        (WebCore::DocumentLoadTiming::responseEnd):
     51        (WebCore::DocumentLoadTiming::loadEventStart):
     52        (WebCore::DocumentLoadTiming::loadEventEnd):
     53        (WebCore::DocumentLoadTiming::hasCrossOriginRedirect):
     54        (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument):
     55        * loader/FrameLoader.cpp:
     56        (WebCore::FrameLoader::stopLoading):
     57        (WebCore::FrameLoader::commitProvisionalLoad):
     58        (WebCore::FrameLoader::continueLoadAfterWillSubmitForm):
     59        (WebCore::FrameLoader::loadProvisionalItemFromCachedPage):
     60        * loader/MainResourceLoader.cpp:
     61        (WebCore::MainResourceLoader::continueAfterNavigationPolicy):
     62        (WebCore::MainResourceLoader::willSendRequest): Moved logic to DocumentLoadTiming.
     63        (WebCore::MainResourceLoader::didReceiveData): Use monotonic time.
     64        (WebCore::MainResourceLoader::didFinishLoading): Ditto.
     65        (WebCore::MainResourceLoader::load):
     66        * page/DOMWindow.cpp:
     67        (WebCore::DOMWindow::dispatchLoadEvent):
     68        * page/DOMWindow.h: Removed dispatchTimedEvent. It doesn't really help in the new model.
     69        * page/PerformanceNavigation.cpp:
     70        (WebCore::PerformanceNavigation::redirectCount):
     71        * page/PerformanceTiming.cpp: Removed skew correction code. This should never happen now.
     72        (WebCore::PerformanceTiming::navigationStart):
     73        (WebCore::PerformanceTiming::unloadEventStart):
     74        (WebCore::PerformanceTiming::unloadEventEnd):
     75        (WebCore::PerformanceTiming::redirectStart):
     76        (WebCore::PerformanceTiming::redirectEnd):
     77        (WebCore::PerformanceTiming::fetchStart):
     78        (WebCore::PerformanceTiming::responseEnd):
     79        (WebCore::PerformanceTiming::domLoading):
     80        (WebCore::PerformanceTiming::domInteractive):
     81        (WebCore::PerformanceTiming::domContentLoadedEventStart):
     82        (WebCore::PerformanceTiming::domContentLoadedEventEnd):
     83        (WebCore::PerformanceTiming::domComplete):
     84        (WebCore::PerformanceTiming::loadEventStart):
     85        (WebCore::PerformanceTiming::loadEventEnd):
     86        (WebCore::PerformanceTiming::resourceLoadTimeRelativeToAbsolute): Used for ResourceLoadTiming.
     87        (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds): Used for DocumentTiming and DocumentLoadTiming.
     88        * page/PerformanceTiming.h:
     89        * platform/network/ResourceLoadTiming.cpp:
     90        (WebCore::ResourceLoadTiming::convertResourceLoadTimeToDocumentTime):
     91        * platform/network/ResourceLoadTiming.h: Added helper function to convert to wall times. Added instructions for use.
     92
    1932011-12-15  Martin Robinson  <mrobinson@igalia.com>
    294
  • trunk/Source/WebCore/GNUmakefile.list.am

    r102942 r102961  
    21882188        Source/WebCore/loader/TextTrackLoader.cpp \
    21892189        Source/WebCore/loader/TextTrackLoader.h \
     2190        Source/WebCore/loader/DocumentLoadTiming.cpp \
     2191        Source/WebCore/loader/DocumentLoadTiming.h \
    21902192        Source/WebCore/loader/DocumentLoader.cpp \
    21912193        Source/WebCore/loader/DocumentLoader.h \
    2192         Source/WebCore/loader/DocumentLoadTiming.h \
    21932194        Source/WebCore/loader/DocumentThreadableLoader.cpp \
    21942195        Source/WebCore/loader/DocumentThreadableLoader.h \
     
    28462847        Source/WebCore/platform/network/ResourceLoadInfo.h \
    28472848        Source/WebCore/platform/network/ResourceLoadPriority.h \
     2849        Source/WebCore/platform/network/ResourceLoadTiming.cpp \
    28482850        Source/WebCore/platform/network/ResourceLoadTiming.h \
    28492851        Source/WebCore/platform/network/ResourceRequestBase.cpp \
  • trunk/Source/WebCore/Target.pri

    r102946 r102961  
    917917    loader/CrossOriginPreflightResultCache.cpp \
    918918    loader/cache/CachedResourceLoader.cpp \
     919    loader/DocumentLoadTiming.cpp \
    919920    loader/DocumentLoader.cpp \
    920921    loader/DocumentThreadableLoader.cpp \
     
    11131114    platform/network/ResourceErrorBase.cpp \
    11141115    platform/network/ResourceHandle.cpp \
     1116    platform/network/ResourceLoadTiming.cpp \
    11151117    platform/network/ResourceRequestBase.cpp \
    11161118    platform/network/ResourceResponseBase.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r102942 r102961  
    28212821            'loader/CrossOriginAccessControl.h',
    28222822            'loader/CrossOriginPreflightResultCache.cpp',
     2823            'loader/DocumentLoadTiming.cpp',
    28232824            'loader/DocumentLoader.cpp',
    28242825            'loader/DocumentThreadableLoader.cpp',
     
    42104211            'platform/network/ResourceHandle.cpp',
    42114212            'platform/network/ResourceHandleInternal.h',
     4213            'platform/network/ResourceLoadTiming.cpp',
    42124214            'platform/network/ResourceRequestBase.cpp',
    42134215            'platform/network/ResourceResponseBase.cpp',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r102942 r102961  
    2574725747                        </File>
    2574825748                        <File
     25749                                RelativePath="..\loader\DocumentLoadTiming.cpp"
     25750                                >
     25751                        </File>
     25752                        <File
     25753                                RelativePath="..\loader\DocumentLoadTiming.h"
     25754                                >
     25755                        </File>
     25756                        <File
    2574925757                                RelativePath="..\loader\DocumentLoader.cpp"
    2575025758                                >
     
    2575225760                        <File
    2575325761                                RelativePath="..\loader\DocumentLoader.h"
    25754                                 >
    25755                         </File>
    25756                         <File
    25757                                 RelativePath="..\loader\DocumentLoadTiming.h"
    2575825762                                >
    2575925763                        </File>
     
    3022230226                                </File>
    3022330227                                <File
     30228                                        RelativePath="..\platform\network\ResourceLoadTiming.cpp"
     30229                                        >
     30230                                </File>
     30231                                <File
    3022430232                                        RelativePath="..\platform\network\ResourceLoadTiming.h"
    3022530233                                        >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r102942 r102961  
    28182818                85FF315A0AAFBFCB00374F38 /* DOMKeyboardEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */; };
    28192819                85FF315B0AAFBFCB00374F38 /* DOMKeyboardEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */; };
     2820                861C2EA413FB4FDD00062ABB /* DocumentLoadTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 861C2EA313FB4FDD00062ABB /* DocumentLoadTiming.cpp */; };
     2821                861C2EA613FB4FFF00062ABB /* ResourceLoadTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 861C2EA513FB4FFF00062ABB /* ResourceLoadTiming.cpp */; };
    28202822                86243D0111BC31F700CC006A /* JSArrayBufferViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */; };
    28212823                86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 86D982F6125C154000AD9E3D /* DocumentTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1004510047                85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMKeyboardEvent.h; sourceTree = "<group>"; };
    1004610048                85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMKeyboardEvent.mm; sourceTree = "<group>"; };
     10049                861C2EA313FB4FDD00062ABB /* DocumentLoadTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoadTiming.cpp; sourceTree = "<group>"; };
     10050                861C2EA513FB4FFF00062ABB /* ResourceLoadTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadTiming.cpp; sourceTree = "<group>"; };
    1004710051                86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferViewHelper.h; sourceTree = "<group>"; };
    1004810052                86D982F6125C154000AD9E3D /* DocumentTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentTiming.h; sourceTree = "<group>"; };
     
    1547915483                                492863981253B8FC00F792D6 /* ResourceLoadInfo.h */,
    1548015484                                E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */,
     15485                                861C2EA513FB4FFF00062ABB /* ResourceLoadTiming.cpp */,
    1548115486                                8A81BF8411DCFD9000DA2B98 /* ResourceLoadTiming.h */,
    1548215487                                514C76670CE923A1007EF3CD /* ResourceRequestBase.cpp */,
     
    2003120036                                E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */,
    2003220037                                E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */,
     20038                                861C2EA313FB4FDD00062ABB /* DocumentLoadTiming.cpp */,
     20039                                8A12E35C11FA33280025836A /* DocumentLoadTiming.h */,
    2003320040                                93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */,
    2003420041                                656D371E0ADBA5DE00A4554D /* DocumentLoader.h */,
    20035                                 8A12E35C11FA33280025836A /* DocumentLoadTiming.h */,
    2003620042                                0B9056150F2578BE0095FF6A /* DocumentThreadableLoader.cpp */,
    2003720043                                0B9056160F2578BE0095FF6A /* DocumentThreadableLoader.h */,
     
    2214522151                                A8185F4009765766005826D9 /* Document.h in Headers */,
    2214622152                                A8185F3D09765766005826D9 /* DocumentFragment.h in Headers */,
     22153                                8A12E35D11FA33280025836A /* DocumentLoadTiming.h in Headers */,
    2214722154                                656D37360ADBA5DE00A4554D /* DocumentLoader.h in Headers */,
    22148                                 8A12E35D11FA33280025836A /* DocumentLoadTiming.h in Headers */,
    2214922155                                ED2BA83C09A24B91006C0AC4 /* DocumentMarker.h in Headers */,
    2215022156                                CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */,
     
    2549025496                                A8185F3C09765766005826D9 /* Document.cpp in Sources */,
    2549125497                                A8185F3F09765766005826D9 /* DocumentFragment.cpp in Sources */,
     25498                                861C2EA413FB4FDD00062ABB /* DocumentLoadTiming.cpp in Sources */,
    2549225499                                93E227E00AF589AD00D48324 /* DocumentLoader.cpp in Sources */,
    2549325500                                1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */,
     
    2711127118                                973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */,
    2711227119                                D0CE58F8125E4CC200F3F199 /* ResourceLoadScheduler.cpp in Sources */,
     27120                                861C2EA613FB4FFF00062ABB /* ResourceLoadTiming.cpp in Sources */,
    2711327121                                514C767C0CE923A1007EF3CD /* ResourceRequestBase.cpp in Sources */,
    2711427122                                7EE6846E12D26E3800E79415 /* ResourceRequestCFNet.cpp in Sources */,
  • trunk/Source/WebCore/dom/Document.cpp

    r102908 r102961  
    10481048    case Loading:
    10491049        if (!m_documentTiming.domLoading)
    1050             m_documentTiming.domLoading = currentTime();
     1050            m_documentTiming.domLoading = monotonicallyIncreasingTime();
    10511051        break;
    10521052    case Interactive:
    10531053        if (!m_documentTiming.domInteractive)
    1054             m_documentTiming.domInteractive = currentTime();
     1054            m_documentTiming.domInteractive = monotonicallyIncreasingTime();
    10551055        break;
    10561056    case Complete:
    10571057        if (!m_documentTiming.domComplete)
    1058             m_documentTiming.domComplete = currentTime();
     1058            m_documentTiming.domComplete = monotonicallyIncreasingTime();
    10591059        break;
    10601060    }
     
    42714271    setParsing(false);
    42724272    if (!m_documentTiming.domContentLoadedEventStart)
    4273         m_documentTiming.domContentLoadedEventStart = currentTime();
     4273        m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTime();
    42744274    dispatchEvent(Event::create(eventNames().DOMContentLoadedEvent, true, false));
    42754275    if (!m_documentTiming.domContentLoadedEventEnd)
    4276         m_documentTiming.domContentLoadedEventEnd = currentTime();
     4276        m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime();
    42774277
    42784278    if (RefPtr<Frame> f = frame()) {
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r102908 r102961  
    542542}
    543543
    544 void InspectorInstrumentation::didFinishLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, double finishTime)
    545 {
    546     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
     544void InspectorInstrumentation::didFinishLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, double monotonicFinishTime)
     545{
     546    InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
     547    InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent();
     548    if (!timelineAgent && !resourceAgent)
     549        return;
     550
     551    double finishTime = 0.0;
     552    // FIXME: Expose all of the timing details to inspector and have it calculate finishTime.
     553    if (monotonicFinishTime)
     554        finishTime = loader->timing()->convertMonotonicTimeToDocumentTime(monotonicFinishTime);
     555
     556    if (timelineAgent)
    547557        timelineAgent->didFinishLoadingResource(identifier, false, finishTime);
    548     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
     558    if (resourceAgent)
    549559        resourceAgent->didFinishLoading(identifier, loader, finishTime);
    550560}
  • trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp

    r102908 r102961  
    104104}
    105105
    106 static PassRefPtr<InspectorObject> buildObjectForTiming(const ResourceLoadTiming& timing)
     106static PassRefPtr<InspectorObject> buildObjectForTiming(const ResourceLoadTiming& timing, DocumentLoader* loader)
    107107{
    108108    RefPtr<InspectorObject> timingObject = InspectorObject::create();
    109     timingObject->setNumber("requestTime", timing.requestTime);
     109    timingObject->setNumber("requestTime", timing.convertResourceLoadTimeToDocumentTime(loader->timing(), 0));
    110110    timingObject->setNumber("proxyStart", timing.proxyStart);
    111111    timingObject->setNumber("proxyEnd", timing.proxyEnd);
     
    133133}
    134134
    135 static PassRefPtr<InspectorObject> buildObjectForResourceResponse(const ResourceResponse& response)
     135static PassRefPtr<InspectorObject> buildObjectForResourceResponse(const ResourceResponse& response, DocumentLoader* loader)
    136136{
    137137    if (response.isNull())
     
    153153    responseObject->setBoolean("fromDiskCache", response.wasCached());
    154154    if (response.resourceLoadTiming())
    155         responseObject->setObject("timing", buildObjectForTiming(*response.resourceLoadTiming()));
     155        responseObject->setObject("timing", buildObjectForTiming(*response.resourceLoadTiming(), loader));
    156156
    157157    if (response.resourceLoadInfo()) {
     
    169169}
    170170
    171 static PassRefPtr<InspectorObject> buildObjectForCachedResource(const CachedResource& cachedResource)
     171static PassRefPtr<InspectorObject> buildObjectForCachedResource(const CachedResource& cachedResource, DocumentLoader* loader)
    172172{
    173173    RefPtr<InspectorObject> resourceObject = InspectorObject::create();
     
    175175    resourceObject->setString("type", InspectorPageAgent::cachedResourceTypeString(cachedResource));
    176176    resourceObject->setNumber("bodySize", cachedResource.encodedSize());
    177     RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(cachedResource.response());
     177    RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(cachedResource.response(), loader);
    178178    if (resourceResponse)
    179179        resourceObject->setObject("response", resourceResponse);
     
    222222        callStackValue = InspectorArray::create();
    223223    RefPtr<InspectorObject> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0);
    224     m_frontend->requestWillBeSent(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), initiatorObject, callStackValue, buildObjectForResourceResponse(redirectResponse));
     224    m_frontend->requestWillBeSent(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), initiatorObject, callStackValue, buildObjectForResourceResponse(redirectResponse, loader));
    225225}
    226226
     
    233233{
    234234    String requestId = IdentifiersFactory::requestId(identifier);
    235     RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(response);
     235    RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(response, loader);
    236236    InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource;
    237237    long cachedResourceSize = 0;
     
    314314    RefPtr<InspectorObject> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0);
    315315
    316     m_frontend->requestServedFromMemoryCache(requestId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource(*resource));
     316    m_frontend->requestServedFromMemoryCache(requestId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource(*resource, loader));
    317317}
    318318
  • trunk/Source/WebCore/loader/DocumentLoadTiming.h

    r102908 r102961  
    2727#define DocumentLoadTiming_h
    2828
     29#include <wtf/CurrentTime.h>
     30
    2931namespace WebCore {
    3032
    31 struct DocumentLoadTiming {
    32     DocumentLoadTiming()
    33         : navigationStart(0.0)
    34         , unloadEventStart(0.0)
    35         , unloadEventEnd(0.0)
    36         , redirectStart(0.0)
    37         , redirectEnd(0.0)
    38         , redirectCount(0)
    39         , fetchStart(0.0)
    40         , responseEnd(0.0)
    41         , loadEventStart(0.0)
    42         , loadEventEnd(0.0)
    43         , hasCrossOriginRedirect(false)
    44         , hasSameOriginAsPreviousDocument(false)
    45     {
    46     }
     33class Frame;
     34class KURL;
    4735
    48     double navigationStart;
    49     double unloadEventStart;
    50     double unloadEventEnd;
    51     double redirectStart;
    52     double redirectEnd;
    53     short redirectCount;
    54     double fetchStart;
    55     double responseEnd;
    56     double loadEventStart;
    57     double loadEventEnd;
    58     bool hasCrossOriginRedirect;
    59     bool hasSameOriginAsPreviousDocument;
     36class DocumentLoadTiming {
     37public:
     38    DocumentLoadTiming();
     39
     40    void markNavigationStart(Frame*);
     41    void addRedirect(const KURL& redirectingUrl, const KURL& redirectedUrl);
     42    double convertMonotonicTimeToDocumentTime(double monotonicTime) const;
     43
     44    void markUnloadEventStart() { m_unloadEventStart = monotonicallyIncreasingTime(); }
     45    void markUnloadEventEnd() { m_unloadEventEnd = monotonicallyIncreasingTime(); }
     46    void markRedirectStart() { m_redirectStart = monotonicallyIncreasingTime(); }
     47    void markRedirectEnd() { m_redirectEnd = monotonicallyIncreasingTime(); }
     48    void markFetchStart() { m_fetchStart = monotonicallyIncreasingTime(); }
     49    void setResponseEnd(double monotonicTime) { m_responseEnd = monotonicTime; }
     50    void markLoadEventStart() { m_loadEventStart = monotonicallyIncreasingTime(); }
     51    void markLoadEventEnd() { m_loadEventEnd = monotonicallyIncreasingTime(); }
     52
     53    void setHasSameOriginAsPreviousDocument(bool value) { m_hasSameOriginAsPreviousDocument = value; }
     54
     55    double navigationStart() const { return convertMonotonicTimeToDocumentTime(m_navigationStart); }
     56    double unloadEventStart() const { return convertMonotonicTimeToDocumentTime(m_unloadEventStart); }
     57    double unloadEventEnd() const { return convertMonotonicTimeToDocumentTime(m_unloadEventEnd); }
     58    double redirectStart() const { return convertMonotonicTimeToDocumentTime(m_redirectStart); }
     59    double redirectEnd() const { return convertMonotonicTimeToDocumentTime(m_redirectEnd); }
     60    short redirectCount() const { return m_redirectCount; }
     61    double fetchStart() const { return convertMonotonicTimeToDocumentTime(m_fetchStart); }
     62    double responseEnd() const { return convertMonotonicTimeToDocumentTime(m_responseEnd); }
     63    double loadEventStart() const { return convertMonotonicTimeToDocumentTime(m_loadEventStart); }
     64    double loadEventEnd() const { return convertMonotonicTimeToDocumentTime(m_loadEventEnd); }
     65    bool hasCrossOriginRedirect() const { return m_hasCrossOriginRedirect; }
     66    bool hasSameOriginAsPreviousDocument() const { return m_hasSameOriginAsPreviousDocument; }
     67
     68private:
     69    double m_referenceMonotonicTime;
     70    double m_referenceWallTime;
     71    double m_navigationStart;
     72    double m_unloadEventStart;
     73    double m_unloadEventEnd;
     74    double m_redirectStart;
     75    double m_redirectEnd;
     76    short m_redirectCount;
     77    double m_fetchStart;
     78    double m_responseEnd;
     79    double m_loadEventStart;
     80    double m_loadEventEnd;
     81    bool m_hasCrossOriginRedirect;
     82    bool m_hasSameOriginAsPreviousDocument;
    6083};
    6184
    62 }
     85} // namespace WebCore
    6386
    6487#endif
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r102908 r102961  
    377377                        RefPtr<DocumentLoader> documentLoader = m_provisionalDocumentLoader;
    378378                        m_pageDismissalEventBeingDispatched = UnloadDismissal;
    379                         if (documentLoader && !documentLoader->timing()->unloadEventStart && !documentLoader->timing()->unloadEventEnd) {
     379                        if (documentLoader && !documentLoader->timing()->unloadEventStart() && !documentLoader->timing()->unloadEventEnd()) {
    380380                            DocumentLoadTiming* timing = documentLoader->timing();
    381                             ASSERT(timing->navigationStart);
    382                             m_frame->domWindow()->dispatchTimedEvent(unloadEvent, m_frame->domWindow()->document(), &timing->unloadEventStart, &timing->unloadEventEnd);
     381                            ASSERT(timing->navigationStart());
     382                            timing->markUnloadEventStart();
     383                            m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->domWindow()->document());
     384                            timing->markUnloadEventEnd();
    383385                        } else
    384386                            m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->domWindow()->document());
     
    17721774        // Check if the destination page is allowed to access the previous page's timing information.
    17731775        RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->request().url());
    1774         m_documentLoader->timing()->hasSameOriginAsPreviousDocument = securityOrigin->canRequest(m_previousUrl);
     1776        m_documentLoader->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canRequest(m_previousUrl));
    17751777    }
    17761778
     
    23282330    }
    23292331
    2330     ASSERT(!m_provisionalDocumentLoader->timing()->navigationStart);
    2331     m_provisionalDocumentLoader->timing()->navigationStart = currentTime();
     2332    m_provisionalDocumentLoader->timing()->markNavigationStart(frame());
    23322333
    23332334    if (!m_provisionalDocumentLoader->startLoadingMainResource(identifier))
     
    30293030
    30303031    m_loadingFromCachedPage = true;
    3031    
     3032
    30323033    // Should have timing data from previous time(s) the page was shown.
    3033     ASSERT(provisionalLoader->timing()->navigationStart);
     3034    ASSERT(provisionalLoader->timing()->navigationStart());
    30343035    provisionalLoader->resetTiming();
    3035     provisionalLoader->timing()->navigationStart = currentTime();   
     3036    provisionalLoader->timing()->markNavigationStart(frame());
    30363037
    30373038    provisionalLoader->setCommitted(true);
  • trunk/Source/WebCore/loader/MainResourceLoader.cpp

    r102908 r102961  
    144144    else if (m_substituteData.isValid()) {
    145145        // A redirect resulted in loading substitute data.
    146         ASSERT(documentLoader()->timing()->redirectCount);
     146        ASSERT(documentLoader()->timing()->redirectCount());
    147147        handle()->cancel();
    148148        handleDataLoadSoon(request);
     
    183183    RefPtr<MainResourceLoader> protect(this);
    184184
    185     ASSERT(documentLoader()->timing()->fetchStart);
     185    ASSERT(documentLoader()->timing()->fetchStart());
    186186    if (!redirectResponse.isNull()) {
    187187        // If the redirecting url is not allowed to display content from the target origin,
     
    193193            return;
    194194        }
    195 
    196         DocumentLoadTiming* documentLoadTiming = documentLoader()->timing();
    197 
    198         // Check if the redirected url is allowed to access the redirecting url's timing information.
    199         RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(newRequest.url());
    200         if (!securityOrigin->canRequest(redirectResponse.url()))
    201             documentLoadTiming->hasCrossOriginRedirect = true;
    202 
    203         documentLoadTiming->redirectCount++;
    204         if (!documentLoadTiming->redirectStart)
    205             documentLoadTiming->redirectStart = documentLoadTiming->fetchStart;
    206         documentLoadTiming->redirectEnd = currentTime();
    207         documentLoadTiming->fetchStart = documentLoadTiming->redirectEnd;
     195        documentLoader()->timing()->addRedirect(redirectResponse.url(), newRequest.url());
    208196    }
    209197
     
    472460    RefPtr<MainResourceLoader> protect(this);
    473461
    474     m_timeOfLastDataReceived = currentTime();
     462    m_timeOfLastDataReceived = monotonicallyIncreasingTime();
    475463
    476464    ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);
     
    484472    ASSERT(shouldLoadAsEmptyDocument(frameLoader()->activeDocumentLoader()->url()) || !defersLoading());
    485473#endif
    486    
     474
    487475    // The additional processing can do anything including possibly removing the last
    488476    // reference to this object.
     
    493481        dl->maybeFinishLoadingMultipartContent();
    494482
    495     ASSERT(!documentLoader()->timing()->responseEnd);
    496     documentLoader()->timing()->responseEnd = finishTime ? finishTime : (m_timeOfLastDataReceived ? m_timeOfLastDataReceived : currentTime());
     483    documentLoader()->timing()->setResponseEnd(finishTime ? finishTime : (m_timeOfLastDataReceived ? m_timeOfLastDataReceived : monotonicallyIncreasingTime()));
    497484    frameLoader()->finishedLoading();
    498485    ResourceLoader::didFinishLoading(finishTime);
     
    604591    m_substituteData = substituteData;
    605592
    606     ASSERT(documentLoader()->timing()->navigationStart);
    607     ASSERT(!documentLoader()->timing()->fetchStart);
    608     documentLoader()->timing()->fetchStart = currentTime();
     593    ASSERT(documentLoader()->timing()->navigationStart());
     594    ASSERT(!documentLoader()->timing()->fetchStart());
     595    documentLoader()->timing()->markFetchStart();
    609596    ResourceRequest request(r);
    610597
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r102908 r102961  
    16361636{
    16371637    RefPtr<Event> loadEvent(Event::create(eventNames().loadEvent, false, false));
    1638     if (m_frame && m_frame->loader()->documentLoader() && !m_frame->loader()->documentLoader()->timing()->loadEventStart) {
     1638    if (m_frame && m_frame->loader()->documentLoader() && !m_frame->loader()->documentLoader()->timing()->loadEventStart()) {
    16391639        // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed while dispatching
    16401640        // the event, so protect it to prevent writing the end time into freed memory.
    16411641        RefPtr<DocumentLoader> documentLoader = m_frame->loader()->documentLoader();
    16421642        DocumentLoadTiming* timing = documentLoader->timing();
    1643         dispatchTimedEvent(loadEvent, document(), &timing->loadEventStart, &timing->loadEventEnd);
     1643        timing->markLoadEventStart();
     1644        dispatchEvent(loadEvent, document());
     1645        timing->markLoadEventEnd();
    16441646    } else
    16451647        dispatchEvent(loadEvent, document());
     
    16711673
    16721674    return result;
    1673 }
    1674 
    1675 void DOMWindow::dispatchTimedEvent(PassRefPtr<Event> event, Document* target, double* startTime, double* endTime)
    1676 {
    1677     ASSERT(startTime);
    1678     ASSERT(endTime);
    1679     *startTime = currentTime();
    1680     dispatchEvent(event, target);
    1681     *endTime = currentTime();
    16821675}
    16831676
  • trunk/Source/WebCore/page/DOMWindow.h

    r102908 r102961  
    268268        bool dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget> prpTarget);
    269269        void dispatchLoadEvent();
    270         void dispatchTimedEvent(PassRefPtr<Event> event, Document* target, double* startTime, double* endTime);
    271270
    272271        DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
  • trunk/Source/WebCore/page/PerformanceNavigation.cpp

    r102908 r102961  
    8585
    8686    DocumentLoadTiming* timing = loader->timing();
    87     if (timing->hasCrossOriginRedirect)
     87    if (timing->hasCrossOriginRedirect())
    8888        return 0;
    8989
    90     return timing->redirectCount;
     90    return timing->redirectCount();
    9191}
    9292
  • trunk/Source/WebCore/page/PerformanceTiming.cpp

    r102908 r102961  
    5151}
    5252
    53 static double getPossiblySkewedTimeInKnownRange(double skewedTime, double lowerBound, double upperBound)
    54 {
    55 #if PLATFORM(CHROMIUM)
    56     // The chromium port's currentTime() implementation only syncs with the
    57     // system clock every 60 seconds. So it is possible for timing marks
    58     // collected in different threads or processes to have a small skew.
    59     // FIXME: It may be possible to add a currentTimeFromSystemTime() method
    60     // that eliminates the skew.
    61     if (skewedTime <= lowerBound)
    62         return lowerBound;
    63 
    64     if (upperBound <= 0.0)
    65         upperBound = currentTime();
    66 
    67     if (skewedTime >= upperBound)
    68         return upperBound;
    69 #else
    70     ASSERT_UNUSED(lowerBound, skewedTime >= lowerBound);
    71     ASSERT_UNUSED(upperBound, skewedTime <= upperBound);
    72 #endif
    73 
    74     return skewedTime;
    75 }
    76 
    7753PerformanceTiming::PerformanceTiming(Frame* frame)
    7854    : m_frame(frame)
     
    9672        return 0;
    9773
    98     return toIntegerMilliseconds(timing->navigationStart);
     74    return toIntegerMilliseconds(timing->navigationStart());
    9975}
    10076
     
    10581        return 0;
    10682
    107     if (timing->hasCrossOriginRedirect || !timing->hasSameOriginAsPreviousDocument)
    108         return 0;
    109 
    110     return toIntegerMilliseconds(timing->unloadEventStart);
     83    if (timing->hasCrossOriginRedirect() || !timing->hasSameOriginAsPreviousDocument())
     84        return 0;
     85
     86    return toIntegerMilliseconds(timing->unloadEventStart());
    11187}
    11288
     
    11793        return 0;
    11894
    119     if (timing->hasCrossOriginRedirect || !timing->hasSameOriginAsPreviousDocument)
    120         return 0;
    121 
    122     return toIntegerMilliseconds(timing->unloadEventEnd);
     95    if (timing->hasCrossOriginRedirect() || !timing->hasSameOriginAsPreviousDocument())
     96        return 0;
     97
     98    return toIntegerMilliseconds(timing->unloadEventEnd());
    12399}
    124100
     
    129105        return 0;
    130106
    131     if (timing->hasCrossOriginRedirect)
    132         return 0;
    133 
    134     return toIntegerMilliseconds(timing->redirectStart);
     107    if (timing->hasCrossOriginRedirect())
     108        return 0;
     109
     110    return toIntegerMilliseconds(timing->redirectStart());
    135111}
    136112
     
    141117        return 0;
    142118
    143     if (timing->hasCrossOriginRedirect)
    144         return 0;
    145 
    146     return toIntegerMilliseconds(timing->redirectEnd);
     119    if (timing->hasCrossOriginRedirect())
     120        return 0;
     121
     122    return toIntegerMilliseconds(timing->redirectEnd());
    147123}
    148124
     
    153129        return 0;
    154130
    155     return toIntegerMilliseconds(timing->fetchStart);
     131    return toIntegerMilliseconds(timing->fetchStart());
    156132}
    157133
     
    278254        return 0;
    279255
    280     return toIntegerMilliseconds(timing->responseEnd);
     256    return toIntegerMilliseconds(timing->responseEnd());
    281257}
    282258
     
    287263        return fetchStart();
    288264
    289     return toIntegerMilliseconds(timing->domLoading);
     265    return monotonicTimeToIntegerMilliseconds(timing->domLoading);
    290266}
    291267
     
    296272        return 0;
    297273
    298     return toIntegerMilliseconds(timing->domInteractive);
     274    return monotonicTimeToIntegerMilliseconds(timing->domInteractive);
    299275}
    300276
     
    305281        return 0;
    306282
    307     return toIntegerMilliseconds(timing->domContentLoadedEventStart);
     283    return monotonicTimeToIntegerMilliseconds(timing->domContentLoadedEventStart);
    308284}
    309285
     
    314290        return 0;
    315291
    316     return toIntegerMilliseconds(timing->domContentLoadedEventEnd);
     292    return monotonicTimeToIntegerMilliseconds(timing->domContentLoadedEventEnd);
    317293}
    318294
     
    323299        return 0;
    324300
    325     return toIntegerMilliseconds(timing->domComplete);
     301    return monotonicTimeToIntegerMilliseconds(timing->domComplete);
    326302}
    327303
     
    332308        return 0;
    333309
    334     return toIntegerMilliseconds(timing->loadEventStart);
     310    return toIntegerMilliseconds(timing->loadEventStart());
    335311}
    336312
     
    341317        return 0;
    342318
    343     return toIntegerMilliseconds(timing->loadEventEnd);
     319    return toIntegerMilliseconds(timing->loadEventEnd());
    344320}
    345321
     
    382358}
    383359
    384 unsigned long long PerformanceTiming::resourceLoadTimeRelativeToAbsolute(int relativeSeconds) const
    385 {
    386     ASSERT(relativeSeconds >= 0);
     360unsigned long long PerformanceTiming::resourceLoadTimeRelativeToAbsolute(int relativeMilliseconds) const
     361{
     362    ASSERT(relativeMilliseconds >= 0);
    387363    ResourceLoadTiming* resourceTiming = resourceLoadTiming();
    388364    ASSERT(resourceTiming);
    389     DocumentLoadTiming* documentTiming = documentLoadTiming();
    390     ASSERT(documentTiming);
    391 
    392     // The ResourceLoadTiming API's requestTime is the base time to which all
    393     // other marks are relative. So to get an absolute time, we must add it to
    394     // the relative marks.
    395     //
    396     // Since ResourceLoadTimings came from the network platform layer, we must
    397     // check them for skew because they may be from another thread/process.
    398     double baseTime = getPossiblySkewedTimeInKnownRange(resourceTiming->requestTime, documentTiming->fetchStart, documentTiming->responseEnd);
    399     return toIntegerMilliseconds(baseTime) + relativeSeconds;
     365    return toIntegerMilliseconds(resourceTiming->convertResourceLoadTimeToDocumentTime(documentLoadTiming(), relativeMilliseconds));
     366}
     367
     368unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double monotonicSeconds) const
     369{
     370    ASSERT(monotonicSeconds >= 0);
     371    const DocumentLoadTiming* timing = documentLoadTiming();
     372    ASSERT(timing);
     373    return toIntegerMilliseconds(timing->convertMonotonicTimeToDocumentTime(monotonicSeconds));
    400374}
    401375
  • trunk/Source/WebCore/page/PerformanceTiming.h

    r102911 r102961  
    3939namespace WebCore {
    4040
    41 struct DocumentLoadTiming;
     41class DocumentLoadTiming;
    4242class DocumentLoader;
    4343struct DocumentTiming;
     
    8282    ResourceLoadTiming* resourceLoadTiming() const;
    8383    unsigned long long resourceLoadTimeRelativeToAbsolute(int) const;
     84    unsigned long long monotonicTimeToIntegerMilliseconds(double) const;
    8485
    8586    Frame* m_frame;
  • trunk/Source/WebCore/platform/network/ResourceLoadTiming.cpp

    r102958 r102961  
    11/*
    2  * Copyright (C) 2010 Google, Inc. All Rights Reserved.
     2 * Copyright (C) 2011 Google, Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    1111 *    documentation and/or other materials provided with the distribution.
    1212 *
    13  * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
     13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
    1414 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1515 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GOOGLE INC. OR
     16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
    1717 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    1818 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
    26 #ifndef DocumentLoadTiming_h
    27 #define DocumentLoadTiming_h
     26#include "config.h"
     27#include "ResourceLoadTiming.h"
     28
     29#include "DocumentLoadTiming.h"
    2830
    2931namespace WebCore {
    3032
    31 struct DocumentLoadTiming {
    32     DocumentLoadTiming()
    33         : navigationStart(0.0)
    34         , unloadEventStart(0.0)
    35         , unloadEventEnd(0.0)
    36         , redirectStart(0.0)
    37         , redirectEnd(0.0)
    38         , redirectCount(0)
    39         , fetchStart(0.0)
    40         , responseEnd(0.0)
    41         , loadEventStart(0.0)
    42         , loadEventEnd(0.0)
    43         , hasCrossOriginRedirect(false)
    44         , hasSameOriginAsPreviousDocument(false)
    45     {
    46     }
     33double ResourceLoadTiming::convertResourceLoadTimeToDocumentTime(const DocumentLoadTiming* documentTiming, int deltaMilliseconds) const
     34{
     35    if (!documentTiming)
     36        return 0.0;
    4737
    48     double navigationStart;
    49     double unloadEventStart;
    50     double unloadEventEnd;
    51     double redirectStart;
    52     double redirectEnd;
    53     short redirectCount;
    54     double fetchStart;
    55     double responseEnd;
    56     double loadEventStart;
    57     double loadEventEnd;
    58     bool hasCrossOriginRedirect;
    59     bool hasSameOriginAsPreviousDocument;
    60 };
     38    return documentTiming->convertMonotonicTimeToDocumentTime(requestTime + deltaMilliseconds / 1000.0);
     39}
    6140
    6241}
    63 
    64 #endif
  • trunk/Source/WebCore/platform/network/ResourceLoadTiming.h

    r102908 r102961  
    3232
    3333namespace WebCore {
     34
     35class DocumentLoadTiming;
    3436
    3537class ResourceLoadTiming : public RefCounted<ResourceLoadTiming> {
     
    7981    }
    8082
    81     double requestTime;
    82     int proxyStart;
     83    // We want to present a unified timeline to Javascript. Using walltime is problematic, because the clock may skew while resources
     84    // load. To prevent that skew, we record a single reference walltime when root document navigation begins. All other times are
     85    // recorded using monotonicallyIncreasingTime(). When a time needs to be presented to Javascript, we build a pseudo-walltime
     86    // using the following equation:
     87    //   pseudo time = document wall reference + (resource request time - document monotonic reference) + deltaMilliseconds / 1000.0.
     88    double convertResourceLoadTimeToDocumentTime(const DocumentLoadTiming* documentTiming, int deltaMilliseconds) const;
     89
     90    double requestTime; // monotonicallyIncreasingTime() when the port started handling this request.
     91    int proxyStart; // The rest of these are millisecond deltas, using monotonicallyIncreasingTime(), from requestTime.
    8392    int proxyEnd;
    8493    int dnsStart;
Note: See TracChangeset for help on using the changeset viewer.