Changeset 161152 in webkit


Ignore:
Timestamp:
Dec 30, 2013 1:43:44 PM (10 years ago)
Author:
andersca@apple.com
Message:

Use std::chrono::milliseconds for all IPC message timeouts
https://bugs.webkit.org/show_bug.cgi?id=126303

Reviewed by Andreas Kling.

  • Platform/IPC/Connection.cpp:

(IPC::Connection::sendSyncMessage):
(IPC::Connection::sendSyncMessageFromSecondaryThread):
(IPC::Connection::waitForSyncReply):

  • Platform/IPC/Connection.h:

(IPC::Connection::sendSync):

  • Platform/IPC/MessageSender.h:

(IPC::MessageSender::sendSync):

  • Shared/ChildProcessProxy.h:

(WebKit::ChildProcessProxy::sendSync):

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::stringSelectionForPasteboard):
(WebKit::WebPageProxy::dataSelectionForPasteboard):
(WebKit::WebPageProxy::readSelectionFromPasteboard):
(WebKit::WebPageProxy::shouldDelayWindowOrderingForEvent):
(WebKit::WebPageProxy::acceptsFirstMouse):

  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::postSynchronousMessage):

  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::runJavaScriptAlert):
(WebKit::WebChromeClient::runJavaScriptConfirm):
(WebKit::WebChromeClient::runJavaScriptPrompt):

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):

  • WebProcess/WebPage/WebInspector.cpp:

(WebKit::WebInspector::createInspectorPage):

Location:
trunk/Source/WebKit2
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r161150 r161152  
     12013-12-30  Anders Carlsson  <andersca@apple.com>
     2
     3        Use std::chrono::milliseconds for all IPC message timeouts
     4        https://bugs.webkit.org/show_bug.cgi?id=126303
     5
     6        Reviewed by Andreas Kling.
     7
     8        * Platform/IPC/Connection.cpp:
     9        (IPC::Connection::sendSyncMessage):
     10        (IPC::Connection::sendSyncMessageFromSecondaryThread):
     11        (IPC::Connection::waitForSyncReply):
     12        * Platform/IPC/Connection.h:
     13        (IPC::Connection::sendSync):
     14        * Platform/IPC/MessageSender.h:
     15        (IPC::MessageSender::sendSync):
     16        * Shared/ChildProcessProxy.h:
     17        (WebKit::ChildProcessProxy::sendSync):
     18        * UIProcess/mac/WebPageProxyMac.mm:
     19        (WebKit::WebPageProxy::stringSelectionForPasteboard):
     20        (WebKit::WebPageProxy::dataSelectionForPasteboard):
     21        (WebKit::WebPageProxy::readSelectionFromPasteboard):
     22        (WebKit::WebPageProxy::shouldDelayWindowOrderingForEvent):
     23        (WebKit::WebPageProxy::acceptsFirstMouse):
     24        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     25        (WebKit::InjectedBundle::postSynchronousMessage):
     26        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     27        (WebKit::WebChromeClient::runJavaScriptAlert):
     28        (WebKit::WebChromeClient::runJavaScriptConfirm):
     29        (WebKit::WebChromeClient::runJavaScriptPrompt):
     30        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     31        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
     32        * WebProcess/WebPage/WebInspector.cpp:
     33        (WebKit::WebInspector::createInspectorPage):
     34
    1352013-12-30  Anders Carlsson  <andersca@apple.com>
    236
  • trunk/Source/WebKit2/Platform/IPC/Connection.cpp

    r161148 r161152  
    431431}
    432432
    433 std::unique_ptr<MessageDecoder> Connection::sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, double timeout, unsigned syncSendFlags)
     433std::unique_ptr<MessageDecoder> Connection::sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, std::chrono::milliseconds timeout, unsigned syncSendFlags)
    434434{
    435435    if (RunLoop::current() != m_clientRunLoop) {
     
    480480}
    481481
    482 std::unique_ptr<MessageDecoder> Connection::sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, double timeout)
     482std::unique_ptr<MessageDecoder> Connection::sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, std::chrono::milliseconds timeout)
    483483{
    484484    ASSERT(RunLoop::current() != m_clientRunLoop);
     
    501501    sendMessage(std::move(encoder), 0);
    502502
    503     // Use a really long timeout.
    504     if (timeout == NoTimeout)
    505         timeout = 1e10;
    506 
    507     pendingReply.semaphore.wait(currentTime() + timeout);
     503    pendingReply.semaphore.wait(currentTime() + (timeout.count() / 1000.0));
    508504
    509505    // Finally, pop the pending sync reply information.
     
    517513}
    518514
    519 std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, double timeout, unsigned syncSendFlags)
    520 {
    521     // Use a really long timeout.
    522     if (timeout == NoTimeout)
    523         timeout = 1e10;
    524 
    525     double absoluteTime = currentTime() + timeout;
     515std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, unsigned syncSendFlags)
     516{
     517    double absoluteTime = currentTime() + (timeout.count() / 1000.0);
    526518
    527519    bool timedOut = false;
  • trunk/Source/WebKit2/Platform/IPC/Connection.h

    r161148 r161152  
    156156    void postConnectionDidCloseOnConnectionWorkQueue();
    157157
    158     static const int NoTimeout = -1;
    159 
    160158    template<typename T> bool send(T&& message, uint64_t destinationID, unsigned messageSendFlags = 0);
    161     template<typename T> bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, double timeout = NoTimeout, unsigned syncSendFlags = 0);
     159    template<typename T> bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::milliseconds::max(), unsigned syncSendFlags = 0);
    162160    template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, std::chrono::milliseconds timeout);
    163161
    164162    std::unique_ptr<MessageEncoder> createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID);
    165163    bool sendMessage(std::unique_ptr<MessageEncoder>, unsigned messageSendFlags = 0);
    166     std::unique_ptr<MessageDecoder> sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<MessageEncoder>, double timeout, unsigned syncSendFlags = 0);
    167     std::unique_ptr<MessageDecoder> sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<MessageEncoder>, double timeout);
     164    std::unique_ptr<MessageDecoder> sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<MessageEncoder>, std::chrono::milliseconds timeout, unsigned syncSendFlags = 0);
     165    std::unique_ptr<MessageDecoder> sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<MessageEncoder>, std::chrono::milliseconds timeout);
    168166    bool sendSyncReply(std::unique_ptr<MessageEncoder>);
    169167
     
    184182    std::unique_ptr<MessageDecoder> waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout);
    185183   
    186     std::unique_ptr<MessageDecoder> waitForSyncReply(uint64_t syncRequestID, double timeout, unsigned syncSendFlags);
     184    std::unique_ptr<MessageDecoder> waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, unsigned syncSendFlags);
    187185
    188186    // Called on the connection work queue.
     
    322320}
    323321
    324 template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, double timeout, unsigned syncSendFlags)
     322template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout, unsigned syncSendFlags)
    325323{
    326324    COMPILE_ASSERT(T::isSync, SyncMessageExpected);
  • trunk/Source/WebKit2/Platform/IPC/MessageSender.h

    r160549 r161152  
    5252
    5353    template<typename T>
    54     bool sendSync(T&& message, typename T::Reply&& reply, double timeout = Connection::NoTimeout, unsigned syncSendFlags = 0)
     54    bool sendSync(T&& message, typename T::Reply&& reply, std::chrono::milliseconds timeout = std::chrono::milliseconds::max(), unsigned syncSendFlags = 0)
    5555    {
    5656        static_assert(T::isSync, "Message is not sync!");
     
    6060
    6161    template<typename T>
    62     bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, double timeout = Connection::NoTimeout, unsigned syncSendFlags = 0)
     62    bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::milliseconds::max(), unsigned syncSendFlags = 0)
    6363    {
    6464        ASSERT(messageSenderConnection());
  • trunk/Source/WebKit2/Shared/ChildProcessProxy.h

    r161148 r161152  
    4949
    5050    template<typename T> bool send(T&& message, uint64_t destinationID, unsigned messageSendFlags = 0);
    51     template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, double timeout = 1);
     51    template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::seconds(1));
    5252   
    5353    IPC::Connection* connection() const
     
    102102
    103103template<typename U>
    104 bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, double timeout)
     104bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout)
    105105{
    106106    COMPILE_ASSERT(U::isSync, SyncMessageExpected);
  • trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r161148 r161152  
    322322        return value;
    323323   
    324     const double messageTimeout = 20;
     324    const auto messageTimeout = std::chrono::seconds(20);
    325325    process().sendSync(Messages::WebPage::GetStringSelectionForPasteboard(), Messages::WebPage::GetStringSelectionForPasteboard::Reply(value), m_pageID, messageTimeout);
    326326    return value;
     
    333333    SharedMemory::Handle handle;
    334334    uint64_t size = 0;
    335     const double messageTimeout = 20;
     335    const auto messageTimeout = std::chrono::seconds(20);
    336336    process().sendSync(Messages::WebPage::GetDataSelectionForPasteboard(pasteboardType),
    337337                                                Messages::WebPage::GetDataSelectionForPasteboard::Reply(handle, size), m_pageID, messageTimeout);
     
    348348
    349349    bool result = false;
    350     const double messageTimeout = 20;
     350    const auto messageTimeout = std::chrono::seconds(20);
    351351    process().sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, messageTimeout);
    352352    return result;
     
    479479
    480480    bool result = false;
    481     const double messageTimeout = 3;
     481    const auto messageTimeout = std::chrono::seconds(3);
    482482    process().sendSync(Messages::WebPage::ShouldDelayWindowOrderingEvent(event), Messages::WebPage::ShouldDelayWindowOrderingEvent::Reply(result), m_pageID, messageTimeout);
    483483    return result;
     
    490490
    491491    bool result = false;
    492     const double messageTimeout = 3;
     492    const auto messageTimeout = std::chrono::seconds(3);
    493493    process().sendSync(Messages::WebPage::AcceptsFirstMouse(eventNumber, event), Messages::WebPage::AcceptsFirstMouse::Reply(result), m_pageID, messageTimeout);
    494494    return result;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r161148 r161152  
    117117    encoder->encode(InjectedBundleUserMessageEncoder(messageBody));
    118118
    119     std::unique_ptr<IPC::MessageDecoder> replyDecoder = WebProcess::shared().parentProcessConnection()->sendSyncMessage(syncRequestID, std::move(encoder), IPC::Connection::NoTimeout);
     119    std::unique_ptr<IPC::MessageDecoder> replyDecoder = WebProcess::shared().parentProcessConnection()->sendSyncMessage(syncRequestID, std::move(encoder), std::chrono::milliseconds::max());
    120120    if (!replyDecoder || !replyDecoder->decode(messageDecoder)) {
    121121        returnData = nullptr;
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r161148 r161152  
    351351    // FIXME (126021): It is not good to change IPC behavior conditionally, and SpinRunLoopWhileWaitingForReply was known to cause trouble in other similar cases.
    352352    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? IPC::SpinRunLoopWhileWaitingForReply : 0;
    353     WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), IPC::Connection::NoTimeout, syncSendFlags);
     353    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), std::chrono::milliseconds::max(), syncSendFlags);
    354354}
    355355
     
    366366    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? IPC::SpinRunLoopWhileWaitingForReply : 0;
    367367    bool result = false;
    368     if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), IPC::Connection::NoTimeout, syncSendFlags))
     368    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), std::chrono::milliseconds::max(), syncSendFlags))
    369369        return false;
    370370
     
    383383    // FIXME (126021): It is not good to change IPC behavior conditionally, and SpinRunLoopWhileWaitingForReply was known to cause trouble in other similar cases.
    384384    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? IPC::SpinRunLoopWhileWaitingForReply : 0;
    385     if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), IPC::Connection::NoTimeout, syncSendFlags))
     385    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), std::chrono::milliseconds::max(), syncSendFlags))
    386386        return false;
    387387
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r161148 r161152  
    651651    // FIXME (126021): It is not good to change IPC behavior conditionally, and SpinRunLoopWhileWaitingForReply was known to cause trouble in other similar cases.
    652652    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? IPC::SpinRunLoopWhileWaitingForReply : 0;
    653     if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponseSync(m_frame->frameID(), response, request, canShowMIMEType, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForResponseSync::Reply(receivedPolicyAction, policyAction, downloadID), IPC::Connection::NoTimeout, syncSendFlags))
     653    if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponseSync(m_frame->frameID(), response, request, canShowMIMEType, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForResponseSync::Reply(receivedPolicyAction, policyAction, downloadID), std::chrono::milliseconds::max(), syncSendFlags))
    654654        return;
    655655
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp

    r161148 r161152  
    7979    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebInspectorProxy::CreateInspectorPage(),
    8080            Messages::WebInspectorProxy::CreateInspectorPage::Reply(inspectorPageID, parameters),
    81             m_page->pageID(), IPC::Connection::NoTimeout)) {
     81            m_page->pageID(), std::chrono::milliseconds::max())) {
    8282        return 0;
    8383    }
Note: See TracChangeset for help on using the changeset viewer.