Title: [158867] trunk/Source/WebCore
Revision
158867
Author
[email protected]
Date
2013-11-07 13:37:36 -0800 (Thu, 07 Nov 2013)

Log Message

Use std::function for all policy continuation functions
https://bugs.webkit.org/show_bug.cgi?id=124011

Reviewed by Sam Weinig.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::willSendRequest):
(WebCore::DocumentLoader::responseReceived):
* loader/DocumentLoader.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::load):
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::FrameLoader::loadPostRequest):
* loader/PolicyCallback.cpp:
(WebCore::PolicyCallback::clear):
(WebCore::PolicyCallback::set):
(WebCore::PolicyCallback::call):
(WebCore::PolicyCallback::clearRequest):
(WebCore::PolicyCallback::cancel):
* loader/PolicyCallback.h:
* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNavigationPolicy):
(WebCore::PolicyChecker::checkNewWindowPolicy):
(WebCore::PolicyChecker::checkContentPolicy):
* loader/PolicyChecker.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158866 => 158867)


--- trunk/Source/WebCore/ChangeLog	2013-11-07 21:30:58 UTC (rev 158866)
+++ trunk/Source/WebCore/ChangeLog	2013-11-07 21:37:36 UTC (rev 158867)
@@ -1,3 +1,32 @@
+2013-11-07  Anders Carlsson  <[email protected]>
+
+        Use std::function for all policy continuation functions
+        https://bugs.webkit.org/show_bug.cgi?id=124011
+
+        Reviewed by Sam Weinig.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::willSendRequest):
+        (WebCore::DocumentLoader::responseReceived):
+        * loader/DocumentLoader.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadURL):
+        (WebCore::FrameLoader::load):
+        (WebCore::FrameLoader::loadWithDocumentLoader):
+        (WebCore::FrameLoader::loadPostRequest):
+        * loader/PolicyCallback.cpp:
+        (WebCore::PolicyCallback::clear):
+        (WebCore::PolicyCallback::set):
+        (WebCore::PolicyCallback::call):
+        (WebCore::PolicyCallback::clearRequest):
+        (WebCore::PolicyCallback::cancel):
+        * loader/PolicyCallback.h:
+        * loader/PolicyChecker.cpp:
+        (WebCore::PolicyChecker::checkNavigationPolicy):
+        (WebCore::PolicyChecker::checkNewWindowPolicy):
+        (WebCore::PolicyChecker::checkContentPolicy):
+        * loader/PolicyChecker.h:
+
 2013-11-07  Brady Eidson  <[email protected]>
 
         Use SQLite journal mode WAL (WriteAheadLogging)

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (158866 => 158867)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-11-07 21:30:58 UTC (rev 158866)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-11-07 21:37:36 UTC (rev 158867)
@@ -527,13 +527,12 @@
     // listener. But there's no way to do that in practice. So instead we cancel later if the
     // listener tells us to. In practice that means the navigation policy needs to be decided
     // synchronously for these redirect cases.
-    if (!redirectResponse.isNull())
-        frameLoader()->policyChecker().checkNavigationPolicy(newRequest, callContinueAfterNavigationPolicy, this);
-}
+    if (redirectResponse.isNull())
+        return;
 
-void DocumentLoader::callContinueAfterNavigationPolicy(void* argument, const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue)
-{
-    static_cast<DocumentLoader*>(argument)->continueAfterNavigationPolicy(request, shouldContinue);
+    frameLoader()->policyChecker().checkNavigationPolicy(newRequest, [this](const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue) {
+        continueAfterNavigationPolicy(request, shouldContinue);
+    });
 }
 
 void DocumentLoader::continueAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue)
@@ -638,14 +637,11 @@
         m_contentFilter = ContentFilter::create(response);
 #endif
 
-    frameLoader()->policyChecker().checkContentPolicy(m_response, callContinueAfterContentPolicy, this);
+    frameLoader()->policyChecker().checkContentPolicy(m_response, [this](PolicyAction policy) {
+        continueAfterContentPolicy(policy);
+    });
 }
 
-void DocumentLoader::callContinueAfterContentPolicy(void* argument, PolicyAction policy)
-{
-    static_cast<DocumentLoader*>(argument)->continueAfterContentPolicy(policy);
-}
-
 void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
 {
     ASSERT(m_waitingForContentPolicy);

Modified: trunk/Source/WebCore/loader/DocumentLoader.h (158866 => 158867)


--- trunk/Source/WebCore/loader/DocumentLoader.h	2013-11-07 21:30:58 UTC (rev 158866)
+++ trunk/Source/WebCore/loader/DocumentLoader.h	2013-11-07 21:37:36 UTC (rev 158867)
@@ -288,10 +288,8 @@
         bool isMultipartReplacingLoad() const;
         bool isPostOrRedirectAfterPost(const ResourceRequest&, const ResourceResponse&);
 
-        static void callContinueAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
         void continueAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
 
-        static void callContinueAfterContentPolicy(void*, PolicyAction);
         void continueAfterContentPolicy(PolicyAction);
 
         void stopLoadingForPolicyChange();

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (158866 => 158867)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2013-11-07 21:30:58 UTC (rev 158866)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2013-11-07 21:37:36 UTC (rev 158867)
@@ -1237,8 +1237,9 @@
     NavigationAction action(request, newLoadType, isFormSubmission, event);
 
     if (!targetFrame && !frameName.isEmpty()) {
-        policyChecker().checkNewWindowPolicy(action, FrameLoader::callContinueLoadAfterNewWindowPolicy,
-            request, formState.release(), frameName, this);
+        policyChecker().checkNewWindowPolicy(action, request, formState.release(), frameName, [this](const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+            continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue);
+        });
         return;
     }
 
@@ -1255,22 +1256,25 @@
         oldDocumentLoader->setLastCheckedRequest(ResourceRequest());
         policyChecker().stopCheck();
         policyChecker().setLoadType(newLoadType);
-        policyChecker().checkNavigationPolicy(request, oldDocumentLoader.get(), formState.release(),
-            callContinueFragmentScrollAfterNavigationPolicy, this);
-    } else {
-        // must grab this now, since this load may stop the previous load and clear this flag
-        bool isRedirect = m_quickRedirectComing;
-        loadWithNavigationAction(request, action, lockHistory, newLoadType, formState.release());
-        if (isRedirect) {
-            m_quickRedirectComing = false;
-            if (m_provisionalDocumentLoader)
-                m_provisionalDocumentLoader->setIsClientRedirect(true);
-        } else if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoadTypeReloadFromOrigin)
-            // Example of this case are sites that reload the same URL with a different cookie
-            // driving the generated content, or a master frame with links that drive a target
-            // frame, where the user has clicked on the same link repeatedly.
-            m_loadType = FrameLoadTypeSame;
+        policyChecker().checkNavigationPolicy(request, oldDocumentLoader.get(), formState.release(), [this](const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue) {
+            continueFragmentScrollAfterNavigationPolicy(request, shouldContinue);
+        });
+        return;
     }
+
+    // must grab this now, since this load may stop the previous load and clear this flag
+    bool isRedirect = m_quickRedirectComing;
+    loadWithNavigationAction(request, action, lockHistory, newLoadType, formState.release());
+    if (isRedirect) {
+        m_quickRedirectComing = false;
+        if (m_provisionalDocumentLoader)
+            m_provisionalDocumentLoader->setIsClientRedirect(true);
+    } else if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoadTypeReloadFromOrigin) {
+        // Example of this case are sites that reload the same URL with a different cookie
+        // driving the generated content, or a master frame with links that drive a target
+        // frame, where the user has clicked on the same link repeatedly.
+        m_loadType = FrameLoadTypeSame;
+    }
 }
 
 SubstituteData FrameLoader::defaultSubstituteDataForURL(const URL& url)
@@ -1302,7 +1306,10 @@
     }
 
     if (request.shouldCheckNewWindowPolicy()) {
-        policyChecker().checkNewWindowPolicy(NavigationAction(request.resourceRequest(), NavigationTypeOther), FrameLoader::callContinueLoadAfterNewWindowPolicy, request.resourceRequest(), 0, request.frameName(), this);
+        policyChecker().checkNewWindowPolicy(NavigationAction(request.resourceRequest(), NavigationTypeOther), request.resourceRequest(), nullptr, request.frameName(), [this](const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+            continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue);
+        });
+
         return;
     }
 
@@ -1397,33 +1404,36 @@
         oldDocumentLoader->setTriggeringAction(action);
         oldDocumentLoader->setLastCheckedRequest(ResourceRequest());
         policyChecker().stopCheck();
-        policyChecker().checkNavigationPolicy(loader->request(), oldDocumentLoader.get(), formState,
-            callContinueFragmentScrollAfterNavigationPolicy, this);
-    } else {
-        if (Frame* parent = m_frame.tree().parent())
-            loader->setOverrideEncoding(parent->loader().documentLoader()->overrideEncoding());
+        policyChecker().checkNavigationPolicy(loader->request(), oldDocumentLoader.get(), formState, [this](const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue) {
+            continueFragmentScrollAfterNavigationPolicy(request, shouldContinue);
+        });
+        return;
+    }
 
-        policyChecker().stopCheck();
-        setPolicyDocumentLoader(loader);
-        if (loader->triggeringAction().isEmpty())
-            loader->setTriggeringAction(NavigationAction(loader->request(), policyChecker().loadType(), isFormSubmission));
+    if (Frame* parent = m_frame.tree().parent())
+        loader->setOverrideEncoding(parent->loader().documentLoader()->overrideEncoding());
 
-        if (Element* ownerElement = m_frame.ownerElement()) {
-            // We skip dispatching the beforeload event if we've already
-            // committed a real document load because the event would leak
-            // subsequent activity by the frame which the parent frame isn't
-            // supposed to learn. For example, if the child frame navigated to
-            // a new URL, the parent frame shouldn't learn the URL.
-            if (!m_stateMachine.committedFirstRealDocumentLoad()
-                && !ownerElement->dispatchBeforeLoadEvent(loader->request().url().string())) {
-                continueLoadAfterNavigationPolicy(loader->request(), formState, false);
-                return;
-            }
+    policyChecker().stopCheck();
+    setPolicyDocumentLoader(loader);
+    if (loader->triggeringAction().isEmpty())
+        loader->setTriggeringAction(NavigationAction(loader->request(), policyChecker().loadType(), isFormSubmission));
+
+    if (Element* ownerElement = m_frame.ownerElement()) {
+        // We skip dispatching the beforeload event if we've already
+        // committed a real document load because the event would leak
+        // subsequent activity by the frame which the parent frame isn't
+        // supposed to learn. For example, if the child frame navigated to
+        // a new URL, the parent frame shouldn't learn the URL.
+        if (!m_stateMachine.committedFirstRealDocumentLoad()
+            && !ownerElement->dispatchBeforeLoadEvent(loader->request().url().string())) {
+            continueLoadAfterNavigationPolicy(loader->request(), formState, false);
+            return;
         }
+    }
 
-        policyChecker().checkNavigationPolicy(loader->request(), loader, formState,
-            callContinueLoadAfterNavigationPolicy, this);
-    }
+    policyChecker().checkNavigationPolicy(loader->request(), loader, formState, [this](const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue) {
+        continueLoadAfterNavigationPolicy(request, formState, shouldContinue);
+    });
 }
 
 void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url)
@@ -2552,20 +2562,25 @@
 
     if (!frameName.isEmpty()) {
         // The search for a target frame is done earlier in the case of form submission.
-        if (Frame* targetFrame = formState ? 0 : findFrameForNavigation(frameName))
+        if (Frame* targetFrame = formState ? 0 : findFrameForNavigation(frameName)) {
             targetFrame->loader().loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, formState.release());
-        else
-            policyChecker().checkNewWindowPolicy(action, FrameLoader::callContinueLoadAfterNewWindowPolicy, workingResourceRequest, formState.release(), frameName, this);
-    } else {
-        // must grab this now, since this load may stop the previous load and clear this flag
-        bool isRedirect = m_quickRedirectComing;
-        loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, formState.release());    
-        if (isRedirect) {
-            m_quickRedirectComing = false;
-            if (m_provisionalDocumentLoader)
-                m_provisionalDocumentLoader->setIsClientRedirect(true);
+            return;
         }
+
+        policyChecker().checkNewWindowPolicy(action, workingResourceRequest, formState.release(), frameName, [this](const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+            continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue);
+        });
+        return;
     }
+
+    // must grab this now, since this load may stop the previous load and clear this flag
+    bool isRedirect = m_quickRedirectComing;
+    loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, formState.release());    
+    if (isRedirect) {
+        m_quickRedirectComing = false;
+        if (m_provisionalDocumentLoader)
+            m_provisionalDocumentLoader->setIsClientRedirect(true);
+    }
 }
 
 unsigned long FrameLoader::loadResourceSynchronously(const ResourceRequest& request, StoredCredentials storedCredentials, ClientCredentialPolicy clientCredentialPolicy, ResourceError& error, ResourceResponse& response, Vector<char>& data)

Modified: trunk/Source/WebCore/loader/PolicyCallback.cpp (158866 => 158867)


--- trunk/Source/WebCore/loader/PolicyCallback.cpp	2013-11-07 21:30:58 UTC (rev 158866)
+++ trunk/Source/WebCore/loader/PolicyCallback.cpp	2013-11-07 21:37:36 UTC (rev 158867)
@@ -39,10 +39,6 @@
 namespace WebCore {
 
 PolicyCallback::PolicyCallback()
-    : m_navigationFunction(0)
-    , m_newWindowFunction(0)
-    , m_contentFunction(0)
-    , m_argument(0)
 {
 }
 
@@ -53,56 +49,52 @@
 void PolicyCallback::clear()
 {
     clearRequest();
-    m_navigationFunction = 0;
-    m_newWindowFunction = 0;
-    m_contentFunction = 0;
+    m_navigationFunction = nullptr;
+    m_newWindowFunction = nullptr;
+    m_contentFunction = nullptr;
 }
 
 void PolicyCallback::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
-    NavigationPolicyDecisionFunction function, void* argument)
+    NavigationPolicyDecisionFunction function)
 {
     m_request = request;
     m_formState = formState;
     m_frameName = String();
 
-    m_navigationFunction = function;
-    m_newWindowFunction = 0;
-    m_contentFunction = 0;
-    m_argument = argument;
+    m_navigationFunction = std::move(function);
+    m_newWindowFunction = nullptr;
+    m_contentFunction = nullptr;
 }
 
-void PolicyCallback::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
-    const String& frameName, const NavigationAction& navigationAction, NewWindowPolicyDecisionFunction function, void* argument)
+void PolicyCallback::set(const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, const NavigationAction& navigationAction, NewWindowPolicyDecisionFunction function)
 {
     m_request = request;
     m_formState = formState;
     m_frameName = frameName;
     m_navigationAction = navigationAction;
 
-    m_navigationFunction = 0;
-    m_newWindowFunction = function;
-    m_contentFunction = 0;
-    m_argument = argument;
+    m_navigationFunction = nullptr;
+    m_newWindowFunction = std::move(function);
+    m_contentFunction = nullptr;
 }
 
-void PolicyCallback::set(ContentPolicyDecisionFunction function, void* argument)
+void PolicyCallback::set(ContentPolicyDecisionFunction function)
 {
     m_request = ResourceRequest();
-    m_formState = 0;
+    m_formState = nullptr;
     m_frameName = String();
 
-    m_navigationFunction = 0;
-    m_newWindowFunction = 0;
-    m_contentFunction = function;
-    m_argument = argument;
+    m_navigationFunction = nullptr;
+    m_newWindowFunction = nullptr;
+    m_contentFunction = std::move(function);
 }
 
 void PolicyCallback::call(bool shouldContinue)
 {
     if (m_navigationFunction)
-        m_navigationFunction(m_argument, m_request, m_formState.get(), shouldContinue);
+        m_navigationFunction(m_request, m_formState.get(), shouldContinue);
     if (m_newWindowFunction)
-        m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, m_navigationAction, shouldContinue);
+        m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, shouldContinue);
     ASSERT(!m_contentFunction);
 }
 
@@ -111,13 +103,13 @@
     ASSERT(!m_navigationFunction);
     ASSERT(!m_newWindowFunction);
     ASSERT(m_contentFunction);
-    m_contentFunction(m_argument, action);
+    m_contentFunction(action);
 }
 
 void PolicyCallback::clearRequest()
 {
     m_request = ResourceRequest();
-    m_formState = 0;
+    m_formState = nullptr;
     m_frameName = String();
 }
 
@@ -125,11 +117,11 @@
 {
     clearRequest();
     if (m_navigationFunction)
-        m_navigationFunction(m_argument, m_request, m_formState.get(), false);
+        m_navigationFunction(m_request, m_formState.get(), false);
     if (m_newWindowFunction)
-        m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, m_navigationAction, false);
+        m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, false);
     if (m_contentFunction)
-        m_contentFunction(m_argument, PolicyIgnore);
+        m_contentFunction(PolicyIgnore);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/PolicyCallback.h (158866 => 158867)


--- trunk/Source/WebCore/loader/PolicyCallback.h	2013-11-07 21:30:58 UTC (rev 158866)
+++ trunk/Source/WebCore/loader/PolicyCallback.h	2013-11-07 21:37:36 UTC (rev 158867)
@@ -33,6 +33,7 @@
 #include "FrameLoaderTypes.h"
 #include "NavigationAction.h"
 #include "ResourceRequest.h"
+#include <functional>
 #include <wtf/RefPtr.h>
 #include <wtf/text/WTFString.h>
 
@@ -40,11 +41,9 @@
 
 class FormState;
 
-typedef void (*NavigationPolicyDecisionFunction)(void* argument,
-    const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
-typedef void (*NewWindowPolicyDecisionFunction)(void* argument,
-    const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, const NavigationAction&, bool shouldContinue);
-typedef void (*ContentPolicyDecisionFunction)(void* argument, PolicyAction);
+typedef std::function<void (const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue)> NavigationPolicyDecisionFunction;
+typedef std::function<void (const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, const NavigationAction&, bool shouldContinue)> NewWindowPolicyDecisionFunction;
+typedef std::function<void (PolicyAction)> ContentPolicyDecisionFunction;
 
 class PolicyCallback {
 public:
@@ -52,11 +51,9 @@
     ~PolicyCallback();
 
     void clear();
-    void set(const ResourceRequest&, PassRefPtr<FormState>,
-        NavigationPolicyDecisionFunction, void* argument);
-    void set(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, const NavigationAction&,
-        NewWindowPolicyDecisionFunction, void* argument);
-    void set(ContentPolicyDecisionFunction, void* argument);
+    void set(const ResourceRequest&, PassRefPtr<FormState>, NavigationPolicyDecisionFunction);
+    void set(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, const NavigationAction&, NewWindowPolicyDecisionFunction);
+    void set(ContentPolicyDecisionFunction);
 
     const ResourceRequest& request() const { return m_request; }
     void clearRequest();
@@ -74,7 +71,6 @@
     NavigationPolicyDecisionFunction m_navigationFunction;
     NewWindowPolicyDecisionFunction m_newWindowFunction;
     ContentPolicyDecisionFunction m_contentFunction;
-    void* m_argument;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/PolicyChecker.cpp (158866 => 158867)


--- trunk/Source/WebCore/loader/PolicyChecker.cpp	2013-11-07 21:30:58 UTC (rev 158866)
+++ trunk/Source/WebCore/loader/PolicyChecker.cpp	2013-11-07 21:37:36 UTC (rev 158867)
@@ -52,13 +52,12 @@
 {
 }
 
-void PolicyChecker::checkNavigationPolicy(const ResourceRequest& newRequest, NavigationPolicyDecisionFunction function, void* argument)
+void PolicyChecker::checkNavigationPolicy(const ResourceRequest& newRequest, NavigationPolicyDecisionFunction function)
 {
-    checkNavigationPolicy(newRequest, m_frame.loader().activeDocumentLoader(), 0, function, argument);
+    checkNavigationPolicy(newRequest, m_frame.loader().activeDocumentLoader(), nullptr, std::move(function));
 }
 
-void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, DocumentLoader* loader,
-    PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function, void* argument)
+void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, DocumentLoader* loader, PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function)
 {
     NavigationAction action = ""
     if (action.isEmpty()) {
@@ -69,7 +68,7 @@
     // Don't ask more than once for the same request or if we are loading an empty URL.
     // This avoids confusion on the part of the client.
     if (equalIgnoringHeaderFields(request, loader->lastCheckedRequest()) || (!request.isNull() && request.url().isEmpty())) {
-        function(argument, request, 0, true);
+        function(request, 0, true);
         loader->setLastCheckedRequest(request);
         return;
     }
@@ -79,20 +78,20 @@
     if (loader->substituteData().isValid() && !loader->substituteData().failingURL().isEmpty()) {
         if (isBackForwardLoadType(m_loadType))
             m_loadType = FrameLoadTypeReload;
-        function(argument, request, 0, true);
+        function(request, 0, true);
         return;
     }
 
     // If we're loading content into a subframe, check against the parent's Content Security Policy
     // and kill the load if that check fails.
     if (m_frame.ownerElement() && !m_frame.ownerElement()->document().contentSecurityPolicy()->allowChildFrameFromSource(request.url())) {
-        function(argument, request, 0, false);
+        function(request, 0, false);
         return;
     }
 
     loader->setLastCheckedRequest(request);
 
-    m_callback.set(request, formState.get(), function, argument);
+    m_callback.set(request, formState.get(), std::move(function));
 
     m_delegateIsDecidingNavigationPolicy = true;
     m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, formState, [this](PolicyAction action) {
@@ -101,8 +100,7 @@
     m_delegateIsDecidingNavigationPolicy = false;
 }
 
-void PolicyChecker::checkNewWindowPolicy(const NavigationAction& action, NewWindowPolicyDecisionFunction function,
-    const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, void* argument)
+void PolicyChecker::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, NewWindowPolicyDecisionFunction function)
 {
     if (m_frame.document() && m_frame.document()->isSandboxed(SandboxPopups))
         return continueAfterNavigationPolicy(PolicyIgnore);
@@ -110,15 +108,15 @@
     if (!DOMWindow::allowPopUp(&m_frame))
         return continueAfterNavigationPolicy(PolicyIgnore);
 
-    m_callback.set(request, formState, frameName, action, function, argument);
+    m_callback.set(request, formState, frameName, action, std::move(function));
     m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(action, request, formState, frameName, [this](PolicyAction action) {
         continueAfterNewWindowPolicy(action);
     });
 }
 
-void PolicyChecker::checkContentPolicy(const ResourceResponse& response, ContentPolicyDecisionFunction function, void* argument)
+void PolicyChecker::checkContentPolicy(const ResourceResponse& response, ContentPolicyDecisionFunction function)
 {
-    m_callback.set(function, argument);
+    m_callback.set(std::move(function));
     m_frame.loader().client().dispatchDecidePolicyForResponse(response, m_frame.loader().activeDocumentLoader()->request(), [this](PolicyAction action) {
         continueAfterContentPolicy(action);
     });

Modified: trunk/Source/WebCore/loader/PolicyChecker.h (158866 => 158867)


--- trunk/Source/WebCore/loader/PolicyChecker.h	2013-11-07 21:30:58 UTC (rev 158866)
+++ trunk/Source/WebCore/loader/PolicyChecker.h	2013-11-07 21:37:36 UTC (rev 158867)
@@ -50,10 +50,10 @@
 public:
     explicit PolicyChecker(Frame&);
 
-    void checkNavigationPolicy(const ResourceRequest&, DocumentLoader*, PassRefPtr<FormState>, NavigationPolicyDecisionFunction, void* argument);
-    void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction, void* argument);
-    void checkNewWindowPolicy(const NavigationAction&, NewWindowPolicyDecisionFunction, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, void* argument);
-    void checkContentPolicy(const ResourceResponse&, ContentPolicyDecisionFunction, void* argument);
+    void checkNavigationPolicy(const ResourceRequest&, DocumentLoader*, PassRefPtr<FormState>, NavigationPolicyDecisionFunction);
+    void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction);
+    void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, NewWindowPolicyDecisionFunction);
+    void checkContentPolicy(const ResourceResponse&, ContentPolicyDecisionFunction);
 
     // FIXME: These are different.  They could use better names.
     void cancelCheck();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to