Changeset 221103 in webkit


Ignore:
Timestamp:
Aug 23, 2017 2:10:09 PM (7 years ago)
Author:
achristensen@apple.com
Message:

Stop using PolicyChecker for ContentPolicy
https://bugs.webkit.org/show_bug.cgi?id=175904

Reviewed by Tim Horton.

PolicyChecker is an artifact from the days before C++11. Now we have lambdas which
have a cleaner flow than one class that exists to be effectively one of three lambda types.
Let's remove them one at a time, starting with ContentPolicy checks.

No change in behaviour.

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::responseReceived):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::checkContentPolicy):

  • loader/FrameLoader.h:
  • loader/PolicyCallback.cpp:

(WebCore::PolicyCallback::set):
(WebCore::PolicyCallback::call):
(WebCore::PolicyCallback::cancel):

  • loader/PolicyCallback.h:
  • loader/PolicyChecker.cpp:

(WebCore::PolicyChecker::checkContentPolicy): Deleted.
(WebCore::PolicyChecker::continueAfterContentPolicy): Deleted.

  • loader/PolicyChecker.h:
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r221100 r221103  
     12017-08-23  Alex Christensen  <achristensen@webkit.org>
     2
     3        Stop using PolicyChecker for ContentPolicy
     4        https://bugs.webkit.org/show_bug.cgi?id=175904
     5
     6        Reviewed by Tim Horton.
     7
     8        PolicyChecker is an artifact from the days before C++11.  Now we have lambdas which
     9        have a cleaner flow than one class that exists to be effectively one of three lambda types.
     10        Let's remove them one at a time, starting with ContentPolicy checks.
     11       
     12        No change in behaviour.
     13
     14        * loader/DocumentLoader.cpp:
     15        (WebCore::DocumentLoader::responseReceived):
     16        * loader/FrameLoader.cpp:
     17        (WebCore::FrameLoader::checkContentPolicy):
     18        * loader/FrameLoader.h:
     19        * loader/PolicyCallback.cpp:
     20        (WebCore::PolicyCallback::set):
     21        (WebCore::PolicyCallback::call):
     22        (WebCore::PolicyCallback::cancel):
     23        * loader/PolicyCallback.h:
     24        * loader/PolicyChecker.cpp:
     25        (WebCore::PolicyChecker::checkContentPolicy): Deleted.
     26        (WebCore::PolicyChecker::continueAfterContentPolicy): Deleted.
     27        * loader/PolicyChecker.h:
     28
    1292017-08-23  Jer Noble  <jer.noble@apple.com>
    230
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r220857 r221103  
    705705#endif
    706706
    707     frameLoader()->policyChecker().checkContentPolicy(m_response, [this](PolicyAction policy) {
     707    frameLoader()->checkContentPolicy(m_response, [this](PolicyAction policy) {
    708708        continueAfterContentPolicy(policy);
    709709    });
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r220760 r221103  
    356356}
    357357
     358void FrameLoader::checkContentPolicy(const ResourceResponse& response, ContentPolicyDecisionFunction&& function)
     359{
     360    client().dispatchDecidePolicyForResponse(response, activeDocumentLoader()->request(), WTFMove(function));
     361}
     362
    358363void FrameLoader::changeLocation(FrameLoadRequest&& request)
    359364{
  • trunk/Source/WebCore/loader/FrameLoader.h

    r220760 r221103  
    8484WEBCORE_EXPORT bool isReload(FrameLoadType);
    8585
     86using ContentPolicyDecisionFunction = WTF::Function<void(PolicyAction)>;
     87
    8688class FrameLoader {
    8789    WTF_MAKE_NONCOPYABLE(FrameLoader);
     
    208210    void setDefersLoading(bool);
    209211
     212    void checkContentPolicy(const ResourceResponse&, ContentPolicyDecisionFunction&&);
     213
    210214    void didExplicitOpen();
    211215
  • trunk/Source/WebCore/loader/PolicyCallback.cpp

    r215918 r221103  
    4747    m_navigationFunction = WTFMove(function);
    4848    m_newWindowFunction = nullptr;
    49     m_contentFunction = nullptr;
    5049}
    5150
     
    5958    m_navigationFunction = nullptr;
    6059    m_newWindowFunction = WTFMove(function);
    61     m_contentFunction = nullptr;
    62 }
    63 
    64 void PolicyCallback::set(ContentPolicyDecisionFunction&& function)
    65 {
    66     m_request = ResourceRequest();
    67     m_formState = nullptr;
    68     m_frameName = String();
    69 
    70     m_navigationFunction = nullptr;
    71     m_newWindowFunction = nullptr;
    72     m_contentFunction = WTFMove(function);
    7360}
    7461
     
    7966    if (m_newWindowFunction)
    8067        m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, shouldContinue);
    81     ASSERT(!m_contentFunction);
    82 }
    83 
    84 void PolicyCallback::call(PolicyAction action)
    85 {
    86     ASSERT(!m_navigationFunction);
    87     ASSERT(!m_newWindowFunction);
    88     ASSERT(m_contentFunction);
    89     m_contentFunction(action);
    9068}
    9169
     
    10482    if (m_newWindowFunction)
    10583        m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, false);
    106     if (m_contentFunction)
    107         m_contentFunction(PolicyIgnore);
    10884}
    10985
  • trunk/Source/WebCore/loader/PolicyCallback.h

    r215918 r221103  
    4242class FormState;
    4343
    44 using ContentPolicyDecisionFunction = Function<void(PolicyAction)>;
    4544using NavigationPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, bool shouldContinue)>;
    4645using NewWindowPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
     
    5049    void set(const ResourceRequest&, FormState*, NavigationPolicyDecisionFunction&&);
    5150    void set(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, NewWindowPolicyDecisionFunction&&);
    52     void set(ContentPolicyDecisionFunction&&);
    5351
    5452    const ResourceRequest& request() const { return m_request; }
     
    5654
    5755    void call(bool shouldContinue);
    58     void call(PolicyAction);
    5956    void cancel();
    6057
     
    6764    NavigationPolicyDecisionFunction m_navigationFunction;
    6865    NewWindowPolicyDecisionFunction m_newWindowFunction;
    69     ContentPolicyDecisionFunction m_contentFunction;
    7066};
    7167
  • trunk/Source/WebCore/loader/PolicyChecker.cpp

    r220459 r221103  
    168168}
    169169
    170 void PolicyChecker::checkContentPolicy(const ResourceResponse& response, ContentPolicyDecisionFunction function)
    171 {
    172     m_callback.set(WTFMove(function));
    173     m_frame.loader().client().dispatchDecidePolicyForResponse(response, m_frame.loader().activeDocumentLoader()->request(), [this](PolicyAction action) {
    174         continueAfterContentPolicy(action);
    175     });
    176 }
    177 
    178170void PolicyChecker::cancelCheck()
    179171{
     
    252244}
    253245
    254 void PolicyChecker::continueAfterContentPolicy(PolicyAction policy)
    255 {
    256     PolicyCallback callback = WTFMove(m_callback);
    257     callback.call(policy);
    258 }
    259 
    260246void PolicyChecker::handleUnimplementablePolicy(const ResourceError& error)
    261247{
  • trunk/Source/WebCore/loader/PolicyChecker.h

    r210216 r221103  
    5757    void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction);
    5858    void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
    59     void checkContentPolicy(const ResourceResponse&, ContentPolicyDecisionFunction);
    6059
    6160    // FIXME: These are different.  They could use better names.
     
    8786    void continueAfterNavigationPolicy(PolicyAction);
    8887    void continueAfterNewWindowPolicy(PolicyAction);
    89     void continueAfterContentPolicy(PolicyAction);
    9088
    9189    void handleUnimplementablePolicy(const ResourceError&);
Note: See TracChangeset for help on using the changeset viewer.