Modified: trunk/Source/WebKit2/ChangeLog (175805 => 175806)
--- trunk/Source/WebKit2/ChangeLog 2014-11-10 10:48:30 UTC (rev 175805)
+++ trunk/Source/WebKit2/ChangeLog 2014-11-10 12:29:57 UTC (rev 175806)
@@ -1,3 +1,25 @@
+2014-11-10 Zan Dobersek <[email protected]>
+
+ [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++11 lambdas.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::SyncMessageState::processIncomingMessage):
+ (IPC::Connection::dispatchWorkQueueMessageReceiverMessage):
+ (IPC::Connection::invalidate):
+ (IPC::Connection::sendMessage):
+ (IPC::Connection::processIncomingMessage):
+ (IPC::Connection::enqueueIncomingMessage):
+ * Platform/IPC/mac/ConnectionMac.mm:
+ (IPC::Connection::initializeDeadNameSource):
+ (IPC::Connection::receiveSourceEventHandler):
+ * Platform/IPC/unix/ConnectionUnix.cpp:
+ (IPC::Connection::open):
+
2014-11-09 Gyuyoung Kim <[email protected]>
Remove create() factory function in FooAnimationValue classes
Modified: trunk/Source/WebKit2/Platform/IPC/Connection.cpp (175805 => 175806)
--- trunk/Source/WebKit2/Platform/IPC/Connection.cpp 2014-11-10 10:48:30 UTC (rev 175805)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.cpp 2014-11-10 12:29:57 UTC (rev 175806)
@@ -164,8 +164,13 @@
{
MutexLocker locker(m_mutex);
- if (m_didScheduleDispatchMessagesWorkSet.add(connection).isNewEntry)
- m_runLoop.dispatch(bind(&SyncMessageState::dispatchMessageAndResetDidScheduleDispatchMessagesForConnection, this, RefPtr<Connection>(connection)));
+ if (m_didScheduleDispatchMessagesWorkSet.add(connection).isNewEntry) {
+ RefPtr<SyncMessageState> protectedThis(this);
+ RefPtr<Connection> protectedConnection(connection);
+ m_runLoop.dispatch([protectedThis, protectedConnection] {
+ protectedThis->dispatchMessageAndResetDidScheduleDispatchMessagesForConnection(protectedConnection.get());
+ });
+ }
m_messagesToDispatchWhileWaitingForSyncReply.append(WTF::move(connectionAndIncomingMessage));
}
@@ -296,10 +301,8 @@
});
}
-void Connection::dispatchWorkQueueMessageReceiverMessage(WorkQueueMessageReceiver* workQueueMessageReceiver, MessageDecoder* incomingMessageDecoder)
+void Connection::dispatchWorkQueueMessageReceiverMessage(WorkQueueMessageReceiver* workQueueMessageReceiver, MessageDecoder* decoder)
{
- std::unique_ptr<MessageDecoder> decoder(incomingMessageDecoder);
-
if (!decoder->isSyncMessage()) {
workQueueMessageReceiver->didReceiveMessage(this, *decoder);
return;
@@ -340,9 +343,12 @@
}
// Reset the client.
- m_client = 0;
+ m_client = nullptr;
- m_connectionQueue->dispatch(WTF::bind(&Connection::platformInvalidate, this));
+ RefPtr<Connection> protectedThis(this);
+ m_connectionQueue->dispatch([protectedThis] {
+ protectedThis->platformInvalidate();
+ });
}
void Connection::markCurrentlyDispatchedMessageAsInvalid()
@@ -381,7 +387,10 @@
}
// FIXME: We should add a boolean flag so we don't call this when work has already been scheduled.
- m_connectionQueue->dispatch(WTF::bind(&Connection::sendOutgoingMessages, this));
+ RefPtr<Connection> protectedThis(this);
+ m_connectionQueue->dispatch([protectedThis] {
+ protectedThis->sendOutgoingMessages();
+ });
return true;
}
@@ -629,23 +638,27 @@
}
if (!m_workQueueMessageReceivers.isValidKey(message->messageReceiverName())) {
- 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();
+ // Something might have gone wrong when decoding the message. In that case, encode the message length
+ // so we can figure out if this happens for certain message lengths.
+ CString messageReceiverName = message->messageReceiverName().isEmpty() ? "<unknown message>" : message->messageReceiverName().toString();
+ CString messageName = message->messageName().isEmpty() ? String::format("<message length: %zu bytes>", message->length()).utf8() : message->messageReceiverName().toString();
- m_clientRunLoop.dispatch(bind(&Connection::dispatchDidReceiveInvalidMessage, this, messageReceiverName, messageName));
- return;
- }
-
- m_clientRunLoop.dispatch(bind(&Connection::dispatchDidReceiveInvalidMessage, this, message->messageReceiverName().toString(), message->messageName().toString()));
+ RefPtr<Connection> protectedThis(this);
+ m_clientRunLoop.dispatch([protectedThis, messageReceiverName, messageName] {
+ protectedThis->dispatchDidReceiveInvalidMessage(messageReceiverName, messageName);
+ });
return;
}
auto it = m_workQueueMessageReceivers.find(message->messageReceiverName());
if (it != m_workQueueMessageReceivers.end()) {
- it->value.first->dispatch(bind(&Connection::dispatchWorkQueueMessageReceiverMessage, this, it->value.second, message.release()));
+ 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.get(), decoder.get());
+ });
return;
}
@@ -801,7 +814,10 @@
m_incomingMessages.append(WTF::move(incomingMessage));
}
- m_clientRunLoop.dispatch(WTF::bind(&Connection::dispatchOneMessage, this));
+ RefPtr<Connection> protectedThis(this);
+ m_clientRunLoop.dispatch([protectedThis] {
+ protectedThis->dispatchOneMessage();
+ });
}
void Connection::dispatchMessage(MessageDecoder& decoder)
Modified: trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm (175805 => 175806)
--- trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm 2014-11-10 10:48:30 UTC (rev 175805)
+++ trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm 2014-11-10 12:29:57 UTC (rev 175806)
@@ -361,8 +361,12 @@
void Connection::initializeDeadNameSource()
{
m_deadNameSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_SEND, m_sendPort, 0, m_connectionQueue->dispatchQueue());
- dispatch_source_set_event_handler(m_deadNameSource, bind(&Connection::connectionDidClose, this));
+ RefPtr<Connection> protectedThis(this);
+ dispatch_source_set_event_handler(m_deadNameSource, ^{
+ protectedThis->connectionDidClose();
+ });
+
mach_port_t sendPort = m_sendPort;
dispatch_source_set_cancel_handler(m_deadNameSource, ^{
// Release our send right.
@@ -504,7 +508,12 @@
if (decoder->messageReceiverName() == "IPC" && decoder->messageName() == "SetExceptionPort") {
if (m_isServer) {
// Server connections aren't supposed to have their exception ports overriden. Treat this as an invalid message.
- m_clientRunLoop.dispatch(bind(&Connection::dispatchDidReceiveInvalidMessage, this, decoder->messageReceiverName().toString(), decoder->messageName().toString()));
+ RefPtr<Connection> protectedThis(this);
+ CString messageReceiverNameString = decoder->messageReceiverName().toString();
+ CString messageNameString = decoder->messageName().toString();
+ m_clientRunLoop.dispatch([protectedThis, messageReceiverNameString, messageNameString] {
+ protectedThis->dispatchDidReceiveInvalidMessage(messageReceiverNameString, messageNameString);
+ });
return;
}
MachPort exceptionPort;
Modified: trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp (175805 => 175806)
--- trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp 2014-11-10 10:48:30 UTC (rev 175805)
+++ trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp 2014-11-10 12:29:57 UTC (rev 175806)
@@ -388,27 +388,27 @@
}
}
+ RefPtr<Connection> protectedThis(this);
m_isConnected = true;
#if PLATFORM(GTK)
- RefPtr<Connection> protector(this);
m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
- [=] {
- protector->readyReadHandler();
+ [protectedThis] {
+ protectedThis->readyReadHandler();
},
- [=] {
- protector->connectionDidClose();
+ [protectedThis] {
+ protectedThis->connectionDidClose();
});
#elif PLATFORM(EFL)
- RefPtr<Connection> protector(this);
m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
- [protector] {
- protector->readyReadHandler();
+ [protectedThis] {
+ protectedThis->readyReadHandler();
});
#endif
- // Schedule a call to readyReadHandler. Data may have arrived before installation of the signal
- // handler.
- m_connectionQueue->dispatch(WTF::bind(&Connection::readyReadHandler, this));
+ // Schedule a call to readyReadHandler. Data may have arrived before installation of the signal handler.
+ m_connectionQueue->dispatch([protectedThis] {
+ protectedThis->readyReadHandler();
+ });
return true;
}