Changeset 234154 in webkit


Ignore:
Timestamp:
Jul 24, 2018 10:27:15 AM (6 years ago)
Author:
achristensen@apple.com
Message:

Reduce getters/setters in WebFramePolicyListenerProxy
https://bugs.webkit.org/show_bug.cgi?id=187830

Reviewed by Dean Jackson.

This is a step towards making it a lambda, which has no getters or setters.
No change in behavior.

setApplyPolicyInNewProcessIfPossible can be replaced by passing another parameter.
This bit was just piggy-backing on the WebFramePolicyListenerProxy.

isMainFrame was only used in an assert, which has a corresponding ObjC exception in
NavigationState::NavigationClient::decidePolicyForNavigationAction for the one relevant client.

  • UIProcess/API/C/WKFramePolicyListener.cpp:

(WKFramePolicyListenerUseInNewProcess):
(useWithPolicies):
(WKFramePolicyListenerUseWithPolicies):
(WKFramePolicyListenerUseInNewProcessWithPolicies):

  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):

  • UIProcess/WebFramePolicyListenerProxy.cpp:

(WebKit::WebFramePolicyListenerProxy::receivedPolicyDecision):
(WebKit::WebFramePolicyListenerProxy::use):
(WebKit::WebFramePolicyListenerProxy::download):
(WebKit::WebFramePolicyListenerProxy::ignore):
(WebKit::WebFramePolicyListenerProxy::isMainFrame const): Deleted.

  • UIProcess/WebFramePolicyListenerProxy.h:

(WebKit::WebFramePolicyListenerProxy::setApplyPolicyInNewProcessIfPossible): Deleted.
(WebKit::WebFramePolicyListenerProxy::applyPolicyInNewProcessIfPossible const): Deleted.

  • UIProcess/WebFrameProxy.cpp:

(WebKit::WebFrameProxy::receivedPolicyDecision):

  • UIProcess/WebFrameProxy.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::processForNavigation):
(WebKit::WebProcessPool::processForNavigationInternal):

  • UIProcess/WebProcessPool.h:
Location:
trunk/Source/WebKit
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r234153 r234154  
     12018-07-24  Alex Christensen  <achristensen@webkit.org>
     2
     3        Reduce getters/setters in WebFramePolicyListenerProxy
     4        https://bugs.webkit.org/show_bug.cgi?id=187830
     5
     6        Reviewed by Dean Jackson.
     7
     8        This is a step towards making it a lambda, which has no getters or setters.
     9        No change in behavior.
     10
     11        setApplyPolicyInNewProcessIfPossible can be replaced by passing another parameter.
     12        This bit was just piggy-backing on the WebFramePolicyListenerProxy.
     13
     14        isMainFrame was only used in an assert, which has a corresponding ObjC exception in
     15        NavigationState::NavigationClient::decidePolicyForNavigationAction for the one relevant client.
     16
     17        * UIProcess/API/C/WKFramePolicyListener.cpp:
     18        (WKFramePolicyListenerUseInNewProcess):
     19        (useWithPolicies):
     20        (WKFramePolicyListenerUseWithPolicies):
     21        (WKFramePolicyListenerUseInNewProcessWithPolicies):
     22        * UIProcess/Cocoa/NavigationState.mm:
     23        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
     24        * UIProcess/WebFramePolicyListenerProxy.cpp:
     25        (WebKit::WebFramePolicyListenerProxy::receivedPolicyDecision):
     26        (WebKit::WebFramePolicyListenerProxy::use):
     27        (WebKit::WebFramePolicyListenerProxy::download):
     28        (WebKit::WebFramePolicyListenerProxy::ignore):
     29        (WebKit::WebFramePolicyListenerProxy::isMainFrame const): Deleted.
     30        * UIProcess/WebFramePolicyListenerProxy.h:
     31        (WebKit::WebFramePolicyListenerProxy::setApplyPolicyInNewProcessIfPossible): Deleted.
     32        (WebKit::WebFramePolicyListenerProxy::applyPolicyInNewProcessIfPossible const): Deleted.
     33        * UIProcess/WebFrameProxy.cpp:
     34        (WebKit::WebFrameProxy::receivedPolicyDecision):
     35        * UIProcess/WebFrameProxy.h:
     36        * UIProcess/WebPageProxy.cpp:
     37        (WebKit::WebPageProxy::receivedPolicyDecision):
     38        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
     39        * UIProcess/WebPageProxy.h:
     40        * UIProcess/WebProcessPool.cpp:
     41        (WebKit::WebProcessPool::processForNavigation):
     42        (WebKit::WebProcessPool::processForNavigationInternal):
     43        * UIProcess/WebProcessPool.h:
     44
    1452018-07-24  Alex Christensen  <achristensen@webkit.org>
    246
  • trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp

    r233986 r234154  
    3232#include "WebFramePolicyListenerProxy.h"
    3333#include "WebFrameProxy.h"
     34#include "WebProcessPool.h"
    3435#include "WebsitePoliciesData.h"
    3536
     
    4849void WKFramePolicyListenerUseInNewProcess(WKFramePolicyListenerRef policyListenerRef)
    4950{
    50     toImpl(policyListenerRef)->setApplyPolicyInNewProcessIfPossible(true);
    51     toImpl(policyListenerRef)->use(std::nullopt);
     51    toImpl(policyListenerRef)->use(std::nullopt, ShouldProcessSwapIfPossible::Yes);
    5252}
    5353
    54 void WKFramePolicyListenerUseWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies)
     54static void useWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible)
    5555{
    5656    auto data = toImpl(websitePolicies)->data();
     
    5959        auto& sessionID = data.websiteDataStoreParameters->networkSessionParameters.sessionID;
    6060        RELEASE_ASSERT_WITH_MESSAGE(sessionID.isEphemeral() || sessionID == PAL::SessionID::defaultSessionID(), "If WebsitePolicies specifies a WebsiteDataStore, the data store's session must be default or non-persistent.");
    61         RELEASE_ASSERT_WITH_MESSAGE(toImpl(policyListenerRef)->isMainFrame(), "WebsitePolicies cannot specify a WebsiteDataStore for subframe navigations.");
    6261
    6362        toImpl(policyListenerRef)->changeWebsiteDataStore(toImpl(websitePolicies)->websiteDataStore()->websiteDataStore());
    6463    }
    6564
    66     toImpl(policyListenerRef)->use(WTFMove(data));
     65    toImpl(policyListenerRef)->use(WTFMove(data), shouldProcessSwapIfPossible);
     66}
     67
     68void WKFramePolicyListenerUseWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies)
     69{
     70    useWithPolicies(policyListenerRef, websitePolicies, ShouldProcessSwapIfPossible::No);
    6771}
    6872
    6973void WKFramePolicyListenerUseInNewProcessWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies)
    7074{
    71     toImpl(policyListenerRef)->setApplyPolicyInNewProcessIfPossible(true);
    72     WKFramePolicyListenerUseWithPolicies(policyListenerRef, websitePolicies);
     75    useWithPolicies(policyListenerRef, websitePolicies, ShouldProcessSwapIfPossible::Yes);
    7376}
    7477
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r233986 r234154  
    552552#pragma clang diagnostic pop
    553553            tryAppLink(WTFMove(navigationAction), mainFrameURLString, [actionPolicy, localListener = WTFMove(localListener), data = WTFMove(data)](bool followedLinkToApp) mutable {
    554                 localListener->setApplyPolicyInNewProcessIfPossible(actionPolicy == _WKNavigationActionPolicyAllowInNewProcess);
    555554                if (followedLinkToApp) {
    556555                    localListener->ignore();
     
    558557                }
    559558
    560                 localListener->use(WTFMove(data));
     559                localListener->use(WTFMove(data), actionPolicy == _WKNavigationActionPolicyAllowInNewProcess ? ShouldProcessSwapIfPossible::Yes : ShouldProcessSwapIfPossible::No);
    561560            });
    562561       
  • trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp

    r234153 r234154  
    4141}
    4242
    43 void WebFramePolicyListenerProxy::receivedPolicyDecision(WebCore::PolicyAction action, std::optional<WebsitePoliciesData>&& data)
     43void WebFramePolicyListenerProxy::receivedPolicyDecision(WebCore::PolicyAction action, std::optional<WebsitePoliciesData>&& data, ShouldProcessSwapIfPossible swap)
    4444{
    4545    if (!m_frame)
    4646        return;
    4747   
    48     m_frame->receivedPolicyDecision(action, m_listenerID, m_navigation.get(), WTFMove(data));
     48    m_frame->receivedPolicyDecision(action, m_listenerID, m_navigation.get(), WTFMove(data), swap);
    4949    m_frame = nullptr;
    5050}
     
    5858}
    5959
    60 bool WebFramePolicyListenerProxy::isMainFrame() const
    61 {
    62     if (!m_frame)
    63         return false;
    64    
    65     return m_frame->isMainFrame();
    66 }
    67 
    6860void WebFramePolicyListenerProxy::setNavigation(Ref<API::Navigation>&& navigation)
    6961{
     
    7163}
    7264   
    73 void WebFramePolicyListenerProxy::use(std::optional<WebsitePoliciesData>&& data)
     65void WebFramePolicyListenerProxy::use(std::optional<WebsitePoliciesData>&& data, ShouldProcessSwapIfPossible swap)
    7466{
    75     receivedPolicyDecision(WebCore::PolicyAction::Use, WTFMove(data));
     67    receivedPolicyDecision(WebCore::PolicyAction::Use, WTFMove(data), swap);
    7668}
    7769
    7870void WebFramePolicyListenerProxy::download()
    7971{
    80     receivedPolicyDecision(WebCore::PolicyAction::Download, std::nullopt);
     72    receivedPolicyDecision(WebCore::PolicyAction::Download, std::nullopt, ShouldProcessSwapIfPossible::No);
    8173}
    8274
    8375void WebFramePolicyListenerProxy::ignore()
    8476{
    85     receivedPolicyDecision(WebCore::PolicyAction::Ignore, std::nullopt);
     77    receivedPolicyDecision(WebCore::PolicyAction::Ignore, std::nullopt, ShouldProcessSwapIfPossible::No);
    8678}
    8779
  • trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.h

    r234153 r234154  
    5252};
    5353
     54enum class ShouldProcessSwapIfPossible { No, Yes };
     55
    5456class WebFramePolicyListenerProxy : public API::ObjectImpl<API::Object::Type::FramePolicyListener> {
    5557public:
     
    6062    }
    6163
    62     void use(std::optional<WebsitePoliciesData>&&);
     64    void use(std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible = ShouldProcessSwapIfPossible::No);
    6365    void download();
    6466    void ignore();
     
    7173   
    7274    void changeWebsiteDataStore(WebsiteDataStore&);
    73     bool isMainFrame() const;
    74 
    75     void setApplyPolicyInNewProcessIfPossible(bool applyPolicyInNewProcessIfPossible) { m_applyPolicyInNewProcessIfPossible = applyPolicyInNewProcessIfPossible; }
    76     bool applyPolicyInNewProcessIfPossible() const { return m_applyPolicyInNewProcessIfPossible; }
    7775
    7876private:
    7977    WebFramePolicyListenerProxy(WebFrameProxy*, uint64_t listenerID, PolicyListenerType);
    8078
    81     void receivedPolicyDecision(WebCore::PolicyAction, std::optional<WebsitePoliciesData>&&);
     79    void receivedPolicyDecision(WebCore::PolicyAction, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
    8280
    8381    PolicyListenerType m_policyType;
     
    8583    uint64_t m_listenerID { 0 };
    8684    RefPtr<API::Navigation> m_navigation;
    87     bool m_applyPolicyInNewProcessIfPossible { false };
    8885};
    8986
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp

    r234153 r234154  
    179179}
    180180
    181 void WebFrameProxy::receivedPolicyDecision(PolicyAction action, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& data)
     181void WebFrameProxy::receivedPolicyDecision(PolicyAction action, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& data, ShouldProcessSwapIfPossible swap)
    182182{
    183183    if (!m_page)
     
    186186    ASSERT(m_activeListener);
    187187    ASSERT(m_activeListener->listenerID() == listenerID);
    188     m_page->receivedPolicyDecision(action, *this, listenerID, navigation, WTFMove(data));
     188    m_page->receivedPolicyDecision(action, *this, listenerID, navigation, WTFMove(data), swap);
    189189}
    190190
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.h

    r234009 r234154  
    5353class WebPageProxy;
    5454class WebsiteDataStore;
     55enum class ShouldProcessSwapIfPossible;
    5556enum class PolicyListenerType;
    5657struct WebsitePoliciesData;
     
    117118
    118119    // Policy operations.
    119     void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&);
     120    void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
    120121
    121122    WebFramePolicyListenerProxy& setUpPolicyListenerProxy(uint64_t listenerID, PolicyListenerType);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r234143 r234154  
    24072407}
    24082408
    2409 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy& frame, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& websitePolicies)
     2409void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy& frame, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& websitePolicies, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible)
    24102410{
    24112411    if (!isValid())
     
    24392439
    24402440        if (action == PolicyAction::Use && navigation && frame.isMainFrame()) {
    2441             auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, activePolicyListener->applyPolicyInNewProcessIfPossible(), action);
     2441            auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, shouldProcessSwapIfPossible, action);
    24422442
    24432443            if (proposedProcess.ptr() != &process()) {
     
    40294029#if ENABLE(CONTENT_FILTERING)
    40304030    if (frame->didHandleContentFilterUnblockNavigation(request))
    4031         return receivedPolicyDecision(PolicyAction::Ignore, *frame, listenerID, &m_navigationState->navigation(newNavigationID), { });
     4031        return receivedPolicyDecision(PolicyAction::Ignore, *frame, listenerID, &m_navigationState->navigation(newNavigationID), std::nullopt, ShouldProcessSwapIfPossible::No);
    40324032#else
    40334033    UNUSED_PARAM(newNavigationID);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r234143 r234154  
    260260struct URLSchemeTaskParameters;
    261261
     262enum class ShouldProcessSwapIfPossible;
     263
    262264#if USE(QUICK_LOOK)
    263265class QuickLookDocumentData;
     
    907909#endif
    908910
    909     void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy&, uint64_t listenerID, API::Navigation* navigationID, std::optional<WebsitePoliciesData>&&);
     911    void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy&, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
    910912
    911913    void backForwardRemovedItem(const WebCore::BackForwardItemIdentifier&);
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r234009 r234154  
    21082108}
    21092109
    2110 Ref<WebProcessProxy> WebProcessPool::processForNavigation(WebPageProxy& page, const API::Navigation& navigation, bool shouldProcessSwapIfPossible, PolicyAction& action)
     2110Ref<WebProcessProxy> WebProcessPool::processForNavigation(WebPageProxy& page, const API::Navigation& navigation, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible, PolicyAction& action)
    21112111{
    21122112    auto process = processForNavigationInternal(page, navigation, shouldProcessSwapIfPossible, action);
     
    21262126}
    21272127
    2128 Ref<WebProcessProxy> WebProcessPool::processForNavigationInternal(WebPageProxy& page, const API::Navigation& navigation, bool shouldProcessSwapIfPossible, PolicyAction& action)
    2129 {
    2130     if (!m_configuration->processSwapsOnNavigation() && !shouldProcessSwapIfPossible)
     2128Ref<WebProcessProxy> WebProcessPool::processForNavigationInternal(WebPageProxy& page, const API::Navigation& navigation, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible, PolicyAction& action)
     2129{
     2130    if (!m_configuration->processSwapsOnNavigation() && shouldProcessSwapIfPossible == ShouldProcessSwapIfPossible::No)
    21312131        return page.process();
    21322132
     
    21722172
    21732173    auto targetURL = navigation.currentRequest().url();
    2174     if (!shouldProcessSwapIfPossible) {
     2174    if (shouldProcessSwapIfPossible == ShouldProcessSwapIfPossible::No) {
    21752175        if (navigation.treatAsSameOriginNavigation())
    21762176            return page.process();
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r233986 r234154  
    111111#endif
    112112
     113enum class ShouldProcessSwapIfPossible;
     114
    113115class WebProcessPool final : public API::ObjectImpl<API::Object::Type::ProcessPool>, public CanMakeWeakPtr<WebProcessPool>, private IPC::MessageReceiver {
    114116public:
     
    453455#endif
    454456
    455     Ref<WebProcessProxy> processForNavigation(WebPageProxy&, const API::Navigation&, bool shouldProcessSwapIfPossible, WebCore::PolicyAction&);
     457    Ref<WebProcessProxy> processForNavigation(WebPageProxy&, const API::Navigation&, ShouldProcessSwapIfPossible, WebCore::PolicyAction&);
    456458    void registerSuspendedPageProxy(SuspendedPageProxy&);
    457459    void unregisterSuspendedPageProxy(SuspendedPageProxy&);
     
    471473    void platformInvalidateContext();
    472474
    473     Ref<WebProcessProxy> processForNavigationInternal(WebPageProxy&, const API::Navigation&, bool shouldProcessSwapIfPossible, WebCore::PolicyAction&);
     475    Ref<WebProcessProxy> processForNavigationInternal(WebPageProxy&, const API::Navigation&, ShouldProcessSwapIfPossible, WebCore::PolicyAction&);
    474476
    475477    RefPtr<WebProcessProxy> tryTakePrewarmedProcess(WebsiteDataStore&);
Note: See TracChangeset for help on using the changeset viewer.