Title: [89163] trunk
Revision
89163
Author
commit-qu...@webkit.org
Date
2011-06-17 13:00:33 -0700 (Fri, 17 Jun 2011)

Log Message

2011-06-17  Vsevolod Vlasov  <vse...@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: Network panel does not show main resource content for iframes deleted from the document
        https://bugs.webkit.org/show_bug.cgi?id=62810

        * http/tests/inspector/network/network-iframe-load-and-delete-expected.txt: Added.
        * http/tests/inspector/network/network-iframe-load-and-delete.html: Added.
2011-06-17  Vsevolod Vlasov  <vse...@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: Network panel does not show main resource content for iframes deleted from the document
        https://bugs.webkit.org/show_bug.cgi?id=62810

        Test: http/tests/inspector/network/network-iframe-load-and-delete.html

        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::didFinishLoadingImpl):
        (WebCore::InspectorInstrumentation::didFailLoadingImpl):
        * inspector/InspectorInstrumentation.h:
        (WebCore::InspectorInstrumentation::didFinishLoading):
        (WebCore::InspectorInstrumentation::didFailLoading):
        * inspector/InspectorPageAgent.cpp:
        (WebCore::cachedResourceContent):
        (WebCore::mainResourceContent):
        (WebCore::InspectorPageAgent::sharedBufferContent):
        (WebCore::InspectorPageAgent::resourceContent):
        (WebCore::InspectorPageAgent::getResourceContent):
        (WebCore::InspectorPageAgent::searchInResources):
        * inspector/InspectorPageAgent.h:
        * inspector/InspectorResourceAgent.cpp:
        (WebCore::InspectorResourceAgent::didReceiveResponse):
        (WebCore::InspectorResourceAgent::didFinishLoading):
        (WebCore::InspectorResourceAgent::didFailLoading):
        (WebCore::InspectorResourceAgent::didReceiveXHRResponse):
        (WebCore::InspectorResourceAgent::getResourceContent):
        * inspector/InspectorResourceAgent.h:
        * inspector/InspectorStyleSheet.cpp:
        (WebCore::InspectorStyleSheet::resourceStyleSheetText):
        * inspector/NetworkResourcesData.cpp:
        (WebCore::NetworkResourcesData::ResourceData::ResourceData):
        (WebCore::NetworkResourcesData::setResourceType):
        (WebCore::NetworkResourcesData::resourceType):
        (WebCore::NetworkResourcesData::addResourceSharedBuffer):
        * inspector/NetworkResourcesData.h:
        (WebCore::NetworkResourcesData::ResourceData::type):
        (WebCore::NetworkResourcesData::ResourceData::setType):
        (WebCore::NetworkResourcesData::ResourceData::buffer):
        (WebCore::NetworkResourcesData::ResourceData::setBuffer):
        (WebCore::NetworkResourcesData::ResourceData::textEncodingName):
        (WebCore::NetworkResourcesData::ResourceData::setTextEncodingName):
        * loader/ResourceLoadNotifier.cpp:
        (WebCore::ResourceLoadNotifier::didFailToLoad):
        (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
        * loader/appcache/ApplicationCacheGroup.cpp:
        (WebCore::ApplicationCacheGroup::didFinishLoading):
        (WebCore::ApplicationCacheGroup::didFail):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (89162 => 89163)


--- trunk/LayoutTests/ChangeLog	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/LayoutTests/ChangeLog	2011-06-17 20:00:33 UTC (rev 89163)
@@ -1,3 +1,13 @@
+2011-06-17  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Network panel does not show main resource content for iframes deleted from the document
+        https://bugs.webkit.org/show_bug.cgi?id=62810
+
+        * http/tests/inspector/network/network-iframe-load-and-delete-expected.txt: Added.
+        * http/tests/inspector/network/network-iframe-load-and-delete.html: Added.
+
 2011-06-17  Ryosuke Niwa  <rn...@webkit.org>
 
         Fix Chromium test expectations.

Added: trunk/LayoutTests/http/tests/inspector/network/network-iframe-load-and-delete-expected.txt (0 => 89163)


--- trunk/LayoutTests/http/tests/inspector/network/network-iframe-load-and-delete-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/network-iframe-load-and-delete-expected.txt	2011-06-17 20:00:33 UTC (rev 89163)
@@ -0,0 +1,12 @@
+CONSOLE MESSAGE: line 36: Done.
+Tests that if iframe is loaded and then deleted, inspector could still show its content. Note that if iframe.src is changed to "_javascript_:'...some html...'" after loading, then we have different codepath, hence two tests;
+
+http://127.0.0.1:8000/inspector/network/resources/resource.php
+resource.type: 0
+resource.content before requesting content: undefined
+resource.content after requesting content: Hello world
+http://127.0.0.1:8000/inspector/network/resources/resource.php
+resource.type: 0
+resource.content before requesting content: undefined
+resource.content after requesting content: Hello world
+

Added: trunk/LayoutTests/http/tests/inspector/network/network-iframe-load-and-delete.html (0 => 89163)


--- trunk/LayoutTests/http/tests/inspector/network/network-iframe-load-and-delete.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/network-iframe-load-and-delete.html	2011-06-17 20:00:33 UTC (rev 89163)
@@ -0,0 +1,82 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+var iframe;
+
+function loadIframe()
+{
+    iframe = document.createElement("iframe");
+    document.body.appendChild(iframe);
+    iframe._onload_ = iframeLoaded;
+    iframe.src = ""
+}
+
+function iframeLoaded()
+{
+    document.body.removeChild(iframe);
+
+    loadIframeAndChangeSrcAfterLoad();
+}
+
+function loadIframeAndChangeSrcAfterLoad()
+{
+    iframe = document.createElement("iframe");
+    document.body.appendChild(iframe);
+    iframe._onload_ = iframeLoadedChangeSrc;
+    iframe.src = ""
+}
+
+function iframeLoadedChangeSrc()
+{
+    iframe._onload_ = null;
+    iframe.src = ""
+    document.body.removeChild(iframe);
+    console.log("Done.");
+}
+
+function test()
+{
+    InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "addMessage", step2);
+    InspectorTest.evaluateInPage("loadIframe()");
+
+    function step2()
+    {
+        var resource1 = WebInspector.panels.network.resources[WebInspector.panels.network.resources.length - 3];
+        InspectorTest.addResult(resource1.url);
+        InspectorTest.addResult("resource.type: " + resource1.type);
+        InspectorTest.addResult("resource.content before requesting content: " + resource1.content);
+        resource1.requestContent(step3);
+    }
+
+    function step3()
+    {
+        var resource1 = WebInspector.panels.network.resources[WebInspector.panels.network.resources.length - 3];
+        InspectorTest.addResult("resource.content after requesting content: " + resource1.content);
+
+        var resource2 = WebInspector.panels.network.resources[WebInspector.panels.network.resources.length - 1];
+        InspectorTest.addResult(resource2.url);
+        InspectorTest.addResult("resource.type: " + resource2.type);
+        InspectorTest.addResult("resource.content before requesting content: " + resource2.content);
+        resource2.requestContent(step4);
+    }
+
+    function step4()
+    {
+        var resource2 = WebInspector.panels.network.resources[WebInspector.panels.network.resources.length - 1];
+        InspectorTest.addResult("resource.content after requesting content: " + resource2.content);
+
+        InspectorTest.completeTest();
+    }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+  <p>
+    Tests that if iframe is loaded and then deleted, inspector could still show its content.
+    Note that if iframe.src is changed to "_javascript_:'...some html...'" after
+    loading, then we have different codepath, hence two tests;
+  </p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (89162 => 89163)


--- trunk/Source/WebCore/ChangeLog	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/ChangeLog	2011-06-17 20:00:33 UTC (rev 89163)
@@ -1,3 +1,54 @@
+2011-06-17  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Network panel does not show main resource content for iframes deleted from the document
+        https://bugs.webkit.org/show_bug.cgi?id=62810
+
+        Test: http/tests/inspector/network/network-iframe-load-and-delete.html
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didFinishLoadingImpl):
+        (WebCore::InspectorInstrumentation::didFailLoadingImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::didFinishLoading):
+        (WebCore::InspectorInstrumentation::didFailLoading):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::cachedResourceContent):
+        (WebCore::mainResourceContent):
+        (WebCore::InspectorPageAgent::sharedBufferContent):
+        (WebCore::InspectorPageAgent::resourceContent):
+        (WebCore::InspectorPageAgent::getResourceContent):
+        (WebCore::InspectorPageAgent::searchInResources):
+        * inspector/InspectorPageAgent.h:
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::didReceiveResponse):
+        (WebCore::InspectorResourceAgent::didFinishLoading):
+        (WebCore::InspectorResourceAgent::didFailLoading):
+        (WebCore::InspectorResourceAgent::didReceiveXHRResponse):
+        (WebCore::InspectorResourceAgent::getResourceContent):
+        * inspector/InspectorResourceAgent.h:
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheet::resourceStyleSheetText):
+        * inspector/NetworkResourcesData.cpp:
+        (WebCore::NetworkResourcesData::ResourceData::ResourceData):
+        (WebCore::NetworkResourcesData::setResourceType):
+        (WebCore::NetworkResourcesData::resourceType):
+        (WebCore::NetworkResourcesData::addResourceSharedBuffer):
+        * inspector/NetworkResourcesData.h:
+        (WebCore::NetworkResourcesData::ResourceData::type):
+        (WebCore::NetworkResourcesData::ResourceData::setType):
+        (WebCore::NetworkResourcesData::ResourceData::buffer):
+        (WebCore::NetworkResourcesData::ResourceData::setBuffer):
+        (WebCore::NetworkResourcesData::ResourceData::textEncodingName):
+        (WebCore::NetworkResourcesData::ResourceData::setTextEncodingName):
+        * loader/ResourceLoadNotifier.cpp:
+        (WebCore::ResourceLoadNotifier::didFailToLoad):
+        (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::didFinishLoading):
+        (WebCore::ApplicationCacheGroup::didFail):
+
 2011-06-17  Darin Adler  <da...@apple.com>
 
         Fix clang build.

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (89162 => 89163)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2011-06-17 20:00:33 UTC (rev 89163)
@@ -490,20 +490,20 @@
         resourceAgent->didReceiveContentLength(identifier, dataLength, encodedDataLength);
 }
 
-void InspectorInstrumentation::didFinishLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, double finishTime)
+void InspectorInstrumentation::didFinishLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, double finishTime)
 {
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
         timelineAgent->didFinishLoadingResource(identifier, false, finishTime);
     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
-        resourceAgent->didFinishLoading(identifier, finishTime);
+        resourceAgent->didFinishLoading(identifier, loader, finishTime);
 }
 
-void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const ResourceError& error)
+void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, const ResourceError& error)
 {
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
         timelineAgent->didFinishLoadingResource(identifier, true, 0);
     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
-        resourceAgent->didFailLoading(identifier, error);
+        resourceAgent->didFailLoading(identifier, loader, error);
     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
         consoleAgent->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.
 }

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (89162 => 89163)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2011-06-17 20:00:33 UTC (rev 89163)
@@ -125,8 +125,8 @@
     static void continueWithPolicyDownload(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
     static void continueWithPolicyIgnore(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
     static void didReceiveContentLength(Frame*, unsigned long identifier, int dataLength, int encodedDataLength);
-    static void didFinishLoading(Frame*, unsigned long identifier, double finishTime);
-    static void didFailLoading(Frame*, unsigned long identifier, const ResourceError&);
+    static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, double finishTime);
+    static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
     static void resourceRetrievedByXMLHttpRequest(ScriptExecutionContext*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
     static void didReceiveXHRResponse(ScriptExecutionContext*, unsigned long identifier);
     static void willLoadXHRSynchronously(ScriptExecutionContext*);
@@ -253,8 +253,8 @@
     static void continueWithPolicyDownloadImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
     static void continueWithPolicyIgnoreImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
     static void didReceiveContentLengthImpl(InstrumentingAgents*, unsigned long identifier, int dataLength, int encodedDataLength);
-    static void didFinishLoadingImpl(InstrumentingAgents*, unsigned long identifier, double finishTime);
-    static void didFailLoadingImpl(InstrumentingAgents*, unsigned long identifier, const ResourceError&);
+    static void didFinishLoadingImpl(InstrumentingAgents*, unsigned long identifier, DocumentLoader*, double finishTime);
+    static void didFailLoadingImpl(InstrumentingAgents*, unsigned long identifier, DocumentLoader*, const ResourceError&);
     static void resourceRetrievedByXMLHttpRequestImpl(InstrumentingAgents*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
     static void didReceiveXHRResponseImpl(InstrumentingAgents*, unsigned long identifier);
     static void willLoadXHRSynchronouslyImpl(InstrumentingAgents*);
@@ -762,19 +762,19 @@
 #endif
 }
 
-inline void InspectorInstrumentation::didFinishLoading(Frame* frame, unsigned long identifier, double finishTime)
+inline void InspectorInstrumentation::didFinishLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, double finishTime)
 {
 #if ENABLE(INSPECTOR)
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
-        didFinishLoadingImpl(instrumentingAgents, identifier, finishTime);
+        didFinishLoadingImpl(instrumentingAgents, identifier, loader, finishTime);
 #endif
 }
 
-inline void InspectorInstrumentation::didFailLoading(Frame* frame, unsigned long identifier, const ResourceError& error)
+inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
 {
 #if ENABLE(INSPECTOR)
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
-        didFailLoadingImpl(instrumentingAgents, identifier, error);
+        didFailLoadingImpl(instrumentingAgents, identifier, loader, error);
 #endif
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (89162 => 89163)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2011-06-17 20:00:33 UTC (rev 89163)
@@ -110,13 +110,23 @@
     return true;
 }
 
-static bool decodeCachedResource(CachedResource* cachedResource, String* result)
+static bool cachedResourceContent(CachedResource* cachedResource, bool withBase64Encode, String* result)
 {
     bool hasZeroSize;
     bool prepared = prepareCachedResourceBuffer(cachedResource, &hasZeroSize);
     if (!prepared)
         return false;
 
+    if (withBase64Encode) {
+        RefPtr<SharedBuffer> buffer = hasZeroSize ? SharedBuffer::create() : cachedResource->data();
+
+        if (!buffer)
+            return false;
+
+        *result = base64Encode(buffer->data(), buffer->size());
+        return true;
+    }
+
     if (cachedResource) {
         switch (cachedResource->type()) {
         case CachedResource::CSSStyleSheet:
@@ -136,10 +146,24 @@
     return false;
 }
 
-static bool decodeMainResource(Frame* frame, String* result)
+static bool mainResourceContent(Frame* frame, bool withBase64Encode, String* result)
 {
-    String textEncodingName = frame->document()->inputEncoding();
     RefPtr<SharedBuffer> buffer = frame->loader()->documentLoader()->mainResourceData();
+    if (!buffer)
+        return false;
+    String textEncodingName = frame->document()->inputEncoding();
+
+    return InspectorPageAgent::sharedBufferContent(buffer, textEncodingName, withBase64Encode, result);
+}
+
+// static
+bool InspectorPageAgent::sharedBufferContent(PassRefPtr<SharedBuffer> buffer, const String& textEncodingName, bool withBase64Encode, String* result)
+{
+    if (withBase64Encode) {
+        *result = base64Encode(buffer->data(), buffer->size());
+        return true;
+    }
+
     return decodeSharedBuffer(buffer, textEncodingName, result);
 }
 
@@ -148,7 +172,8 @@
     return adoptPtr(new InspectorPageAgent(instrumentingAgents, page, injectedScriptManager));
 }
 
-void InspectorPageAgent::resourceContent(ErrorString* errorString, Frame* frame, const KURL& url, String* result)
+// static
+void InspectorPageAgent::resourceContent(ErrorString* errorString, Frame* frame, const KURL& url, bool base64Encode, String* result)
 {
     if (!frame) {
         *errorString = "No frame to get resource content for";
@@ -157,55 +182,23 @@
 
     FrameLoader* frameLoader = frame->loader();
     DocumentLoader* loader = frameLoader->documentLoader();
+
+    if (!loader) {
+        *errorString = "No documentLoader for frame to get resource content for";
+        return;
+    }
+
     RefPtr<SharedBuffer> buffer;
     bool success = false;
     if (equalIgnoringFragmentIdentifier(url, loader->url()))
-        success = decodeMainResource(frame, result);
+        success = mainResourceContent(frame, base64Encode, result);
     if (!success)
-        success = decodeCachedResource(cachedResource(frame, url), result);
+        success = cachedResourceContent(cachedResource(frame, url), base64Encode, result);
 
     if (!success)
         *errorString = "No resource with given URL found";
 }
 
-void InspectorPageAgent::resourceContentBase64(ErrorString* errorString, Frame* frame, const KURL& url, String* result)
-{
-    String textEncodingName;
-    RefPtr<SharedBuffer> data = "" url, &textEncodingName);
-    if (!data) {
-        *result = String();
-        *errorString = "No resource with given URL found";
-        return;
-    }
-
-    *result = base64Encode(data->data(), data->size());
-}
-
-PassRefPtr<SharedBuffer> InspectorPageAgent::resourceData(Frame* frame, const KURL& url, String* textEncodingName)
-{
-    RefPtr<SharedBuffer> buffer;
-    FrameLoader* frameLoader = frame->loader();
-    DocumentLoader* loader = frameLoader->documentLoader();
-    if (equalIgnoringFragmentIdentifier(url, loader->url())) {
-        *textEncodingName = frame->document()->inputEncoding();
-        buffer = frameLoader->documentLoader()->mainResourceData();
-        if (buffer)
-            return buffer;
-    }
-
-    CachedResource* cachedResource = InspectorPageAgent::cachedResource(frame, url);
-    if (!cachedResource)
-        return 0;
-
-    bool hasZeroSize;
-    bool prepared = prepareCachedResourceBuffer(cachedResource, &hasZeroSize);
-    if (!prepared)
-        return 0;
-
-    *textEncodingName = cachedResource->encoding();
-    return hasZeroSize ? SharedBuffer::create() : cachedResource->data();
-}
-
 CachedResource* InspectorPageAgent::cachedResource(Frame* frame, const KURL& url)
 {
     CachedResource* cachedResource = frame->document()->cachedResourceLoader()->cachedResource(url);
@@ -428,10 +421,8 @@
         *errorString = "No frame for given id found";
         return;
     }
-    if (optionalBase64Encode ? *optionalBase64Encode : false)
-        InspectorPageAgent::resourceContentBase64(errorString, frame, KURL(ParsedURLString, url), content);
-    else
-        InspectorPageAgent::resourceContent(errorString, frame, KURL(ParsedURLString, url), content);
+    bool base64Encode = optionalBase64Encode ? *optionalBase64Encode : false;
+    resourceContent(errorString, frame, KURL(ParsedURLString, url), base64Encode, content);
 }
 
 static String createSearchRegexSource(const String& text)
@@ -493,7 +484,7 @@
             switch (InspectorPageAgent::cachedResourceType(*cachedResource)) {
             case InspectorPageAgent::StylesheetResource:
             case InspectorPageAgent::ScriptResource:
-                if (decodeCachedResource(cachedResource, &content)) {
+                if (cachedResourceContent(cachedResource, false, &content)) {
                     int matchesCount = countRegularExpressionMatches(regex, content);
                     if (matchesCount)
                         result->pushValue(buildObjectForSearchMatch(frameId(frame), cachedResource->url(), matchesCount));
@@ -503,7 +494,7 @@
                 break;
             }
         }
-        if (decodeMainResource(frame, &content)) {
+        if (mainResourceContent(frame, false, &content)) {
             int matchesCount = countRegularExpressionMatches(regex, content);
             if (matchesCount)
                 result->pushValue(buildObjectForSearchMatch(frameId(frame), frame->document()->url(), matchesCount));

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (89162 => 89163)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.h	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h	2011-06-17 20:00:33 UTC (rev 89163)
@@ -54,6 +54,7 @@
 class KURL;
 class Page;
 class RegularExpression;
+class SharedBuffer;
 
 typedef String ErrorString;
 
@@ -74,8 +75,8 @@
 
     static PassOwnPtr<InspectorPageAgent> create(InstrumentingAgents*, Page*, InjectedScriptManager*);
 
-    static void resourceContent(ErrorString*, Frame*, const KURL&, String* result);
-    static void resourceContentBase64(ErrorString*, Frame*, const KURL&, String* result);
+    static bool sharedBufferContent(PassRefPtr<SharedBuffer>, const String& textEncodingName, bool withBase64Encode, String* result);
+    static void resourceContent(ErrorString*, Frame*, const KURL&, bool base64Encode, String* result);
 
     static PassRefPtr<SharedBuffer> resourceData(Frame*, const KURL&, String* textEncodingName);
     static CachedResource* cachedResource(Frame*, const KURL&);

Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp (89162 => 89163)


--- trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp	2011-06-17 20:00:33 UTC (rev 89163)
@@ -35,6 +35,7 @@
 
 #include "CachedResource.h"
 #include "CachedResourceLoader.h"
+#include "Document.h"
 #include "DocumentLoader.h"
 #include "EventsCollector.h"
 #include "Frame.h"
@@ -244,12 +245,12 @@
             type = InspectorPageAgent::ImageResource;
         else if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == InspectorPageAgent::OtherResource)
             type = InspectorPageAgent::DocumentResource;
-        else if (m_loadingXHRSynchronously || m_resourcesData->isXHR(identifier))
+        else if (m_loadingXHRSynchronously || m_resourcesData->resourceType(identifier) == InspectorPageAgent::XHRResource)
             type = InspectorPageAgent::XHRResource;
 
         m_resourcesData->responseReceived(identifier, m_pageAgent->frameId(loader->frame()), response.url());
     }
-
+    m_resourcesData->setResourceType(identifier, type);
     m_frontend->responseReceived(static_cast<int>(identifier), currentTime(), InspectorPageAgent::resourceTypeString(type), resourceResponse);
     // If we revalidated the resource and got Not modified, send content length following didReceiveResponse
     // as there will be no calls to didReceiveContentLength from the network stack.
@@ -262,16 +263,22 @@
     m_frontend->dataReceived(static_cast<int>(identifier), currentTime(), dataLength, encodedDataLength);
 }
 
-void InspectorResourceAgent::didFinishLoading(unsigned long identifier, double finishTime)
+void InspectorResourceAgent::didFinishLoading(unsigned long identifier, DocumentLoader* loader, double finishTime)
 {
+    if (m_resourcesData->resourceType(identifier) == InspectorPageAgent::DocumentResource)
+        m_resourcesData->addResourceSharedBuffer(identifier, loader->frameLoader()->documentLoader()->mainResourceData(), loader->frame()->document()->inputEncoding());
+
     if (!finishTime)
         finishTime = currentTime();
 
     m_frontend->loadingFinished(static_cast<int>(identifier), finishTime);
 }
 
-void InspectorResourceAgent::didFailLoading(unsigned long identifier, const ResourceError& error)
+void InspectorResourceAgent::didFailLoading(unsigned long identifier, DocumentLoader* loader, const ResourceError& error)
 {
+    if (m_resourcesData->resourceType(identifier) == InspectorPageAgent::DocumentResource)
+        m_resourcesData->addResourceSharedBuffer(identifier, loader->frameLoader()->documentLoader()->mainResourceData(), loader->frame()->document()->inputEncoding());
+
     m_frontend->loadingFailed(static_cast<int>(identifier), currentTime(), error.localizedDescription(), error.isCancellation());
 }
 
@@ -292,7 +299,7 @@
 
 void InspectorResourceAgent::didReceiveXHRResponse(unsigned long identifier)
 {
-    m_resourcesData->didReceiveXHRResponse(identifier);
+    m_resourcesData->setResourceType(identifier, InspectorPageAgent::XHRResource);
 }
 
 void InspectorResourceAgent::willLoadXHRSynchronously()
@@ -433,9 +440,19 @@
         return;
     }
 
-    if (resourceData->hasContent())
+    bool base64Encode = optionalBase64Encode ? *optionalBase64Encode : false;
+
+    if (resourceData->hasContent()) {
         *content = resourceData->content();
-    else if (!resourceData->frameId().isNull() && !resourceData->url().isNull())
+        return;
+    }
+
+    if (resourceData->buffer() && !resourceData->textEncodingName().isNull()) {
+        if (InspectorPageAgent::sharedBufferContent(resourceData->buffer(), resourceData->textEncodingName(), base64Encode, content))
+            return;
+    }
+
+    if (!resourceData->frameId().isNull() && !resourceData->url().isNull())
         m_pageAgent->getResourceContent(errorString, resourceData->frameId(), resourceData->url(), optionalBase64Encode, content);
     else
         *errorString = "No data found for resource with given identifier";

Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.h (89162 => 89163)


--- trunk/Source/WebCore/inspector/InspectorResourceAgent.h	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.h	2011-06-17 20:00:33 UTC (rev 89163)
@@ -91,8 +91,8 @@
     void markResourceAsCached(unsigned long identifier);
     void didReceiveResponse(unsigned long identifier, DocumentLoader* laoder, const ResourceResponse&);
     void didReceiveContentLength(unsigned long identifier, int dataLength, int encodedDataLength);
-    void didFinishLoading(unsigned long identifier, double finishTime);
-    void didFailLoading(unsigned long identifier, const ResourceError&);
+    void didFinishLoading(unsigned long identifier, DocumentLoader*, double finishTime);
+    void didFailLoading(unsigned long identifier, DocumentLoader*, const ResourceError&);
     void didLoadResourceFromMemoryCache(DocumentLoader*, const CachedResource*);
     void mainFrameNavigated(DocumentLoader*);
     void setInitialScriptContent(unsigned long identifier, const String& sourceString);

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (89162 => 89163)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2011-06-17 20:00:33 UTC (rev 89163)
@@ -1069,7 +1069,7 @@
         return false;
 
     String error;
-    InspectorPageAgent::resourceContent(&error, ownerDocument()->frame(), m_pageStyleSheet->finalURL(), result);
+    InspectorPageAgent::resourceContent(&error, ownerDocument()->frame(), m_pageStyleSheet->finalURL(), false, result);
     return error.isEmpty();
 }
 

Modified: trunk/Source/WebCore/inspector/NetworkResourcesData.cpp (89162 => 89163)


--- trunk/Source/WebCore/inspector/NetworkResourcesData.cpp	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/NetworkResourcesData.cpp	2011-06-17 20:00:33 UTC (rev 89163)
@@ -43,8 +43,8 @@
     : m_identifier(identifier)
     , m_loaderId(loaderId)
     , m_hasContent(false)
-    , m_isXHR(false)
     , m_isContentPurged(false)
+    , m_type(InspectorPageAgent::OtherResource)
 {
 }
 
@@ -94,14 +94,22 @@
     resourceData->setUrl(url);
 }
 
-void NetworkResourcesData::didReceiveXHRResponse(unsigned long identifier)
+void NetworkResourcesData::setResourceType(unsigned long identifier, InspectorPageAgent::ResourceType type)
 {
     ResourceData* resourceData = m_identifierToResourceDataMap.get(identifier);
     if (!resourceData)
         return;
-    resourceData->setIsXHR(true);
+    resourceData->setType(type);
 }
 
+InspectorPageAgent::ResourceType NetworkResourcesData::resourceType(unsigned long identifier)
+{
+    ResourceData* resourceData = m_identifierToResourceDataMap.get(identifier);
+    if (!resourceData)
+        return InspectorPageAgent::OtherResource;
+    return resourceData->type();
+}
+
 void NetworkResourcesData::addResourceContent(unsigned long identifier, const String& content)
 {
     ResourceData* resourceData = m_identifierToResourceDataMap.get(identifier);
@@ -117,12 +125,13 @@
     }
 }
 
-bool NetworkResourcesData::isXHR(unsigned long identifier)
+void NetworkResourcesData::addResourceSharedBuffer(unsigned long identifier, PassRefPtr<SharedBuffer> buffer, const String& textEncodingName)
 {
     ResourceData* resourceData = m_identifierToResourceDataMap.get(identifier);
     if (!resourceData)
-        return false;
-    return resourceData->isXHR();
+        return;
+    resourceData->setBuffer(buffer);
+    resourceData->setTextEncodingName(textEncodingName);
 }
 
 NetworkResourcesData::ResourceData* NetworkResourcesData::data(unsigned long identifier)

Modified: trunk/Source/WebCore/inspector/NetworkResourcesData.h (89162 => 89163)


--- trunk/Source/WebCore/inspector/NetworkResourcesData.h	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/inspector/NetworkResourcesData.h	2011-06-17 20:00:33 UTC (rev 89163)
@@ -29,8 +29,13 @@
 #ifndef NetworkResourcesData_h
 #define NetworkResourcesData_h
 
+#include "CachedResourceHandle.h"
+#include "InspectorPageAgent.h"
+#include "SharedBuffer.h"
+
 #include <wtf/Deque.h>
 #include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
 #include <wtf/text/StringBuilder.h>
 #include <wtf/text/WTFString.h>
 
@@ -38,6 +43,9 @@
 
 namespace WebCore {
 
+class SharedBuffer;
+class CachedResource;
+
 class NetworkResourcesData {
 public:
     class ResourceData {
@@ -53,9 +61,6 @@
         String url() const { return m_url; }
         void setUrl(String url) { m_url = url; }
 
-        bool isXHR() const { return m_isXHR; }
-        void setIsXHR(bool isXHR) { m_isXHR = isXHR; }
-
         bool hasContent() const { return m_hasContent; }
         String content();
         void appendContent(const String&);
@@ -64,6 +69,15 @@
         void setIsContentPurged(bool isContentPurged) { m_isContentPurged = isContentPurged; }
         unsigned purgeContent();
 
+        InspectorPageAgent::ResourceType type() const { return m_type; }
+        void setType(InspectorPageAgent::ResourceType type) { m_type = type; }
+
+        PassRefPtr<SharedBuffer> buffer() const { return m_buffer; }
+        void setBuffer(PassRefPtr<SharedBuffer> buffer) { m_buffer = buffer; }
+
+        String textEncodingName() const { return m_textEncodingName; }
+        void setTextEncodingName(String textEncodingName) { m_textEncodingName = textEncodingName; }
+
     private:
         unsigned long m_identifier;
         String m_loaderId;
@@ -71,8 +85,11 @@
         String m_url;
         bool m_hasContent;
         StringBuilder m_contentBuilder;
-        bool m_isXHR;
         bool m_isContentPurged;
+        InspectorPageAgent::ResourceType m_type;
+
+        RefPtr<SharedBuffer> m_buffer;
+        String m_textEncodingName;
     };
 
     NetworkResourcesData();
@@ -81,10 +98,10 @@
 
     void resourceCreated(unsigned long identifier, const String& loaderId);
     void responseReceived(unsigned long identifier, const String& frameId, const String& url);
-    void didReceiveXHRResponse(unsigned long identifier);
+    void setResourceType(unsigned long identifier, InspectorPageAgent::ResourceType);
+    InspectorPageAgent::ResourceType resourceType(unsigned long identifier);
     void addResourceContent(unsigned long identifier, const String& content);
-
-    bool isXHR(unsigned long identifier);
+    void addResourceSharedBuffer(unsigned long identifier, PassRefPtr<SharedBuffer>, const String& textEncodingName);
     ResourceData* data(unsigned long identifier);
     void clear(const String& preservedLoaderId = String());
 

Modified: trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp (89162 => 89163)


--- trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp	2011-06-17 20:00:33 UTC (rev 89163)
@@ -97,7 +97,7 @@
     if (!error.isNull())
         m_frame->loader()->client()->dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error);
 
-    InspectorInstrumentation::didFailLoading(m_frame, loader->identifier(), error);
+    InspectorInstrumentation::didFailLoading(m_frame, loader->documentLoader(), loader->identifier(), error);
 }
 
 void ResourceLoadNotifier::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
@@ -141,7 +141,7 @@
 {
     m_frame->loader()->client()->dispatchDidFinishLoading(loader, identifier);
 
-    InspectorInstrumentation::didFinishLoading(m_frame, identifier, finishTime);
+    InspectorInstrumentation::didFinishLoading(m_frame, loader, identifier, finishTime);
 }
 
 void ResourceLoadNotifier::dispatchTransferLoadingResourceFromPage(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, Page* oldPage)

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp (89162 => 89163)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp	2011-06-17 19:51:13 UTC (rev 89162)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp	2011-06-17 20:00:33 UTC (rev 89163)
@@ -590,7 +590,7 @@
 void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double finishTime)
 {
 #if ENABLE(INSPECTOR)
-    InspectorInstrumentation::didFinishLoading(m_frame, m_currentResourceIdentifier, finishTime);
+    InspectorInstrumentation::didFinishLoading(m_frame, m_frame->loader()->documentLoader(), m_currentResourceIdentifier, finishTime);
 #endif
 
     if (handle == m_manifestHandle) {
@@ -631,7 +631,7 @@
 void ApplicationCacheGroup::didFail(ResourceHandle* handle, const ResourceError& error)
 {
 #if ENABLE(INSPECTOR)
-    InspectorInstrumentation::didFailLoading(m_frame, m_currentResourceIdentifier, error);
+    InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader()->documentLoader(), m_currentResourceIdentifier, error);
 #endif
 
     if (handle == m_manifestHandle) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to