2010-11-01 Jenn Braithwaite <jennb@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Nov 2010 02:42:26 +0000 (02:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Nov 2010 02:42:26 +0000 (02:42 +0000)
        Reviewed by Adam Roben.

        Windows: Update resource tracking when moving a frame between documents
        https://bugs.webkit.org/show_bug.cgi?id=48364

        * Interfaces/IWebResourceLoadDelegatePrivate2.idl:Added
        Added removeIdentifierForRequest.
        * Interfaces/WebKit.idl:
        Added IWebResourceLoadDelegatePrivate2.idl.
        * WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebFrameLoaderClient::transferLoadingResourceFromPage):
2010-11-01  Jenn Braithwaite  <jennb@chromium.org>

        Reviewed by Adam Roben.

        Windows: Update resource tracking when moving a frame between documents
        https://bugs.webkit.org/show_bug.cgi?id=48364

        * DumpRenderTree/win/DumpRenderTree.cpp:
        (createWebViewAndOffscreenWindow):
        (main):
        Give each WebView its own ResourceLoadDelegate instance in order to
        make assertions about resource ids on a particular WebView.
        * DumpRenderTree/win/ResourceLoadDelegate.cpp:
        (ResourceLoadDelegate::identifierForInitialRequest):
        Always add id to the map.
        (ResourceLoadDelegate::removeIdentifierForRequest):
        Added.
        (ResourceLoadDelegate::willSendRequest):
        (ResourceLoadDelegate::didReceiveAuthenticationChallenge):
        (ResourceLoadDelegate::didReceiveResponse):
        (ResourceLoadDelegate::didFinishLoadingFromDataSource):
        (ResourceLoadDelegate::didFailLoadingWithError):
        (ResourceLoadDelegate::descriptionSuitableForTestResult):
        Replace static descriptionSuitableForTestResult with static member function to access identifier map.
        * DumpRenderTree/win/ResourceLoadDelegate.h:
        (ResourceLoadDelegate::urlMap):
        Moved within class so that each WebView has its own id map.

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

WebKit/win/ChangeLog
WebKit/win/Interfaces/IWebResourceLoadDelegatePrivate2.idl [new file with mode: 0644]
WebKit/win/Interfaces/WebKit.idl
WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp
WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h

index cb65428..cc63f38 100644 (file)
@@ -1,3 +1,17 @@
+2010-11-01  Jenn Braithwaite  <jennb@chromium.org>
+
+        Reviewed by Adam Roben.
+
+        Windows: Update resource tracking when moving a frame between documents
+        https://bugs.webkit.org/show_bug.cgi?id=48364
+
+        * Interfaces/IWebResourceLoadDelegatePrivate2.idl:Added
+        Added removeIdentifierForRequest.
+        * Interfaces/WebKit.idl:
+        Added IWebResourceLoadDelegatePrivate2.idl.
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::transferLoadingResourceFromPage):
+
 2010-11-01  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Anders Carlsson.
diff --git a/WebKit/win/Interfaces/IWebResourceLoadDelegatePrivate2.idl b/WebKit/win/Interfaces/IWebResourceLoadDelegatePrivate2.idl
new file mode 100644 (file)
index 0000000..7e98e6a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DO_NO_IMPORTS
+import "oaidl.idl";
+import "ocidl.idl";
+import "IWebView.idl";
+#endif
+
+interface IWebView;
+
+[
+    object,
+    oleautomation,
+    uuid(3517ADDA-5870-4aab-9A4E-056E65989DF8),
+    pointer_default(unique)
+]
+interface IWebResourceLoadDelegatePrivate2 : IUnknown
+{
+    /*!
+        @method webView:removeIdentifierForRequest
+        @param webView The WebView sending the message.
+        @param identifier An identifier that can be used to track the progress of a resource load across
+        multiple call backs.
+        @discussion This message is sent to notify the delegate to stop using the identifier
+        to track the progress of a resource load.
+        - (void)webView:(WebView *)sender removeIdentifierForRequest:(id)identifier;
+    */
+    HRESULT removeIdentifierForRequest([in] IWebView* webView, [in] unsigned long identifier);
+}
index 37a9ead..3f401be 100644 (file)
@@ -117,6 +117,7 @@ import "ocidl.idl";
 #include "IWebResource.idl"
 #include "IWebResourceLoadDelegate.idl"
 #include "IWebResourceLoadDelegatePrivate.idl"
+#include "IWebResourceLoadDelegatePrivate2.idl"
 #include "IWebScriptWorld.idl"
 #include "IWebScrollBarDelegatePrivate.idl"
 #include "IWebScrollBarPrivate.idl"
index 7d5a1cc..a77c6fb 100644 (file)
@@ -747,8 +747,22 @@ void WebFrameLoaderClient::didTransferChildFrameToNewDocument(Page*)
         m_webFrame->setWebView(webView);
 }
 
-void WebFrameLoaderClient::transferLoadingResourceFromPage(unsigned long, DocumentLoader*, const ResourceRequest&, Page*)
+void WebFrameLoaderClient::transferLoadingResourceFromPage(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, Page* oldPage)
 {
+    assignIdentifierToInitialRequest(identifier, loader, request);
+
+    WebView* oldWebView = kit(oldPage);
+    if (!oldWebView)
+        return;
+
+    COMPtr<IWebResourceLoadDelegate> oldResourceLoadDelegate;
+    if (FAILED(oldWebView->resourceLoadDelegate(&oldResourceLoadDelegate)))
+        return;
+
+    COMPtr<IWebResourceLoadDelegatePrivate2> oldResourceLoadDelegatePrivate2(Query, oldResourceLoadDelegate);
+    if (!oldResourceLoadDelegatePrivate2)
+        return;
+    oldResourceLoadDelegatePrivate2->removeIdentifierForRequest(oldWebView, identifier);
 }
 
 PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& URL, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer)
index c8b51f5..0413cda 100644 (file)
@@ -1,3 +1,31 @@
+2010-11-01  Jenn Braithwaite  <jennb@chromium.org>
+
+        Reviewed by Adam Roben.
+
+        Windows: Update resource tracking when moving a frame between documents
+        https://bugs.webkit.org/show_bug.cgi?id=48364
+
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (createWebViewAndOffscreenWindow):
+        (main):
+        Give each WebView its own ResourceLoadDelegate instance in order to
+        make assertions about resource ids on a particular WebView.
+        * DumpRenderTree/win/ResourceLoadDelegate.cpp:
+        (ResourceLoadDelegate::identifierForInitialRequest):
+        Always add id to the map.
+        (ResourceLoadDelegate::removeIdentifierForRequest):
+        Added.
+        (ResourceLoadDelegate::willSendRequest):
+        (ResourceLoadDelegate::didReceiveAuthenticationChallenge):
+        (ResourceLoadDelegate::didReceiveResponse):
+        (ResourceLoadDelegate::didFinishLoadingFromDataSource):
+        (ResourceLoadDelegate::didFailLoadingWithError):
+        (ResourceLoadDelegate::descriptionSuitableForTestResult):
+        Replace static descriptionSuitableForTestResult with static member function to access identifier map.
+        * DumpRenderTree/win/ResourceLoadDelegate.h:
+        (ResourceLoadDelegate::urlMap):
+        Moved within class so that each WebView has its own id map.
+
 2010-11-01  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Dimitri Glazkov.
index 5138562..7c3d9b3 100644 (file)
@@ -98,7 +98,6 @@ PolicyDelegate* policyDelegate;
 COMPtr<FrameLoadDelegate> sharedFrameLoadDelegate;
 COMPtr<UIDelegate> sharedUIDelegate;
 COMPtr<EditingDelegate> sharedEditingDelegate;
-COMPtr<ResourceLoadDelegate> sharedResourceLoadDelegate;
 COMPtr<HistoryDelegate> sharedHistoryDelegate;
 
 IWebFrame* frame;
@@ -1201,7 +1200,10 @@ IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow)
     if (FAILED(viewEditing->setEditingDelegate(sharedEditingDelegate.get())))
         return 0;
 
-    if (FAILED(webView->setResourceLoadDelegate(sharedResourceLoadDelegate.get())))
+    ResourceLoadDelegate* resourceLoadDelegate = new ResourceLoadDelegate();
+    HRESULT result = webView->setResourceLoadDelegate(resourceLoadDelegate);
+    resourceLoadDelegate->Release(); // The delegate is owned by the WebView, so release our reference to it.
+    if (FAILED(result))
         return 0;
 
     openWindows().append(hostWindow);
@@ -1285,7 +1287,6 @@ int main(int argc, char* argv[])
     sharedFrameLoadDelegate.adoptRef(new FrameLoadDelegate);
     sharedUIDelegate.adoptRef(new UIDelegate);
     sharedEditingDelegate.adoptRef(new EditingDelegate);
-    sharedResourceLoadDelegate.adoptRef(new ResourceLoadDelegate);
     sharedHistoryDelegate.adoptRef(new HistoryDelegate);
 
     // FIXME - need to make DRT pass with Windows native controls <http://bugs.webkit.org/show_bug.cgi?id=25592>
index 825366a..cf17987 100644 (file)
@@ -35,7 +35,6 @@
 #include <comutil.h>
 #include <sstream>
 #include <tchar.h>
-#include <wtf/HashMap.h>
 #include <wtf/Vector.h>
 
 using namespace std;
@@ -60,26 +59,17 @@ static inline BSTR BSTRFromString(const string& str)
     return result;
 }
 
-typedef HashMap<unsigned long, wstring> IdentifierMap;
-
-IdentifierMap& urlMap()
-{
-    static IdentifierMap urlMap;
-
-    return urlMap;
-}
-
-static wstring descriptionSuitableForTestResult(unsigned long identifier)
+wstring ResourceLoadDelegate::descriptionSuitableForTestResult(unsigned long identifier) const
 {
-    IdentifierMap::iterator it = urlMap().find(identifier);
+    IdentifierMap::const_iterator it = m_urlMap.find(identifier);
     
-    if (it == urlMap().end())
+    if (it == m_urlMap.end())
         return L"<unknown>";
 
     return urlSuitableForTestResult(it->second);
 }
 
-static wstring descriptionSuitableForTestResult(IWebURLRequest* request)
+wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLRequest* request)
 {
     if (!request)
         return L"(null)";
@@ -108,7 +98,7 @@ static wstring descriptionSuitableForTestResult(IWebURLRequest* request)
     return L"<NSURLRequest URL " + url + L", main document URL " + mainDocumentURL + L", http method " + httpMethod + L">";
 }
 
-static wstring descriptionSuitableForTestResult(IWebURLResponse* response)
+wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLResponse* response)
 {
     if (!response)
         return L"(null)";
@@ -128,7 +118,7 @@ static wstring descriptionSuitableForTestResult(IWebURLResponse* response)
     return L"<NSURLResponse " + url + L", http status code " + wstringFromInt(statusCode) + L">";
 }
 
-static wstring descriptionSuitableForTestResult(IWebError* error, unsigned long identifier)
+wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebError* error, unsigned long identifier) const
 {
     wstring result = L"<NSError ";
 
@@ -197,6 +187,8 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::QueryInterface(REFIID riid, void
         *ppvObject = static_cast<IWebResourceLoadDelegate*>(this);
     else if (IsEqualGUID(riid, IID_IWebResourceLoadDelegate))
         *ppvObject = static_cast<IWebResourceLoadDelegate*>(this);
+    else if (IsEqualGUID(riid, IID_IWebResourceLoadDelegatePrivate2))
+        *ppvObject = static_cast<IWebResourceLoadDelegatePrivate2*>(this);
     else
         return E_NOINTERFACE;
 
@@ -224,17 +216,30 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::identifierForInitialRequest(
     /* [in] */ IWebDataSource* dataSource,
     /* [in] */ unsigned long identifier)
 { 
-    if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) {
+    if (!done) {
         BSTR urlStr;
         if (FAILED(request->URL(&urlStr)))
             return E_FAIL;
 
+        ASSERT(!urlMap().contains(identifier));
         urlMap().set(identifier, wstringFromBSTR(urlStr));
     }
 
     return S_OK;
 }
 
+HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::removeIdentifierForRequest(
+    /* [in] */ IWebView* webView,
+    /* [in] */ unsigned long identifier)
+{
+    if (!done) {
+        ASSERT(urlMap().contains(identifier));
+        urlMap().remove(identifier);
+    }
+
+    return S_OK;
+}
+
 HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::willSendRequest( 
     /* [in] */ IWebView* webView,
     /* [in] */ unsigned long identifier,
@@ -351,11 +356,12 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFinishLoadingFromDataSource(
 {
     if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) {
         printf("%S - didFinishLoading\n",
-            descriptionSuitableForTestResult(identifier).c_str()),
-       urlMap().remove(identifier);
+            descriptionSuitableForTestResult(identifier).c_str());
     }
 
-   return S_OK;
+    removeIdentifierForRequest(webView, identifier);
+
+    return S_OK;
 }
         
 HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFailLoadingWithError( 
@@ -368,8 +374,9 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFailLoadingWithError(
         printf("%S - didFailLoadingWithError: %S\n", 
             descriptionSuitableForTestResult(identifier).c_str(),
             descriptionSuitableForTestResult(error, identifier).c_str());
-        urlMap().remove(identifier);
     }
 
+    removeIdentifierForRequest(webView, identifier);
+
     return S_OK;
 }
index 924727b..3f20f47 100644 (file)
 #define ResourceLoadDelegate_h
 
 #include <WebKit/WebKit.h>
+#include <string>
+#include <wtf/HashMap.h>
 
-class ResourceLoadDelegate : public IWebResourceLoadDelegate {
+class ResourceLoadDelegate : public IWebResourceLoadDelegate, public IWebResourceLoadDelegatePrivate2 {
 public:
     ResourceLoadDelegate();
     virtual ~ResourceLoadDelegate();
@@ -95,8 +97,22 @@ public:
         /* [in] */ IWebView *webView,
         /* [in] */ IWebError *error,
         /* [in] */ IWebDataSource *dataSource) { return E_NOTIMPL; }
+
+    // IWebResourceLoadDelegatePrivate2
+    virtual HRESULT STDMETHODCALLTYPE removeIdentifierForRequest(
+        /* [in] */ IWebView *webView,
+        /* [in] */ unsigned long identifier);
     
-protected:
+private:
+    static std::wstring descriptionSuitableForTestResult(IWebURLRequest*);
+    static std::wstring descriptionSuitableForTestResult(IWebURLResponse*);
+    std::wstring descriptionSuitableForTestResult(unsigned long) const;
+    std::wstring descriptionSuitableForTestResult(IWebError*, unsigned long) const;
+
+    typedef HashMap<unsigned long, std::wstring> IdentifierMap;
+    IdentifierMap& urlMap() { return m_urlMap; }
+    IdentifierMap m_urlMap;
+
     ULONG m_refCount;
 };