Changeset 72122 in webkit


Ignore:
Timestamp:
Nov 16, 2010 11:00:58 AM (13 years ago)
Author:
andersca@apple.com
Message:

Make WebPageProxy::decidePolicyForMIMEType a tad synchronous
https://bugs.webkit.org/show_bug.cgi?id=49605

Reviewed by Sam Weinig.

Change the DecidePolicyForMIMEType message to be synchronous, and if the policy listener is
invoked from within the decidePolicyForMIMEType callback return the policy information as out
parameters. This is needed in order to convert a loading connection to a download.

  • Platform/CoreIPC/HandleMessage.h:

(CoreIPC::callMemberFunction):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::decidePolicyForMIMEType):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):

Location:
trunk/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r72100 r72122  
     12010-11-16  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Make WebPageProxy::decidePolicyForMIMEType a tad synchronous
     6        https://bugs.webkit.org/show_bug.cgi?id=49605
     7
     8        Change the DecidePolicyForMIMEType message to be synchronous, and if the policy listener is
     9        invoked from within the decidePolicyForMIMEType callback return the policy information as out
     10        parameters. This is needed in order to convert a loading connection to a download.
     11
     12        * Platform/CoreIPC/HandleMessage.h:
     13        (CoreIPC::callMemberFunction):
     14        * UIProcess/WebPageProxy.cpp:
     15        (WebKit::WebPageProxy::WebPageProxy):
     16        (WebKit::WebPageProxy::receivedPolicyDecision):
     17        (WebKit::WebPageProxy::decidePolicyForMIMEType):
     18        * UIProcess/WebPageProxy.h:
     19        * UIProcess/WebPageProxy.messages.in:
     20        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     21        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):
     22
    1232010-11-16  Kenneth Rohde Christiansen  <kenneth@webkit.org>, Zalan Bujtas  <zbujtas@gmail.com>
    224
  • trunk/WebKit2/Platform/CoreIPC/HandleMessage.h

    r71270 r72122  
    133133    (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, replyArgs.argument1, replyArgs.argument2);
    134134}
    135    
     135
     136template<typename C, typename MF, typename P1, typename P2, typename P3, typename P4, typename R1, typename R2, typename R3>
     137void callMemberFunction(const Arguments4<P1, P2, P3, P4>& args, Arguments3<R1, R2, R3>& replyArgs, C* object, MF function)
     138{
     139    (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, replyArgs.argument1, replyArgs.argument2, replyArgs.argument3);
     140}
     141
    136142// Variadic dispatch functions.
    137143
  • trunk/WebKit2/UIProcess/WebPageProxy.cpp

    r72100 r72122  
    9898    , m_isValid(true)
    9999    , m_isClosed(false)
     100    , m_inDecidePolicyForMIMEType(false)
     101    , m_syncMimeTypePolicyActionIsValid(false)
     102    , m_syncMimeTypePolicyAction(PolicyUse)
     103    , m_syncMimeTypePolicyDownloadID(0)
    100104    , m_pageID(pageID)
    101105{
     
    475479        // Create a download proxy.
    476480        downloadID = pageNamespace()->context()->createDownloadProxy();
     481    }
     482
     483    // If we received a policy decision while in decidePolicyForMIMEType the decision will
     484    // be sent back to the web process by decidePolicyForMIMEType.
     485    if (m_inDecidePolicyForMIMEType) {
     486        m_syncMimeTypePolicyActionIsValid = true;
     487        m_syncMimeTypePolicyAction = action;
     488        m_syncMimeTypePolicyDownloadID = downloadID;
     489        return;
    477490    }
    478491
     
    913926}
    914927
    915 void WebPageProxy::decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID)
     928void WebPageProxy::decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
    916929{
    917930    WebFrameProxy* frame = process()->webFrame(frameID);
    918931    RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
     932
     933    ASSERT(!m_inDecidePolicyForMIMEType);
     934
     935    m_inDecidePolicyForMIMEType = true;
     936    m_syncMimeTypePolicyActionIsValid = false;
     937
    919938    if (!m_policyClient.decidePolicyForMIMEType(this, MIMEType, url, frame, listener.get()))
    920939        listener->use();
     940
     941    m_inDecidePolicyForMIMEType = false;
     942
     943    // Check if we received a policy decision already. If we did, we can just pass it back.
     944    if (m_syncMimeTypePolicyActionIsValid) {
     945        receivedPolicyAction = true;
     946        policyAction = m_syncMimeTypePolicyAction;
     947        downloadID = m_syncMimeTypePolicyDownloadID;
     948    }
    921949}
    922950
  • trunk/WebKit2/UIProcess/WebPageProxy.h

    r72100 r72122  
    289289    void decidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const String& url, uint64_t listenerID);
    290290    void decidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const String& url, uint64_t listenerID);
    291     void decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID);
     291    void decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID);
    292292
    293293    void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
     
    424424    bool m_isClosed;
    425425
     426    bool m_inDecidePolicyForMIMEType;
     427    bool m_syncMimeTypePolicyActionIsValid;
     428    WebCore::PolicyAction m_syncMimeTypePolicyAction;
     429    uint64_t m_syncMimeTypePolicyDownloadID;
     430
    426431    uint64_t m_pageID;
    427432
  • trunk/WebKit2/UIProcess/WebPageProxy.messages.in

    r72100 r72122  
    6060
    6161    # Policy messages.
    62     DecidePolicyForMIMEType(uint64_t frameID, WTF::String MIMEType, WTF::String url, uint64_t listenerID)
     62    DecidePolicyForMIMEType(uint64_t frameID, WTF::String MIMEType, WTF::String url, uint64_t listenerID) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID)
    6363    DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID)
    6464    DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID)
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r72086 r72122  
    524524    const String& url = request.url().string(); // FIXME: Pass entire request.
    525525
    526     webPage->send(Messages::WebPageProxy::DecidePolicyForMIMEType(m_frame->frameID(), MIMEType, url, listenerID));
     526    bool receivedPolicyAction;
     527    uint64_t policyAction;
     528    uint64_t downloadID;
     529    if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForMIMEType(m_frame->frameID(), MIMEType, url, listenerID), Messages::WebPageProxy::DecidePolicyForMIMEType::Reply(receivedPolicyAction, policyAction, downloadID)))
     530        return;
     531
     532    // We call this synchronously because CFNetwork can only convert a loading connection to a download from its didReceiveResponse callback.
     533    if (receivedPolicyAction)
     534        m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID);
    527535}
    528536
Note: See TracChangeset for help on using the changeset viewer.