2009-11-27 Yury Semikhatsky <yurys@chromium.org>
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Nov 2009 13:07:06 +0000 (13:07 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Nov 2009 13:07:06 +0000 (13:07 +0000)
        Reviewed by Pavel Feldman.

        This is a WebCore part of the fix that allows to view plugin
        resources loaded by plugins.

        https://bugs.webkit.org/show_bug.cgi?id=31832

        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::willSendRequest):
        (WebCore::InspectorController::didReceiveResponse):
        (WebCore::InspectorController::didReceiveContentLength):
        (WebCore::InspectorController::didFinishLoading):
        (WebCore::InspectorController::didFailLoading):
        * inspector/InspectorController.h:
        * inspector/InspectorResource.cpp:
        (WebCore::InspectorResource::addLength):
        * loader/ResourceLoadNotifier.cpp:
        (WebCore::ResourceLoadNotifier::didFailToLoad):
        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
        (WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
        (WebCore::ResourceLoadNotifier::dispatchDidReceiveContentLength):
        (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
2009-11-27  Yury Semikhatsky  <yurys@chromium.org>

        Reviewed by Pavel Feldman.

        WebCore part of the fix that allows to view plugin
        resources loaded by plugins. Methods that for resource
        loading notifications are exposed through WebDevToolsAgent
        interface to the glue code to allow Chromium's plugin
        implementation to notify InspectorController about resource
        loading in plugins.

        https://bugs.webkit.org/show_bug.cgi?id=31832

        * public/WebDevToolsAgent.h:
        * public/WebView.h:
        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::createUniqueIdentifierForRequest):
        * src/WebViewImpl.h:

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

WebCore/ChangeLog
WebCore/inspector/InspectorController.cpp
WebCore/inspector/InspectorController.h
WebCore/inspector/InspectorResource.cpp
WebCore/loader/ResourceLoadNotifier.cpp
WebKit/chromium/ChangeLog
WebKit/chromium/public/WebDevToolsAgent.h
WebKit/chromium/public/WebView.h
WebKit/chromium/src/WebViewImpl.cpp
WebKit/chromium/src/WebViewImpl.h

index 858cda971e28da65f1c203801debc1c1aa58f7d3..7185279fa1fc0753de73601e3c4504ace8563a8c 100644 (file)
@@ -1,3 +1,28 @@
+2009-11-27  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        This is a WebCore part of the fix that allows to view plugin
+        resources loaded by plugins.
+
+        https://bugs.webkit.org/show_bug.cgi?id=31832
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::willSendRequest):
+        (WebCore::InspectorController::didReceiveResponse):
+        (WebCore::InspectorController::didReceiveContentLength):
+        (WebCore::InspectorController::didFinishLoading):
+        (WebCore::InspectorController::didFailLoading):
+        * inspector/InspectorController.h:
+        * inspector/InspectorResource.cpp:
+        (WebCore::InspectorResource::addLength):
+        * loader/ResourceLoadNotifier.cpp:
+        (WebCore::ResourceLoadNotifier::didFailToLoad):
+        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
+        (WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
+        (WebCore::ResourceLoadNotifier::dispatchDidReceiveContentLength):
+        (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
+
 2009-11-27  Yury Semikhatsky  <yurys@chromium.org>
 
         Reviewed by Pavel Feldman.
index 6d87b25d19ad135151c54d1a2b6cf92f5fabcef5..2fd702f0522356be4b92c8677a84149470ed1afc 100644 (file)
@@ -939,10 +939,11 @@ bool InspectorController::isMainResourceLoader(DocumentLoader* loader, const KUR
     return loader->frame() == m_inspectedPage->mainFrame() && requestUrl == loader->requestURL();
 }
 
-void InspectorController::willSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void InspectorController::willSendRequest(unsigned long identifier, const ResourceRequest& request, const ResourceResponse& redirectResponse)
 {
+    bool isMainResource = (m_mainResource && m_mainResource->identifier() == identifier);
     if (m_timelineAgent)
-        m_timelineAgent->willSendResourceRequest(identifier, isMainResourceLoader(loader, request.url()), request);
+        m_timelineAgent->willSendResourceRequest(identifier, isMainResource, request);
 
     RefPtr<InspectorResource> resource = getTrackedResource(identifier);
     if (!resource)
@@ -959,7 +960,7 @@ void InspectorController::willSendRequest(DocumentLoader* loader, unsigned long
         resource->createScriptObject(m_frontend.get());
 }
 
-void InspectorController::didReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse& response)
+void InspectorController::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
 {
     if (m_timelineAgent)
         m_timelineAgent->didReceiveResourceResponse(identifier, response);
@@ -975,7 +976,7 @@ void InspectorController::didReceiveResponse(DocumentLoader*, unsigned long iden
         resource->updateScriptObject(m_frontend.get());
 }
 
-void InspectorController::didReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived)
+void InspectorController::didReceiveContentLength(unsigned long identifier, int lengthReceived)
 {
     RefPtr<InspectorResource> resource = getTrackedResource(identifier);
     if (!resource)
@@ -987,7 +988,7 @@ void InspectorController::didReceiveContentLength(DocumentLoader*, unsigned long
         resource->updateScriptObject(m_frontend.get());
 }
 
-void InspectorController::didFinishLoading(DocumentLoader*, unsigned long identifier)
+void InspectorController::didFinishLoading(unsigned long identifier)
 {
     if (m_timelineAgent)
         m_timelineAgent->didFinishLoadingResource(identifier, false);
@@ -1006,7 +1007,7 @@ void InspectorController::didFinishLoading(DocumentLoader*, unsigned long identi
         resource->updateScriptObject(m_frontend.get());
 }
 
-void InspectorController::didFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError& /*error*/)
+void InspectorController::didFailLoading(unsigned long identifier, const ResourceError& /*error*/)
 {
     if (m_timelineAgent)
         m_timelineAgent->didFinishLoadingResource(identifier, true);
index 7b638c33dd0d5328d76b6a7bfa71dd9d9968a28e..d3ea5719a2f8bf011cd2cc631d637585dd5a8883 100644 (file)
@@ -216,11 +216,11 @@ public:
     void didLoadResourceFromMemoryCache(DocumentLoader*, const CachedResource*);
 
     void identifierForInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
-    void willSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
-    void didReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&);
-    void didReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived);
-    void didFinishLoading(DocumentLoader*, unsigned long identifier);
-    void didFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&);
+    void willSendRequest(unsigned long identifier, const ResourceRequest&, const ResourceResponse& redirectResponse);
+    void didReceiveResponse(unsigned long identifier, const ResourceResponse&);
+    void didReceiveContentLength(unsigned long identifier, int lengthReceived);
+    void didFinishLoading(unsigned long identifier);
+    void didFailLoading(unsigned long identifier, const ResourceError&);
     void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
     void scriptImported(unsigned long identifier, const String& sourceString);
 
index fac81b3fd380b35709c7f031c61dade4f68f9e5f..0a4cb73abaf0e88c5a6ba25e3b38daaa8e985607 100644 (file)
@@ -381,6 +381,12 @@ void InspectorResource::addLength(int lengthReceived)
 {
     m_length += lengthReceived;
     m_changes.set(LengthChange);
+
+    // Update load time, otherwise the resource will
+    // have start time == end time and  0 load duration
+    // until its loading is completed.
+    m_endTime = currentTime();
+    m_changes.set(TimingChange);
 }
 
 } // namespace WebCore
index 4cddd01c39abe21890211f33b80e2bfef1e4acac..92804345b3dbdce65e2692b52cfc8aa36c8d754a 100644 (file)
@@ -96,6 +96,11 @@ void ResourceLoadNotifier::didFailToLoad(ResourceLoader* loader, const ResourceE
 
     if (!error.isNull())
         m_frame->loader()->client()->dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error);
+
+#if ENABLE(INSPECTOR)
+    if (Page* page = m_frame->page())
+        page->inspectorController()->didFailLoading(loader->identifier(), error);
+#endif
 }
 
 void ResourceLoadNotifier::didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString)
@@ -126,7 +131,7 @@ void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsig
 
 #if ENABLE(INSPECTOR)
     if (Page* page = m_frame->page())
-        page->inspectorController()->willSendRequest(loader, identifier, request, redirectResponse);
+        page->inspectorController()->willSendRequest(identifier, request, redirectResponse);
 #endif
 }
 
@@ -136,7 +141,7 @@ void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, un
 
 #if ENABLE(INSPECTOR)
     if (Page* page = m_frame->page())
-        page->inspectorController()->didReceiveResponse(loader, identifier, r);
+        page->inspectorController()->didReceiveResponse(identifier, r);
 #endif
 }
 
@@ -146,7 +151,7 @@ void ResourceLoadNotifier::dispatchDidReceiveContentLength(DocumentLoader* loade
 
 #if ENABLE(INSPECTOR)
     if (Page* page = m_frame->page())
-        page->inspectorController()->didReceiveContentLength(loader, identifier, length);
+        page->inspectorController()->didReceiveContentLength(identifier, length);
 #endif
 }
 
@@ -156,7 +161,7 @@ void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsi
 
 #if ENABLE(INSPECTOR)
     if (Page* page = m_frame->page())
-        page->inspectorController()->didFinishLoading(loader, identifier);
+        page->inspectorController()->didFinishLoading(identifier);
 #endif
 }
 
index 0e7a2bc5ac83453f4e6da494b8a8363d23c9171e..29a23c14cea042d12cdd8b03feabcd327bdd48df 100644 (file)
@@ -1,3 +1,22 @@
+2009-11-27  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        WebCore part of the fix that allows to view plugin
+        resources loaded by plugins. Methods that for resource
+        loading notifications are exposed through WebDevToolsAgent
+        interface to the glue code to allow Chromium's plugin
+        implementation to notify InspectorController about resource
+        loading in plugins.
+
+        https://bugs.webkit.org/show_bug.cgi?id=31832
+
+        * public/WebDevToolsAgent.h:
+        * public/WebView.h:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::createUniqueIdentifierForRequest):
+        * src/WebViewImpl.h:
+
 2009-11-26  Yury Semikhatsky  <yurys@chromium.org>
 
         Not reviewed. Build fix: revert r51421.
index cf4d7eafeddbedab68f235bc531f3def653ed747..4a44cb0de8ae09a699ccff50bdef4d515f93fe3e 100644 (file)
 
 namespace WebKit {
 class WebDevToolsAgentClient;
+class WebFrame;
 class WebString;
+class WebURLRequest;
+class WebURLResponse;
 class WebView;
 struct WebPoint;
+struct WebURLError;
 
 class WebDevToolsAgent {
 public:
@@ -70,6 +74,13 @@ public:
     // Installs dispatch handle that is going to be called periodically
     // while on a breakpoint.
     WEBKIT_API static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler);
+
+    virtual void identifierForInitialRequest(unsigned long resourceId, WebFrame*, const WebURLRequest&) = 0;
+    virtual void willSendRequest(unsigned long resourceId, const WebURLRequest&) = 0;
+    virtual void didReceiveData(unsigned long resourceId, int length) = 0;
+    virtual void didReceiveResponse(unsigned long resourceId, const WebURLResponse&) = 0;
+    virtual void didFinishLoading(unsigned long resourceId) = 0;
+    virtual void didFailLoading(unsigned long resourceId, const WebURLError&) = 0;
 };
 
 } // namespace WebKit
index 8261afc5a95ac7f488bd6fe38aeeff55088b6e2b..29a3f9e209dde32505ff514d75ce93e95878d1a9 100644 (file)
@@ -191,6 +191,13 @@ public:
     virtual bool setDropEffect(bool accept) = 0;
 
 
+    // Support for resource loading initiated by plugins -------------------
+
+    // Returns next unused request identifier which is unique within the
+    // parent Page.
+    virtual unsigned long createUniqueIdentifierForRequest() = 0;
+
+
     // Developer tools -----------------------------------------------------
 
     // Inspect a particular point in the WebView.  (x = -1 || y = -1) is a
index aaf717472c4d6317094183fe068686c610e6c187..7914a9ee8f1069ebdce64298a2c6d504f250ca94 100644 (file)
@@ -70,6 +70,7 @@
 #include "PluginInfoStore.h"
 #include "PopupMenuChromium.h"
 #include "PopupMenuClient.h"
+#include "ProgressTracker.h"
 #include "RenderView.h"
 #include "ResourceHandle.h"
 #include "SecurityOrigin.h"
@@ -1475,6 +1476,12 @@ int WebViewImpl::dragIdentity()
     return 0;
 }
 
+unsigned long WebViewImpl::createUniqueIdentifierForRequest() {
+    if (m_page)
+        return m_page->progress()->createUniqueIdentifier();
+    return 0;
+}
+
 void WebViewImpl::inspectElementAt(const WebPoint& point)
 {
     if (!m_page.get())
index 2b83a8e84bfd9b2db039414942d2f69cbf6d90f8..96227e3cf9f0b40e781e6c4843a2fe93675212e6 100644 (file)
@@ -143,6 +143,7 @@ public:
         const WebPoint& screenPoint);
     virtual int dragIdentity();
     virtual bool setDropEffect(bool accept);
+    virtual unsigned long createUniqueIdentifierForRequest();
     virtual void inspectElementAt(const WebPoint& point);
     virtual WebString inspectorSettings() const;
     virtual void setInspectorSettings(const WebString& settings);