Changeset 63689 in webkit
- Timestamp:
- Jul 19, 2010 2:55:13 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r63686 r63689 1 2010-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 1 20 2010-07-19 Eric Carlson <eric.carlson@apple.com> 2 21 -
trunk/LayoutTests/fast/dom/webtiming-expected.txt
r63559 r63689 14 14 PASS timing.connectStart is >= timing.domainLookupEnd 15 15 PASS timing.connectEnd is >= timing.connectStart 16 FAIL timing.requestStart should be >= timing.connectEnd. Was 0 (of type number). 16 PASS timing.requestStart is >= timing.connectEnd 17 17 PASS timing.requestEnd is >= timing.requestStart 18 18 PASS timing.responseStart is >= timing.requestEnd … … 29 29 PASS timing.connectStart is >= timing.domainLookupEnd 30 30 PASS timing.connectEnd is >= timing.connectStart 31 FAIL timing.requestStart should be >= timing.connectEnd. Was 0 (of type number). 31 PASS timing.requestStart is >= timing.connectEnd 32 32 PASS timing.requestEnd is >= timing.requestStart 33 33 PASS timing.responseStart is >= timing.requestEnd … … 45 45 PASS timing.connectStart is >= timing.domainLookupEnd 46 46 PASS timing.connectEnd is >= timing.connectStart 47 FAIL timing.requestStart should be >= timing.connectEnd. Was 0 (of type number). 47 PASS timing.requestStart is >= timing.connectEnd 48 48 PASS timing.requestEnd is >= timing.requestStart 49 49 PASS timing.responseStart is >= timing.requestEnd -
trunk/LayoutTests/platform/gtk/Skipped
r63616 r63689 5865 5865 fast/dom/navigation-type-reload.html 5866 5866 fast/dom/webtiming.html 5867 fast/dom/webtiming-navigate-within-document.html 5867 5868 http/tests/misc/webtiming-one-redirect.php 5868 5869 http/tests/misc/webtiming-two-redirects.php -
trunk/LayoutTests/platform/mac/Skipped
r63623 r63689 291 291 fast/dom/navigation-type-reload.html 292 292 fast/dom/webtiming.html 293 fast/dom/webtiming-navigate-within-document.html 293 294 http/tests/misc/webtiming-one-redirect.php 294 295 http/tests/misc/webtiming-two-redirects.php -
trunk/LayoutTests/platform/qt/Skipped
r63679 r63689 5450 5450 fast/dom/navigation-type-reload.html 5451 5451 fast/dom/webtiming.html 5452 fast/dom/webtiming-navigate-within-document.html 5452 5453 http/tests/misc/webtiming-one-redirect.php 5453 5454 http/tests/misc/webtiming-two-redirects.php -
trunk/LayoutTests/platform/win/Skipped
r63616 r63689 959 959 fast/dom/navigation-type-reload.html 960 960 fast/dom/webtiming.html 961 fast/dom/webtiming-navigate-within-document.html 961 962 http/tests/misc/webtiming-one-redirect.php 962 963 http/tests/misc/webtiming-two-redirects.php -
trunk/WebCore/ChangeLog
r63688 r63689 1 2010-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 1 50 2010-07-19 Chris Marrin <cmarrin@apple.com> 2 51 -
trunk/WebCore/loader/DocumentLoader.h
r60657 r63689 206 206 void takeMemoryCacheLoadsForClientNotification(Vector<String>& loads); 207 207 208 DocumentLoadTiming* timing() { return &m_documentLoadTiming; } 209 208 210 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 209 211 ApplicationCacheHost* applicationCacheHost() const { return m_applicationCacheHost.get(); } … … 295 297 bool m_didCreateGlobalHistoryEntry; 296 298 299 DocumentLoadTiming m_documentLoadTiming; 300 297 301 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 298 302 friend class ApplicationCacheHost; // for substitute resource delivery -
trunk/WebCore/loader/FrameLoader.cpp
r63620 r63689 450 450 if (!m_frame->document()->inPageCache()) 451 451 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 } 453 459 } 454 460 m_pageDismissalEventBeingDispatched = false; … … 1501 1507 return; 1502 1508 1503 m_frameLoadTimeline = FrameLoadTimeline();1504 m_frameLoadTimeline.navigationStart = currentTime();1505 1506 1509 policyChecker()->setLoadType(type); 1507 1510 RefPtr<FormState> formState = prpFormState; … … 2216 2219 RefPtr<Frame> protect(m_frame); 2217 2220 2218 ASSERT(!m_frameLoadTimeline.responseEnd);2219 m_frameLoadTimeline.responseEnd = currentTime();2220 2221 2221 RefPtr<DocumentLoader> dl = activeDocumentLoader(); 2222 ASSERT(!dl->timing()->responseEnd); 2223 dl->timing()->responseEnd = currentTime(); 2222 2224 dl->finishedLoading(); 2223 2225 if (!dl->mainDocumentError().isNull() || !dl->frameLoader()) … … 2509 2511 notifier()->assignIdentifierToInitialRequest(identifier, m_provisionalDocumentLoader.get(), m_provisionalDocumentLoader->originalRequest()); 2510 2512 } 2513 2514 ASSERT(!m_provisionalDocumentLoader->timing()->navigationStart); 2515 m_provisionalDocumentLoader->timing()->navigationStart = currentTime(); 2511 2516 2512 2517 if (!m_provisionalDocumentLoader->startLoadingMainResource(identifier)) -
trunk/WebCore/loader/FrameLoader.h
r62984 r63689 194 194 195 195 FrameLoadType loadType() const; 196 FrameLoadTimeline* frameLoadTimeline() { return &m_frameLoadTimeline; }197 196 198 197 CachePolicy subresourceCachePolicy() const; … … 447 446 FrameState m_state; 448 447 FrameLoadType m_loadType; 449 FrameLoadTimeline m_frameLoadTimeline;450 448 451 449 // Document loaders for the three phases of frame loading. Note that while -
trunk/WebCore/loader/FrameLoaderTypes.h
r63326 r63689 61 61 }; 62 62 63 // FIXME: Move t his to a new header file.64 struct FrameLoadTimeline{65 FrameLoadTimeline()63 // FIXME: Move to DocumentLoadTiming.h. 64 struct DocumentLoadTiming { 65 DocumentLoadTiming() 66 66 : navigationStart(0.0) 67 67 , unloadEventEnd(0.0) -
trunk/WebCore/loader/MainResourceLoader.cpp
r63332 r63689 160 160 RefPtr<MainResourceLoader> protect(this); 161 161 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 } 170 171 171 172 // Update cookie policy base URL as URL changes, except for subframes, which use the … … 543 544 m_substituteData = substituteData; 544 545 546 ASSERT(documentLoader()->timing()->navigationStart); 547 ASSERT(!documentLoader()->timing()->fetchStart); 548 documentLoader()->timing()->fetchStart = currentTime(); 545 549 ResourceRequest request(r); 546 550 -
trunk/WebCore/page/DOMWindow.cpp
r63312 r63689 36 36 #include "Chrome.h" 37 37 #include "Console.h" 38 #include "DocumentLoader.h" 38 39 #include "DOMApplicationCache.h" 39 40 #include "DOMSelection.h" … … 1439 1440 void DOMWindow::dispatchLoadEvent() 1440 1441 { 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(); 1443 1444 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(); 1446 1447 1447 1448 // For load events, send a separate load event to the enclosing frame only. -
trunk/WebCore/page/Navigation.cpp
r63356 r63689 80 80 return 0; 81 81 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; 83 87 } 84 88 -
trunk/WebCore/page/Timing.cpp
r63569 r63689 41 41 namespace WebCore { 42 42 43 static unsigned long long toIntegerMilliseconds(double milliseconds) 44 { 45 ASSERT(milliseconds >= 0); 46 return static_cast<unsigned long long>(milliseconds * 1000.0); 43 static unsigned long long toIntegerMilliseconds(double seconds) 44 { 45 ASSERT(seconds >= 0); 46 return static_cast<unsigned long long>(seconds * 1000.0); 47 } 48 49 static 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; 47 68 } 48 69 … … 64 85 unsigned long long Timing::navigationStart() const 65 86 { 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); 70 92 } 71 93 72 94 unsigned long long Timing::unloadEventEnd() const 73 95 { 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); 78 101 } 79 102 80 103 unsigned long long Timing::redirectStart() const 81 104 { 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); 86 110 } 87 111 88 112 unsigned long long Timing::redirectEnd() const 89 113 { 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); 94 119 } 95 120 96 121 unsigned long long Timing::fetchStart() const 97 122 { 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); 102 128 } 103 129 … … 114 140 return fetchStart(); 115 141 116 return toIntegerMilliseconds(timing->requestTime) + dnsStart;142 return resourceLoadTimeRelativeToAbsolute(dnsStart); 117 143 } 118 144 … … 129 155 return domainLookupStart(); 130 156 131 return toIntegerMilliseconds(timing->requestTime) + dnsEnd;157 return resourceLoadTimeRelativeToAbsolute(dnsEnd); 132 158 } 133 159 … … 144 170 return domainLookupEnd(); 145 171 146 return toIntegerMilliseconds(timing->requestTime) + connectStart;172 return resourceLoadTimeRelativeToAbsolute(connectStart); 147 173 } 148 174 … … 159 185 return connectStart(); 160 186 161 return toIntegerMilliseconds(timing->requestTime) + connectEnd;187 return resourceLoadTimeRelativeToAbsolute(connectEnd); 162 188 } 163 189 … … 169 195 170 196 ASSERT(timing->sendStart >= 0); 171 return toIntegerMilliseconds(timing->requestTime) + timing->sendStart;197 return resourceLoadTimeRelativeToAbsolute(timing->sendStart); 172 198 } 173 199 … … 179 205 180 206 ASSERT(timing->sendEnd >= 0); 181 return toIntegerMilliseconds(timing->requestTime) + timing->sendEnd;207 return resourceLoadTimeRelativeToAbsolute(timing->sendEnd); 182 208 } 183 209 … … 195 221 // headers larger than a single packet, this time will be too late. 196 222 ASSERT(timing->receiveHeadersEnd >= 0); 197 return toIntegerMilliseconds(timing->requestTime) + timing->receiveHeadersEnd;223 return resourceLoadTimeRelativeToAbsolute(timing->receiveHeadersEnd); 198 224 } 199 225 200 226 unsigned long long Timing::responseEnd() const 201 227 { 228 DocumentLoadTiming* timing = documentLoadTiming(); 229 if (!timing) 230 return 0; 231 232 return toIntegerMilliseconds(timing->responseEnd); 233 } 234 235 unsigned long long Timing::loadEventStart() const 236 { 237 DocumentLoadTiming* timing = documentLoadTiming(); 238 if (!timing) 239 return 0; 240 241 return toIntegerMilliseconds(timing->loadEventStart); 242 } 243 244 unsigned long long Timing::loadEventEnd() const 245 { 246 DocumentLoadTiming* timing = documentLoadTiming(); 247 if (!timing) 248 return 0; 249 250 return toIntegerMilliseconds(timing->loadEventEnd); 251 } 252 253 DocumentLoader* Timing::documentLoader() const 254 { 202 255 if (!m_frame) 203 256 return 0; 204 257 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 261 DocumentLoadTiming* Timing::documentLoadTiming() const 262 { 263 DocumentLoader* loader = documentLoader(); 264 if (!loader) 265 return 0; 266 267 return loader->timing(); 222 268 } 223 269 224 270 ResourceLoadTiming* Timing::resourceLoadTiming() const 225 271 { 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 279 unsigned 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; 231 295 } 232 296 -
trunk/WebCore/page/Timing.h
r63426 r63689 39 39 namespace WebCore { 40 40 41 struct DocumentLoadTiming; 42 class DocumentLoader; 41 43 class Frame; 42 44 class ResourceLoadTiming; … … 68 70 Timing(Frame*); 69 71 72 DocumentLoader* documentLoader() const; 73 DocumentLoadTiming* documentLoadTiming() const; 70 74 ResourceLoadTiming* resourceLoadTiming() const; 75 unsigned long long resourceLoadTimeRelativeToAbsolute(int) const; 71 76 72 77 Frame* m_frame;
Note: See TracChangeset
for help on using the changeset viewer.