WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-138018-20141114030826.patch (text/plain), 11.98 KB, created by
Zan Dobersek
on 2014-11-14 03:07:24 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2014-11-14 03:07:24 PST
Size:
11.98 KB
patch
obsolete
>Subversion Revision: 176120 >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index df881ed99e54a3c5f726c6cdceaca9444ba35024..98c25c0b95e189cc1d8dc62f810ba8c8fba6b904 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,30 @@ >+2014-11-14 Zan Dobersek <zdobersek@igalia.com> >+ >+ [WK2] Use C++ lambdas in IPC::Connection >+ https://bugs.webkit.org/show_bug.cgi?id=138018 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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): 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::initializeDeadNameSource): >+ (IPC::Connection::receiveSourceEventHandler): >+ * Platform/IPC/unix/ConnectionUnix.cpp: >+ (IPC::Connection::open): >+ > 2014-11-14 Carlos Garcia Campos <cgarcia@igalia.com> > > [SOUP] Encode/Decode allowCookies in ResourceRequest >diff --git a/Source/WebKit2/Platform/IPC/Connection.cpp b/Source/WebKit2/Platform/IPC/Connection.cpp >index 0cc5483a3b3c30697b4f3273cea1c98ff86b2771..991229ff4d1f52ec8be87d4130f4a662c98a65d6 100644 >--- a/Source/WebKit2/Platform/IPC/Connection.cpp >+++ b/Source/WebKit2/Platform/IPC/Connection.cpp >@@ -164,8 +164,13 @@ bool Connection::SyncMessageState::processIncomingMessage(Connection* connection > { > 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::removeWorkQueueMessageReceiver(StringReference messageReceiverN > }); > } > >-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 @@ void Connection::invalidate() > } > > // 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 @@ bool Connection::sendMessage(std::unique_ptr<MessageEncoder> encoder, unsigned m > } > > // 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,25 @@ void Connection::processIncomingMessage(std::unique_ptr<MessageDecoder> message) > } > > 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(); >+ RefPtr<Connection> protectedThis(this); >+ StringReference messageReceiverName = message->messageReceiverName().isEmpty() ? "<unknown message receiver>" : message->messageReceiverName(); >+ StringReference messageName = message->messageName().isEmpty() ? "<unknown message>" : message->messageName(); > >- m_clientRunLoop.dispatch(bind(&Connection::dispatchDidReceiveInvalidMessage, this, messageReceiverName, messageName)); >- return; >- } >- >- m_clientRunLoop.dispatch(bind(&Connection::dispatchDidReceiveInvalidMessage, this, message->messageReceiverName().toString(), message->messageName().toString())); >+ 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; > } > >@@ -776,14 +787,14 @@ void Connection::dispatchSyncMessage(MessageDecoder& decoder) > sendSyncReply(WTF::move(replyEncoder)); > } > >-void Connection::dispatchDidReceiveInvalidMessage(const CString& messageReceiverNameString, const CString& messageNameString) >+void Connection::dispatchDidReceiveInvalidMessage(StringReference messageReceiverName, StringReference messageName) > { > ASSERT(&RunLoop::current() == &m_clientRunLoop); > > if (!m_client) > return; > >- m_client->didReceiveInvalidMessage(this, StringReference(messageReceiverNameString.data(), messageReceiverNameString.length()), StringReference(messageNameString.data(), messageNameString.length())); >+ m_client->didReceiveInvalidMessage(this, messageReceiverName, messageName); > } > > void Connection::didFailToSendSyncMessage() >@@ -801,7 +812,10 @@ void Connection::enqueueIncomingMessage(std::unique_ptr<MessageDecoder> incoming > 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) >diff --git a/Source/WebKit2/Platform/IPC/Connection.h b/Source/WebKit2/Platform/IPC/Connection.h >index b52cf1ee00e0697832e60a07dd91a80dea33a8ad..c1bc7b7a3218f9ce9f1fd38317cd19d7e6d47bff 100644 >--- a/Source/WebKit2/Platform/IPC/Connection.h >+++ b/Source/WebKit2/Platform/IPC/Connection.h >@@ -222,7 +222,7 @@ private: > void dispatchMessage(std::unique_ptr<MessageDecoder>); > void dispatchMessage(MessageDecoder&); > void dispatchSyncMessage(MessageDecoder&); >- void dispatchDidReceiveInvalidMessage(const CString& messageReceiverNameString, const CString& messageNameString); >+ void dispatchDidReceiveInvalidMessage(StringReference messageReceiverName, StringReference messageName); > void didFailToSendSyncMessage(); > > // Can be called on any thread. >diff --git a/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm b/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm >index c0845ecea972f909370063b9b2ecf145fc3e6949..dabb07f167452b4088e46c2aa4e6628e339feb89 100644 >--- a/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm >+++ b/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm >@@ -361,7 +361,11 @@ bool Connection::sendOutgoingMessage(std::unique_ptr<MessageEncoder> encoder) > 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, ^{ >@@ -504,7 +508,13 @@ void Connection::receiveSourceEventHandler() > 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); >+ StringReference messageReceiverName = decoder->messageReceiverName(); >+ StringReference messageName = decoder->messageName(); >+ >+ m_clientRunLoop.dispatch([protectedThis, messageReceiverName, messageName] { >+ protectedThis->dispatchDidReceiveInvalidMessage(messageReceiverName, messageName); >+ }); > return; > } > MachPort exceptionPort; >diff --git a/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp b/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp >index 16be014e8739fac4d970449bfa14d0619498db86..4dd95fd0d923a62387b0ce39e460aefdc35157f9 100644 >--- a/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp >+++ b/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp >@@ -388,27 +388,27 @@ bool Connection::open() > } > } > >+ 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; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 138018
:
240365
|
240621
|
241571
|
244888
|
248196
|
248241
|
248321
|
248326