<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[181630] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/181630">181630</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2015-03-17 03:04:34 -0700 (Tue, 17 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WK2] Use C++ lambdas in IPC::Connection
https://bugs.webkit.org/show_bug.cgi?id=138018
Reviewed by Anders Carlsson.
Replace uses of WTF::bind() in the IPC::Connection class with C++ lambdas.
* Platform/IPC/Connection.cpp:
(IPC::Connection::dispatchWorkQueueMessageReceiverMessage):
(IPC::Connection::invalidate):
(IPC::Connection::sendMessage):
(IPC::Connection::processIncomingMessage): Simplify the error messages so we
don't have to format strings on-the-fly, removing the issues of cross-thread
string copying altogether.
(IPC::Connection::dispatchDidReceiveInvalidMessage): The parameters are now
of the StringReference type.
(IPC::Connection::enqueueIncomingMessage):
* Platform/IPC/Connection.h:
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::receiveSourceEventHandler):
* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::open):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCConnectioncpp">trunk/Source/WebKit2/Platform/IPC/Connection.cpp</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCConnectionh">trunk/Source/WebKit2/Platform/IPC/Connection.h</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCmacConnectionMacmm">trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCunixConnectionUnixcpp">trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (181629 => 181630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-03-17 09:45:55 UTC (rev 181629)
+++ trunk/Source/WebKit2/ChangeLog        2015-03-17 10:04:34 UTC (rev 181630)
</span><span class="lines">@@ -1,5 +1,30 @@
</span><span class="cx"> 2015-03-17 Zan Dobersek <zdobersek@igalia.com>
</span><span class="cx">
</span><ins>+ [WK2] Use C++ lambdas in IPC::Connection
+ https://bugs.webkit.org/show_bug.cgi?id=138018
+
+ Reviewed by Anders Carlsson.
+
+ Replace uses of WTF::bind() in the IPC::Connection class with C++ lambdas.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::dispatchWorkQueueMessageReceiverMessage):
+ (IPC::Connection::invalidate):
+ (IPC::Connection::sendMessage):
+ (IPC::Connection::processIncomingMessage): Simplify the error messages so we
+ don't have to format strings on-the-fly, removing the issues of cross-thread
+ string copying altogether.
+ (IPC::Connection::dispatchDidReceiveInvalidMessage): The parameters are now
+ of the StringReference type.
+ (IPC::Connection::enqueueIncomingMessage):
+ * Platform/IPC/Connection.h:
+ * Platform/IPC/mac/ConnectionMac.mm:
+ (IPC::Connection::receiveSourceEventHandler):
+ * Platform/IPC/unix/ConnectionUnix.cpp:
+ (IPC::Connection::open):
+
+2015-03-17 Zan Dobersek <zdobersek@igalia.com>
+
</ins><span class="cx"> [CMake] Use a forwarding header for ANGLE's ShaderLang.h to avoid picking up ANGLE's EGL headers
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=142530
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/Connection.cpp (181629 => 181630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/Connection.cpp        2015-03-17 09:45:55 UTC (rev 181629)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.cpp        2015-03-17 10:04:34 UTC (rev 181630)
</span><span class="lines">@@ -300,34 +300,32 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Connection::dispatchWorkQueueMessageReceiverMessage(WorkQueueMessageReceiver* workQueueMessageReceiver, MessageDecoder* incomingMessageDecoder)
</del><ins>+void Connection::dispatchWorkQueueMessageReceiverMessage(WorkQueueMessageReceiver& workQueueMessageReceiver, MessageDecoder& decoder)
</ins><span class="cx"> {
</span><del>- std::unique_ptr<MessageDecoder> decoder(incomingMessageDecoder);
-
- if (!decoder->isSyncMessage()) {
- workQueueMessageReceiver->didReceiveMessage(*this, *decoder);
</del><ins>+ if (!decoder.isSyncMessage()) {
+ workQueueMessageReceiver.didReceiveMessage(*this, decoder);
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> uint64_t syncRequestID = 0;
</span><del>- if (!decoder->decode(syncRequestID) || !syncRequestID) {
</del><ins>+ if (!decoder.decode(syncRequestID) || !syncRequestID) {
</ins><span class="cx"> // We received an invalid sync message.
</span><span class="cx"> // FIXME: Handle this.
</span><del>- decoder->markInvalid();
</del><ins>+ decoder.markInvalid();
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if HAVE(DTRACE)
</span><del>- auto replyEncoder = std::make_unique<MessageEncoder>("IPC", "SyncMessageReply", syncRequestID, incomingMessageDecoder->UUID());
</del><ins>+ auto replyEncoder = std::make_unique<MessageEncoder>("IPC", "SyncMessageReply", syncRequestID, decoder.UUID());
</ins><span class="cx"> #else
</span><span class="cx"> auto replyEncoder = std::make_unique<MessageEncoder>("IPC", "SyncMessageReply", syncRequestID);
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> // Hand off both the decoder and encoder to the work queue message receiver.
</span><del>- workQueueMessageReceiver->didReceiveSyncMessage(*this, *decoder, replyEncoder);
</del><ins>+ workQueueMessageReceiver.didReceiveSyncMessage(*this, decoder, replyEncoder);
</ins><span class="cx">
</span><span class="cx"> // FIXME: If the message was invalid, we should send back a SyncMessageError.
</span><del>- ASSERT(!decoder->isInvalid());
</del><ins>+ ASSERT(!decoder.isInvalid());
</ins><span class="cx">
</span><span class="cx"> if (replyEncoder)
</span><span class="cx"> sendSyncReply(WTF::move(replyEncoder));
</span><span class="lines">@@ -347,10 +345,12 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Reset the client.
- m_client = 0;
</del><ins>+ m_client = nullptr;
</ins><span class="cx">
</span><del>- m_connectionQueue->dispatch(WTF::bind(&Connection::platformInvalidate, this));
</del><ins>+ RefPtr<Connection> protectedThis(this);
+ m_connectionQueue->dispatch([protectedThis] {
+ protectedThis->platformInvalidate();
+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Connection::markCurrentlyDispatchedMessageAsInvalid()
</span><span class="lines">@@ -397,7 +397,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // FIXME: We should add a boolean flag so we don't call this when work has already been scheduled.
</span><del>- m_connectionQueue->dispatch(WTF::bind(&Connection::sendOutgoingMessages, this));
</del><ins>+ RefPtr<Connection> protectedThis(this);
+ m_connectionQueue->dispatch([protectedThis] {
+ protectedThis->sendOutgoingMessages();
+ });
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -653,23 +656,27 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!m_workQueueMessageReceivers.isValidKey(message->messageReceiverName())) {
</span><del>- if (message->messageReceiverName().isEmpty() && message->messageName().isEmpty()) {
- // Something went wrong when decoding the message. Encode the message length so we can figure out if this
- // happens for certain message lengths.
- CString messageReceiverName = "<unknown message>";
- CString messageName = String::format("<message length: %zu bytes>", message->length()).utf8();
</del><ins>+ RefPtr<Connection> protectedThis(this);
+ StringReference messageReceiverName = message->messageReceiverName();
+ StringCapture capturedMessageReceiverName(messageReceiverName.isEmpty() ? "<unknown message receiver>" : String(messageReceiverName.data(), messageReceiverName.size()));
+ StringReference messageName = message->messageName();
+ StringCapture capturedMessageName(messageName.isEmpty() ? "<unknown message>" : String(messageName.data(), messageName.size()));
</ins><span class="cx">
</span><del>- m_clientRunLoop.dispatch(bind(&Connection::dispatchDidReceiveInvalidMessage, this, messageReceiverName, messageName));
- return;
- }
-
- m_clientRunLoop.dispatch(bind(&Connection::dispatchDidReceiveInvalidMessage, this, message->messageReceiverName().toString(), message->messageName().toString()));
</del><ins>+ m_clientRunLoop.dispatch([protectedThis, capturedMessageReceiverName, capturedMessageName] {
+ protectedThis->dispatchDidReceiveInvalidMessage(capturedMessageReceiverName.string().utf8(), capturedMessageName.string().utf8());
+ });
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> auto it = m_workQueueMessageReceivers.find(message->messageReceiverName());
</span><span class="cx"> if (it != m_workQueueMessageReceivers.end()) {
</span><del>- it->value.first->dispatch(bind(&Connection::dispatchWorkQueueMessageReceiverMessage, this, it->value.second, message.release()));
</del><ins>+ RefPtr<Connection> protectedThis(this);
+ RefPtr<WorkQueueMessageReceiver>& workQueueMessageReceiver = it->value.second;
+ MessageDecoder* decoderPtr = message.release();
+ it->value.first->dispatch([protectedThis, workQueueMessageReceiver, decoderPtr] {
+ std::unique_ptr<MessageDecoder> decoder(decoderPtr);
+ protectedThis->dispatchWorkQueueMessageReceiverMessage(*workQueueMessageReceiver, *decoder);
+ });
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -829,7 +836,10 @@
</span><span class="cx"> m_incomingMessages.append(WTF::move(incomingMessage));
</span><span class="cx"> }
</span><span class="cx">
</span><del>- m_clientRunLoop.dispatch(WTF::bind(&Connection::dispatchOneMessage, this));
</del><ins>+ RefPtr<Connection> protectedThis(this);
+ m_clientRunLoop.dispatch([protectedThis] {
+ protectedThis->dispatchOneMessage();
+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Connection::dispatchMessage(MessageDecoder& decoder)
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (181629 => 181630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/Connection.h        2015-03-17 09:45:55 UTC (rev 181629)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h        2015-03-17 10:04:34 UTC (rev 181630)
</span><span class="lines">@@ -213,7 +213,7 @@
</span><span class="cx"> void processIncomingMessage(std::unique_ptr<MessageDecoder>);
</span><span class="cx"> void processIncomingSyncReply(std::unique_ptr<MessageDecoder>);
</span><span class="cx">
</span><del>- void dispatchWorkQueueMessageReceiverMessage(WorkQueueMessageReceiver*, MessageDecoder*);
</del><ins>+ void dispatchWorkQueueMessageReceiverMessage(WorkQueueMessageReceiver&, MessageDecoder&);
</ins><span class="cx">
</span><span class="cx"> bool canSendOutgoingMessages() const;
</span><span class="cx"> bool platformCanSendOutgoingMessages() const;
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCmacConnectionMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm (181629 => 181630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm        2015-03-17 09:45:55 UTC (rev 181629)
+++ trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm        2015-03-17 10:04:34 UTC (rev 181630)
</span><span class="lines">@@ -510,7 +510,14 @@
</span><span class="cx"> if (decoder->messageReceiverName() == "IPC" && decoder->messageName() == "SetExceptionPort") {
</span><span class="cx"> if (m_isServer) {
</span><span class="cx"> // Server connections aren't supposed to have their exception ports overriden. Treat this as an invalid message.
</span><del>- m_clientRunLoop.dispatch(bind(&Connection::dispatchDidReceiveInvalidMessage, this, decoder->messageReceiverName().toString(), decoder->messageName().toString()));
</del><ins>+ RefPtr<Connection> protectedThis(this);
+ StringReference messageReceiverName = decoder->messageReceiverName();
+ StringCapture capturedMessageReceiverName(String(messageReceiverName.data(), messageReceiverName.size()));
+ StringReference messageName = decoder->messageName();
+ StringCapture capturedMessageName(String(messageName.data(), messageName.size()));
+ m_clientRunLoop.dispatch([protectedThis, capturedMessageReceiverName, capturedMessageName] {
+ protectedThis->dispatchDidReceiveInvalidMessage(capturedMessageReceiverName.string().utf8(), capturedMessageName.string().utf8());
+ });
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> MachPort exceptionPort;
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCunixConnectionUnixcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp (181629 => 181630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp        2015-03-17 09:45:55 UTC (rev 181629)
+++ trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp        2015-03-17 10:04:34 UTC (rev 181630)
</span><span class="lines">@@ -388,27 +388,27 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ RefPtr<Connection> protectedThis(this);
</ins><span class="cx"> m_isConnected = true;
</span><span class="cx"> #if PLATFORM(GTK)
</span><del>- RefPtr<Connection> protector(this);
</del><span class="cx"> m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
</span><del>- [=] {
- protector->readyReadHandler();
</del><ins>+ [protectedThis] {
+ protectedThis->readyReadHandler();
</ins><span class="cx"> },
</span><del>- [=] {
- protector->connectionDidClose();
</del><ins>+ [protectedThis] {
+ protectedThis->connectionDidClose();
</ins><span class="cx"> });
</span><span class="cx"> #elif PLATFORM(EFL)
</span><del>- RefPtr<Connection> protector(this);
</del><span class="cx"> m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
</span><del>- [protector] {
- protector->readyReadHandler();
</del><ins>+ [protectedThis] {
+ protectedThis->readyReadHandler();
</ins><span class="cx"> });
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- // Schedule a call to readyReadHandler. Data may have arrived before installation of the signal
- // handler.
- m_connectionQueue->dispatch(WTF::bind(&Connection::readyReadHandler, this));
</del><ins>+ // Schedule a call to readyReadHandler. Data may have arrived before installation of the signal handler.
+ m_connectionQueue->dispatch([protectedThis] {
+ protectedThis->readyReadHandler();
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>