Changeset 161152 in webkit
- Timestamp:
- Dec 30, 2013 1:43:44 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r161150 r161152 1 2013-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 1 35 2013-12-30 Anders Carlsson <andersca@apple.com> 2 36 -
trunk/Source/WebKit2/Platform/IPC/Connection.cpp
r161148 r161152 431 431 } 432 432 433 std::unique_ptr<MessageDecoder> Connection::sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, doubletimeout, unsigned syncSendFlags)433 std::unique_ptr<MessageDecoder> Connection::sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, std::chrono::milliseconds timeout, unsigned syncSendFlags) 434 434 { 435 435 if (RunLoop::current() != m_clientRunLoop) { … … 480 480 } 481 481 482 std::unique_ptr<MessageDecoder> Connection::sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, doubletimeout)482 std::unique_ptr<MessageDecoder> Connection::sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, std::chrono::milliseconds timeout) 483 483 { 484 484 ASSERT(RunLoop::current() != m_clientRunLoop); … … 501 501 sendMessage(std::move(encoder), 0); 502 502 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)); 508 504 509 505 // Finally, pop the pending sync reply information. … … 517 513 } 518 514 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; 515 std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, unsigned syncSendFlags) 516 { 517 double absoluteTime = currentTime() + (timeout.count() / 1000.0); 526 518 527 519 bool timedOut = false; -
trunk/Source/WebKit2/Platform/IPC/Connection.h
r161148 r161152 156 156 void postConnectionDidCloseOnConnectionWorkQueue(); 157 157 158 static const int NoTimeout = -1;159 160 158 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); 162 160 template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, std::chrono::milliseconds timeout); 163 161 164 162 std::unique_ptr<MessageEncoder> createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID); 165 163 bool sendMessage(std::unique_ptr<MessageEncoder>, unsigned messageSendFlags = 0); 166 std::unique_ptr<MessageDecoder> sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<MessageEncoder>, doubletimeout, unsigned syncSendFlags = 0);167 std::unique_ptr<MessageDecoder> sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<MessageEncoder>, doubletimeout);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); 168 166 bool sendSyncReply(std::unique_ptr<MessageEncoder>); 169 167 … … 184 182 std::unique_ptr<MessageDecoder> waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout); 185 183 186 std::unique_ptr<MessageDecoder> waitForSyncReply(uint64_t syncRequestID, doubletimeout, unsigned syncSendFlags);184 std::unique_ptr<MessageDecoder> waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, unsigned syncSendFlags); 187 185 188 186 // Called on the connection work queue. … … 322 320 } 323 321 324 template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, doubletimeout, unsigned syncSendFlags)322 template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout, unsigned syncSendFlags) 325 323 { 326 324 COMPILE_ASSERT(T::isSync, SyncMessageExpected); -
trunk/Source/WebKit2/Platform/IPC/MessageSender.h
r160549 r161152 52 52 53 53 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) 55 55 { 56 56 static_assert(T::isSync, "Message is not sync!"); … … 60 60 61 61 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) 63 63 { 64 64 ASSERT(messageSenderConnection()); -
trunk/Source/WebKit2/Shared/ChildProcessProxy.h
r161148 r161152 49 49 50 50 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)); 52 52 53 53 IPC::Connection* connection() const … … 102 102 103 103 template<typename U> 104 bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, doubletimeout)104 bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout) 105 105 { 106 106 COMPILE_ASSERT(U::isSync, SyncMessageExpected); -
trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
r161148 r161152 322 322 return value; 323 323 324 const double messageTimeout = 20;324 const auto messageTimeout = std::chrono::seconds(20); 325 325 process().sendSync(Messages::WebPage::GetStringSelectionForPasteboard(), Messages::WebPage::GetStringSelectionForPasteboard::Reply(value), m_pageID, messageTimeout); 326 326 return value; … … 333 333 SharedMemory::Handle handle; 334 334 uint64_t size = 0; 335 const double messageTimeout = 20;335 const auto messageTimeout = std::chrono::seconds(20); 336 336 process().sendSync(Messages::WebPage::GetDataSelectionForPasteboard(pasteboardType), 337 337 Messages::WebPage::GetDataSelectionForPasteboard::Reply(handle, size), m_pageID, messageTimeout); … … 348 348 349 349 bool result = false; 350 const double messageTimeout = 20;350 const auto messageTimeout = std::chrono::seconds(20); 351 351 process().sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, messageTimeout); 352 352 return result; … … 479 479 480 480 bool result = false; 481 const double messageTimeout = 3;481 const auto messageTimeout = std::chrono::seconds(3); 482 482 process().sendSync(Messages::WebPage::ShouldDelayWindowOrderingEvent(event), Messages::WebPage::ShouldDelayWindowOrderingEvent::Reply(result), m_pageID, messageTimeout); 483 483 return result; … … 490 490 491 491 bool result = false; 492 const double messageTimeout = 3;492 const auto messageTimeout = std::chrono::seconds(3); 493 493 process().sendSync(Messages::WebPage::AcceptsFirstMouse(eventNumber, event), Messages::WebPage::AcceptsFirstMouse::Reply(result), m_pageID, messageTimeout); 494 494 return result; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
r161148 r161152 117 117 encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); 118 118 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()); 120 120 if (!replyDecoder || !replyDecoder->decode(messageDecoder)) { 121 121 returnData = nullptr; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r161148 r161152 351 351 // FIXME (126021): It is not good to change IPC behavior conditionally, and SpinRunLoopWhileWaitingForReply was known to cause trouble in other similar cases. 352 352 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); 354 354 } 355 355 … … 366 366 unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? IPC::SpinRunLoopWhileWaitingForReply : 0; 367 367 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)) 369 369 return false; 370 370 … … 383 383 // FIXME (126021): It is not good to change IPC behavior conditionally, and SpinRunLoopWhileWaitingForReply was known to cause trouble in other similar cases. 384 384 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)) 386 386 return false; 387 387 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r161148 r161152 651 651 // FIXME (126021): It is not good to change IPC behavior conditionally, and SpinRunLoopWhileWaitingForReply was known to cause trouble in other similar cases. 652 652 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)) 654 654 return; 655 655 -
trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
r161148 r161152 79 79 if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebInspectorProxy::CreateInspectorPage(), 80 80 Messages::WebInspectorProxy::CreateInspectorPage::Reply(inspectorPageID, parameters), 81 m_page->pageID(), IPC::Connection::NoTimeout)) {81 m_page->pageID(), std::chrono::milliseconds::max())) { 82 82 return 0; 83 83 }
Note: See TracChangeset
for help on using the changeset viewer.