Title: [205062] trunk/Source
Revision
205062
Author
[email protected]
Date
2016-08-26 17:30:00 -0700 (Fri, 26 Aug 2016)

Log Message

Web Inspector: Frontend should have access to Resource Timing information
https://bugs.webkit.org/show_bug.cgi?id=160095

Patch by Johan K. Jensen <[email protected]> on 2016-08-26
Reviewed by Alex Christensen.

Source/_javascript_Core:

Rename ResourceTiming property.

* inspector/protocol/Network.json:
Rename navigationStart to startTime so it's applicable
for all resources and not just the main resource.

Source/WebCore:

Show correct information with Resource Timing information
from ResourceLoader rather than DocumentLoader.

No new tests, frontend doesn't use the timing data yet.

* inspector/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::buildObjectForTiming):
(WebCore::InspectorNetworkAgent::buildObjectForResourceResponse):
(WebCore::InspectorNetworkAgent::buildObjectForCachedResource):
(WebCore::InspectorNetworkAgent::willSendRequest):
(WebCore::InspectorNetworkAgent::didReceiveResponse):
(WebCore::InspectorNetworkAgent::didLoadResourceFromMemoryCache):
(WebCore::buildObjectForTiming): Deleted.
(WebCore::buildObjectForResourceResponse): Deleted.
(WebCore::buildObjectForCachedResource): Deleted.
Use ResourceLoader instead of DocumentLoader to get Resource Timing information.
Move functions to member functions to access the executionStopWatch.

(WebCore::InspectorNetworkAgent::didFinishLoading):
Use the load timing finishTime and convert to elapsed time for frontend.

* inspector/InspectorNetworkAgent.h:
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::didFinishLoading):
Pass the web process load timing on to the inspector.

Source/WTF:

Add method to get elapsed time for any monotonic time.
Used by InspectorNetworkAgent.

* wtf/Stopwatch.h:
(WTF::Stopwatch::elapsedTimeSinceMonotonicTime):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (205061 => 205062)


--- trunk/Source/_javascript_Core/ChangeLog	2016-08-27 00:13:59 UTC (rev 205061)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-08-27 00:30:00 UTC (rev 205062)
@@ -1,3 +1,16 @@
+2016-08-26  Johan K. Jensen  <[email protected]>
+
+        Web Inspector: Frontend should have access to Resource Timing information
+        https://bugs.webkit.org/show_bug.cgi?id=160095
+
+        Reviewed by Alex Christensen.
+
+        Rename ResourceTiming property.
+
+        * inspector/protocol/Network.json:
+        Rename navigationStart to startTime so it's applicable
+        for all resources and not just the main resource.
+
 2016-08-25  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Provide a way to clear an IndexedDB object store

Modified: trunk/Source/_javascript_Core/inspector/protocol/Network.json (205061 => 205062)


--- trunk/Source/_javascript_Core/inspector/protocol/Network.json	2016-08-27 00:13:59 UTC (rev 205061)
+++ trunk/Source/_javascript_Core/inspector/protocol/Network.json	2016-08-27 00:30:00 UTC (rev 205062)
@@ -33,7 +33,7 @@
             "type": "object",
             "description": "Timing information for the request.",
             "properties": [
-                { "name": "navigationStart", "type": "number", "description": "Timing's navigationStart is a baseline in seconds, while the other numbers are ticks in milliseconds relatively to this navigationStart." },
+                { "name": "startTime", "type": "number", "description": "Timing's startTime is a baseline in seconds, while the other numbers are ticks in milliseconds relatively to this." },
                 { "name": "domainLookupStart", "type": "number", "description": "Started DNS address resolve." },
                 { "name": "domainLookupEnd", "type": "number", "description": "Finished DNS address resolve." },
                 { "name": "connectStart", "type": "number", "description": "Started connecting to the remote host." },

Modified: trunk/Source/WTF/ChangeLog (205061 => 205062)


--- trunk/Source/WTF/ChangeLog	2016-08-27 00:13:59 UTC (rev 205061)
+++ trunk/Source/WTF/ChangeLog	2016-08-27 00:30:00 UTC (rev 205062)
@@ -1,3 +1,16 @@
+2016-08-26  Johan K. Jensen  <[email protected]>
+
+        Web Inspector: Frontend should have access to Resource Timing information
+        https://bugs.webkit.org/show_bug.cgi?id=160095
+
+        Reviewed by Alex Christensen.
+
+        Add method to get elapsed time for any monotonic time.
+        Used by InspectorNetworkAgent.
+
+        * wtf/Stopwatch.h:
+        (WTF::Stopwatch::elapsedTimeSinceMonotonicTime):
+
 2016-08-26  Csaba Osztrogonác  <[email protected]>
 
         Fix the ENABLE(WEBASSEMBLY) build on Linux

Modified: trunk/Source/WTF/wtf/Stopwatch.h (205061 => 205062)


--- trunk/Source/WTF/wtf/Stopwatch.h	2016-08-27 00:13:59 UTC (rev 205061)
+++ trunk/Source/WTF/wtf/Stopwatch.h	2016-08-27 00:30:00 UTC (rev 205062)
@@ -43,6 +43,7 @@
     void stop();
 
     double elapsedTime();
+    double elapsedTimeSinceMonotonicTime(double);
 
     bool isActive() const { return !std::isnan(m_lastStartTime); }
 private:
@@ -81,6 +82,14 @@
     return m_elapsedTime + (monotonicallyIncreasingTime() - m_lastStartTime);
 }
 
+inline double Stopwatch::elapsedTimeSinceMonotonicTime(double monotonicTime)
+{
+    if (!isActive())
+        return m_elapsedTime;
+
+    return m_elapsedTime + (monotonicTime - m_lastStartTime);
+}
+
 } // namespace WTF
 
 using WTF::Stopwatch;

Modified: trunk/Source/WebCore/ChangeLog (205061 => 205062)


--- trunk/Source/WebCore/ChangeLog	2016-08-27 00:13:59 UTC (rev 205061)
+++ trunk/Source/WebCore/ChangeLog	2016-08-27 00:30:00 UTC (rev 205062)
@@ -1,3 +1,36 @@
+2016-08-26  Johan K. Jensen  <[email protected]>
+
+        Web Inspector: Frontend should have access to Resource Timing information
+        https://bugs.webkit.org/show_bug.cgi?id=160095
+
+        Reviewed by Alex Christensen.
+
+        Show correct information with Resource Timing information
+        from ResourceLoader rather than DocumentLoader.
+
+        No new tests, frontend doesn't use the timing data yet.
+
+        * inspector/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::buildObjectForTiming):
+        (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse):
+        (WebCore::InspectorNetworkAgent::buildObjectForCachedResource):
+        (WebCore::InspectorNetworkAgent::willSendRequest):
+        (WebCore::InspectorNetworkAgent::didReceiveResponse):
+        (WebCore::InspectorNetworkAgent::didLoadResourceFromMemoryCache):
+        (WebCore::buildObjectForTiming): Deleted.
+        (WebCore::buildObjectForResourceResponse): Deleted.
+        (WebCore::buildObjectForCachedResource): Deleted.
+        Use ResourceLoader instead of DocumentLoader to get Resource Timing information.
+        Move functions to member functions to access the executionStopWatch.
+
+        (WebCore::InspectorNetworkAgent::didFinishLoading):
+        Use the load timing finishTime and convert to elapsed time for frontend.
+
+        * inspector/InspectorNetworkAgent.h:
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::didFinishLoading):
+        Pass the web process load timing on to the inspector.
+
 2016-08-26  Chris Dumez  <[email protected]>
 
         Unreviewed, fix Windows build after r205048.

Modified: trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp (205061 => 205062)


--- trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp	2016-08-27 00:13:59 UTC (rev 205061)
+++ trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp	2016-08-27 00:30:00 UTC (rev 205062)
@@ -184,10 +184,13 @@
     return headersObject;
 }
 
-static Ref<Inspector::Protocol::Network::ResourceTiming> buildObjectForTiming(const NetworkLoadTiming& timing, DocumentLoader* loader)
+Ref<Inspector::Protocol::Network::ResourceTiming> InspectorNetworkAgent::buildObjectForTiming(const NetworkLoadTiming& timing, ResourceLoader& resourceLoader)
 {
+    double monotonicTime = resourceLoader.loadTiming().startTime();
+    double startTimeInInspector = m_environment.executionStopwatch()->elapsedTimeSinceMonotonicTime(monotonicTime);
+
     return Inspector::Protocol::Network::ResourceTiming::create()
-        .setNavigationStart(loader->timing().startTime())
+        .setStartTime(startTimeInInspector)
         .setDomainLookupStart(timing.domainLookupStart)
         .setDomainLookupEnd(timing.domainLookupEnd)
         .setConnectStart(timing.connectStart)
@@ -213,7 +216,7 @@
     return requestObject;
 }
 
-static RefPtr<Inspector::Protocol::Network::Response> buildObjectForResourceResponse(const ResourceResponse& response, DocumentLoader* loader)
+RefPtr<Inspector::Protocol::Network::Response> InspectorNetworkAgent::buildObjectForResourceResponse(const ResourceResponse& response, ResourceLoader* resourceLoader)
 {
     if (response.isNull())
         return nullptr;
@@ -230,12 +233,13 @@
         .release();
 
     responseObject->setFromDiskCache(response.source() == ResourceResponse::Source::DiskCache || response.source() == ResourceResponse::Source::DiskCacheAfterValidation);
-    responseObject->setTiming(buildObjectForTiming(response.networkLoadTiming(), loader));
+    if (resourceLoader)
+        responseObject->setTiming(buildObjectForTiming(response.networkLoadTiming(), *resourceLoader));
 
     return WTFMove(responseObject);
 }
 
-static Ref<Inspector::Protocol::Network::CachedResource> buildObjectForCachedResource(CachedResource* cachedResource, DocumentLoader* loader)
+Ref<Inspector::Protocol::Network::CachedResource> InspectorNetworkAgent::buildObjectForCachedResource(CachedResource* cachedResource)
 {
     auto resourceObject = Inspector::Protocol::Network::CachedResource::create()
         .setUrl(cachedResource->url())
@@ -243,7 +247,7 @@
         .setBodySize(cachedResource->encodedSize())
         .release();
 
-    auto resourceResponse = buildObjectForResourceResponse(cachedResource->response(), loader);
+    auto resourceResponse = buildObjectForResourceResponse(cachedResource->response(), cachedResource->loader());
     resourceObject->setResponse(WTFMove(resourceResponse));
 
     String sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(cachedResource);
@@ -305,7 +309,7 @@
     Inspector::Protocol::Page::ResourceType resourceType = InspectorPageAgent::resourceTypeJson(type);
 
     RefPtr<Inspector::Protocol::Network::Initiator> initiatorObject = buildInitiatorObject(loader.frame() ? loader.frame()->document() : nullptr);
-    m_frontendDispatcher->requestWillBeSent(requestId, m_pageAgent->frameId(loader.frame()), m_pageAgent->loaderId(&loader), loader.url().string(), buildObjectForResourceRequest(request), timestamp(), initiatorObject, buildObjectForResourceResponse(redirectResponse, &loader), type != InspectorPageAgent::OtherResource ? &resourceType : nullptr);
+    m_frontendDispatcher->requestWillBeSent(requestId, m_pageAgent->frameId(loader.frame()), m_pageAgent->loaderId(&loader), loader.url().string(), buildObjectForResourceRequest(request), timestamp(), initiatorObject, buildObjectForResourceResponse(redirectResponse, nullptr), type != InspectorPageAgent::OtherResource ? &resourceType : nullptr);
 }
 
 void InspectorNetworkAgent::markResourceAsCached(unsigned long identifier)
@@ -322,7 +326,7 @@
         return;
 
     String requestId = IdentifiersFactory::requestId(identifier);
-    RefPtr<Inspector::Protocol::Network::Response> resourceResponse = buildObjectForResourceResponse(response, &loader);
+    RefPtr<Inspector::Protocol::Network::Response> resourceResponse = buildObjectForResourceResponse(response, resourceLoader);
 
     bool isNotModified = response.httpStatusCode() == 304;
 
@@ -390,11 +394,7 @@
 
     m_resourcesData->maybeDecodeDataToContent(requestId);
 
-    // FIXME: The finishTime that is passed in is from the NetworkProcess and is more accurate.
-    // However, all other times passed to the Inspector are generated from the web process. Mixing
-    // times from different processes can cause the finish time to be earlier than the response
-    // received time due to inter-process communication lag.
-    finishTime = timestamp();
+    double elapsedFinishTime = finishTime ? m_environment.executionStopwatch()->elapsedTimeSinceMonotonicTime(finishTime) : timestamp();
 
     String sourceMappingURL;
     NetworkResourcesData::ResourceData const* resourceData = m_resourcesData->data(requestId);
@@ -401,7 +401,7 @@
     if (resourceData && resourceData->cachedResource())
         sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(resourceData->cachedResource());
 
-    m_frontendDispatcher->loadingFinished(requestId, finishTime, !sourceMappingURL.isEmpty() ? &sourceMappingURL : nullptr);
+    m_frontendDispatcher->loadingFinished(requestId, elapsedFinishTime, !sourceMappingURL.isEmpty() ? &sourceMappingURL : nullptr);
 }
 
 void InspectorNetworkAgent::didFailLoading(unsigned long identifier, DocumentLoader& loader, const ResourceError& error)
@@ -435,7 +435,7 @@
 
     RefPtr<Inspector::Protocol::Network::Initiator> initiatorObject = buildInitiatorObject(loader.frame() ? loader.frame()->document() : nullptr);
 
-    m_frontendDispatcher->requestServedFromMemoryCache(requestId, frameId, loaderId, loader.url().string(), timestamp(), initiatorObject, buildObjectForCachedResource(&resource, &loader));
+    m_frontendDispatcher->requestServedFromMemoryCache(requestId, frameId, loaderId, loader.url().string(), timestamp(), initiatorObject, buildObjectForCachedResource(&resource));
 }
 
 void InspectorNetworkAgent::setInitialScriptContent(unsigned long identifier, const String& sourceString)

Modified: trunk/Source/WebCore/inspector/InspectorNetworkAgent.h (205061 => 205062)


--- trunk/Source/WebCore/inspector/InspectorNetworkAgent.h	2016-08-27 00:13:59 UTC (rev 205061)
+++ trunk/Source/WebCore/inspector/InspectorNetworkAgent.h	2016-08-27 00:30:00 UTC (rev 205062)
@@ -48,6 +48,7 @@
 class Document;
 class DocumentLoader;
 class InspectorPageAgent;
+class NetworkLoadTiming;
 class NetworkResourcesData;
 class ResourceError;
 class ResourceLoader;
@@ -116,6 +117,10 @@
 private:
     void enable();
 
+    Ref<Inspector::Protocol::Network::ResourceTiming> buildObjectForTiming(const NetworkLoadTiming&, ResourceLoader&);
+    RefPtr<Inspector::Protocol::Network::Response> buildObjectForResourceResponse(const ResourceResponse&, ResourceLoader*);
+    Ref<Inspector::Protocol::Network::CachedResource> buildObjectForCachedResource(CachedResource*);
+
     double timestamp();
 
     std::unique_ptr<Inspector::NetworkFrontendDispatcher> m_frontendDispatcher;

Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (205061 => 205062)


--- trunk/Source/WebCore/loader/SubresourceLoader.cpp	2016-08-27 00:13:59 UTC (rev 205061)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp	2016-08-27 00:30:00 UTC (rev 205062)
@@ -460,8 +460,13 @@
     Ref<SubresourceLoader> protectedThis(*this);
     CachedResourceHandle<CachedResource> protectResource(m_resource);
 
-    finishTime = monotonicallyIncreasingTime();
-    m_loadTiming.setResponseEnd(finishTime);
+    // FIXME: The finishTime that is passed in is from the NetworkProcess and is more accurate.
+    // However, all other load times are generated from the web process or offsets.
+    // Mixing times from different processes can cause the finish time to be earlier than
+    // the response received time due to inter-process communication lag.
+    UNUSED_PARAM(finishTime);
+    double responseEndTime = monotonicallyIncreasingTime();
+    m_loadTiming.setResponseEnd(responseEndTime);
 
 #if ENABLE(WEB_TIMING)
     if (m_documentLoader->cachedResourceLoader().document() && RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
@@ -469,7 +474,7 @@
 #endif
 
     m_state = Finishing;
-    m_resource->setLoadFinishTime(finishTime);
+    m_resource->setLoadFinishTime(responseEndTime); // FIXME: Users of the loadFinishTime should use the LoadTiming struct instead.
     m_resource->finishLoading(resourceData());
 
     if (wasCancelled())
@@ -476,7 +481,7 @@
         return;
     m_resource->finish();
     ASSERT(!reachedTerminalState());
-    didFinishLoadingOnePart(finishTime);
+    didFinishLoadingOnePart(responseEndTime);
     notifyDone();
     if (reachedTerminalState())
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to