Fixes the bug where resource would show up multiple times in the
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 06:57:32 +0000 (06:57 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 06:57:32 +0000 (06:57 +0000)
Inspector. This happened when a resource was used multiple times or
when the preloader was scanning ahead to fetch resources.

<rdar://problem/5689373> Cached resources re-appear in Web Inspector
for each access (18223)

Reviewed by Adam Roben.

* page/InspectorController.cpp:
(WebCore::InspectorController::addResource): Add the URL to m_knownResources.
(WebCore::InspectorController::removeResource): Remove the URL from m_knownResources
(WebCore::InspectorController::didLoadResourceFromMemoryCache): If the URL
is in m_knownResources, then early return.
* page/InspectorController.h: Added m_knownResources.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34059 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/page/InspectorController.cpp
WebCore/page/InspectorController.h

index 91dc040..b0006d8 100644 (file)
@@ -1,3 +1,21 @@
+2008-05-22  Timothy Hatcher  <timothy@apple.com>
+
+        Fixes the bug where resource would show up multiple times in the
+        Inspector. This happened when a resource was used multiple times or
+        when the preloader was scanning ahead to fetch resources.
+
+        <rdar://problem/5689373> Cached resources re-appear in Web Inspector
+        for each access (18223)
+
+        Reviewed by Adam Roben.
+
+        * page/InspectorController.cpp:
+        (WebCore::InspectorController::addResource): Add the URL to m_knownResources.
+        (WebCore::InspectorController::removeResource): Remove the URL from m_knownResources
+        (WebCore::InspectorController::didLoadResourceFromMemoryCache): If the URL
+        is in m_knownResources, then early return.
+        * page/InspectorController.h: Added m_knownResources.
+
 2008-05-22  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Adele, Dan Bernstein.
index 038a1ec..8dfde38 100644 (file)
@@ -1962,6 +1962,7 @@ void InspectorController::frameDetachedFromParent(Frame* frame)
 void InspectorController::addResource(InspectorResource* resource)
 {
     m_resources.set(resource->identifier, resource);
+    m_knownResources.add(resource->requestURL.string());
 
     Frame* frame = resource->frame.get();
     ResourcesMap* resourceMap = m_frameResources.get(frame);
@@ -1977,6 +1978,7 @@ void InspectorController::addResource(InspectorResource* resource)
 void InspectorController::removeResource(InspectorResource* resource)
 {
     m_resources.remove(resource->identifier);
+    m_knownResources.remove(resource->requestURL.string());
 
     Frame* frame = resource->frame.get();
     ResourcesMap* resourceMap = m_frameResources.get(frame);
@@ -1997,6 +1999,10 @@ void InspectorController::didLoadResourceFromMemoryCache(DocumentLoader* loader,
     if (!enabled())
         return;
 
+    // If the resource URL is already known, we don't need to add it again since this is just a cached load.
+    if (m_knownResources.contains(request.url().string()))
+        return;
+
     RefPtr<InspectorResource> resource = InspectorResource::create(m_nextIdentifier--, loader, loader->frame());
     resource->finished = true;
 
index 2fd401f..bf95aed 100644 (file)
@@ -32,6 +32,8 @@
 #include "JavaScriptDebugListener.h"
 
 #include "Console.h"
+#include "PlatformString.h"
+#include "StringHash.h"
 #include <JavaScriptCore/JSContextRef.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
@@ -210,6 +212,7 @@ private:
     RefPtr<Node> m_nodeToFocus;
     RefPtr<InspectorResource> m_mainResource;
     ResourcesMap m_resources;
+    HashSet<String> m_knownResources;
     FrameResourcesMap m_frameResources;
     Vector<ConsoleMessage*> m_consoleMessages;
     Vector<RefPtr<KJS::Profile> > m_profiles;