Diff
Modified: trunk/Source/WebKit2/ChangeLog (177791 => 177792)
--- trunk/Source/WebKit2/ChangeLog 2014-12-29 15:31:16 UTC (rev 177791)
+++ trunk/Source/WebKit2/ChangeLog 2014-12-29 17:46:02 UTC (rev 177792)
@@ -1,5 +1,53 @@
2014-12-28 Anders Carlsson <ander...@apple.com>
+ Use UserData when sending messages to the process pool
+ https://bugs.webkit.org/show_bug.cgi?id=139978
+
+ Reviewed by Sam Weinig.
+
+ * Scripts/webkit/messages.py:
+ (generate_message_handler):
+ Include the connection parameter for legacy receivers as well.
+
+ * Shared/CoreIPCSupport/WebContextMessageKinds.h:
+ Remove this, it's no longer needed.
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::didReceiveMessage):
+ No need to special case the postMessage message.
+
+ (WebKit::WebProcessPool::didReceiveSyncMessage):
+ No need to special case the postSynchronousMessageMessage message.
+
+ (WebKit::WebProcessPool::handleMessage):
+ Convert handles to objects and call didReceiveMessageFromInjectedBundle.
+
+ (WebKit::WebProcessPool::handleSynchronousMessage):
+ Convert handles to objects, call didReceiveSynchronousMessageFromInjectedBundle, and then
+ convert objects back to handles in the reply.
+
+ (WebKit::WebProcessPool::didReceiveMessageFromInjectedBundle): Deleted.
+ (WebKit::WebProcessPool::didReceiveSynchronousMessageFromInjectedBundle): Deleted.
+ (WebKit::WebProcessPool::dummy): Deleted.
+ * UIProcess/WebProcessPool.h:
+ Add handleMessage and handleSynchronousMessage message handlers.
+
+ * UIProcess/WebProcessPool.messages.in:
+ Add new messages.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ Remove a now unused file.
+
+ * WebProcess/InjectedBundle/InjectedBundle.cpp:
+ (WebKit::InjectedBundle::postMessage):
+ Convert objects to handles in the message body and then send the HandleMessage to the UI process.
+
+ (WebKit::InjectedBundle::postSynchronousMessage):
+ Convert objects to handles in the message body, send the HandleSynchronousMessage message to the UI process,
+ and then convert handles back to objects in the reply.
+
+2014-12-28 Anders Carlsson <ander...@apple.com>
+
Transform nested objects inside arrays
https://bugs.webkit.org/show_bug.cgi?id=139976
Modified: trunk/Source/WebKit2/Scripts/webkit/messages.py (177791 => 177792)
--- trunk/Source/WebKit2/Scripts/webkit/messages.py 2014-12-29 15:31:16 UTC (rev 177791)
+++ trunk/Source/WebKit2/Scripts/webkit/messages.py 2014-12-29 17:46:02 UTC (rev 177792)
@@ -533,7 +533,7 @@
if async_messages:
if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE):
- result.append('void %s::didReceive%sMessage(IPC::Connection*, IPC::MessageDecoder& decoder)\n' % (receiver.name, receiver.name))
+ result.append('void %s::didReceive%sMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)\n' % (receiver.name, receiver.name))
else:
result.append('void %s::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)\n' % (receiver.name))
@@ -552,9 +552,7 @@
result.append('\n')
use_connection = True
if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE):
- if not sync_delayed_messages:
- use_connection = False
- result.append('void %s::didReceiveSync%sMessage(IPC::Connection*%s, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)\n' % (receiver.name, receiver.name, ' connection' if use_connection else ''))
+ result.append('void %s::didReceiveSync%sMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)\n' % (receiver.name, receiver.name))
else:
result.append('void %s::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)\n' % (receiver.name))
result.append('{\n')
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (177791 => 177792)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2014-12-29 15:31:16 UTC (rev 177791)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2014-12-29 17:46:02 UTC (rev 177792)
@@ -38,7 +38,6 @@
#include "TextChecker.h"
#include "WKContextPrivate.h"
#include "WebApplicationCacheManagerProxy.h"
-#include "WebContextMessageKinds.h"
#include "WebContextSupplement.h"
#include "WebContextUserMessageCoders.h"
#include "WebCookieManagerProxy.h"
@@ -200,7 +199,6 @@
platformInitialize();
addMessageReceiver(Messages::WebProcessPool::messageReceiverName(), *this);
- addMessageReceiver(WebContextLegacyMessages::messageReceiverName(), *this);
// NOTE: These sub-objects must be initialized after m_messageReceiverMap..
m_iconDatabase = WebIconDatabase::create(this);
@@ -949,18 +947,6 @@
}
}
-// InjectedBundle client
-
-void WebProcessPool::didReceiveMessageFromInjectedBundle(const String& messageName, API::Object* messageBody)
-{
- m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, messageName, messageBody);
-}
-
-void WebProcessPool::didReceiveSynchronousMessageFromInjectedBundle(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData)
-{
- m_injectedBundleClient.didReceiveSynchronousMessageFromInjectedBundle(this, messageName, messageBody, returnData);
-}
-
void WebProcessPool::populateVisitedLinks()
{
m_historyClient->populateVisitedLinks(*this);
@@ -1144,20 +1130,6 @@
return;
}
- if (decoder.messageReceiverName() == WebContextLegacyMessages::messageReceiverName()
- && decoder.messageName() == WebContextLegacyMessages::postMessageMessageName()) {
- String messageName;
- RefPtr<API::Object> messageBody;
- WebContextUserMessageDecoder messageBodyDecoder(messageBody, *WebProcessProxy::fromConnection(connection));
- if (!decoder.decode(messageName))
- return;
- if (!decoder.decode(messageBodyDecoder))
- return;
-
- didReceiveMessageFromInjectedBundle(messageName, messageBody.get());
- return;
- }
-
ASSERT_NOT_REACHED();
}
@@ -1168,26 +1140,6 @@
return;
}
- if (decoder.messageReceiverName() == WebContextLegacyMessages::messageReceiverName()
- && decoder.messageName() == WebContextLegacyMessages::postSynchronousMessageMessageName()) {
- // FIXME: We should probably encode something in the case that the arguments do not decode correctly.
-
- WebProcessProxy* process = WebProcessProxy::fromConnection(connection);
-
- String messageName;
- RefPtr<API::Object> messageBody;
- WebContextUserMessageDecoder messageBodyDecoder(messageBody, *process);
- if (!decoder.decode(messageName))
- return;
- if (!decoder.decode(messageBodyDecoder))
- return;
-
- RefPtr<API::Object> returnData;
- didReceiveSynchronousMessageFromInjectedBundle(messageName, messageBody.get(), returnData);
- replyEncoder->encode(WebContextUserMessageEncoder(returnData.get(), *process));
- return;
- }
-
ASSERT_NOT_REACHED();
}
@@ -1380,12 +1332,23 @@
#endif
}
-#if !PLATFORM(COCOA)
-void WebProcessPool::dummy(bool&)
+void WebProcessPool::handleMessage(IPC::Connection* connection, const String& messageName, const WebKit::UserData& messageBody)
{
+ if (auto* webProcessProxy = WebProcessProxy::fromConnection(connection))
+ m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, messageName, webProcessProxy->transformHandlesToObjects(messageBody.object()).get());
}
-#endif
+void WebProcessPool::handleSynchronousMessage(IPC::Connection* connection, const String& messageName, const UserData& messageBody, UserData& returnUserData)
+{
+ auto* webProcessProxy = WebProcessProxy::fromConnection(connection);
+ if (!webProcessProxy)
+ return;
+
+ RefPtr<API::Object> returnData;
+ m_injectedBundleClient.didReceiveSynchronousMessageFromInjectedBundle(this, messageName, webProcessProxy->transformHandlesToObjects(messageBody.object()).get(), returnData);
+ returnUserData = UserData(webProcessProxy->transformObjectsToHandles(returnData.get()));
+}
+
void WebProcessPool::didGetStatistics(const StatisticsData& statisticsData, uint64_t requestID)
{
RefPtr<StatisticsRequest> request = m_statisticsRequests.take(requestID);
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (177791 => 177792)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h 2014-12-29 15:31:16 UTC (rev 177791)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h 2014-12-29 17:46:02 UTC (rev 177792)
@@ -188,10 +188,6 @@
void postMessageToInjectedBundle(const String&, API::Object*);
- // InjectedBundle client
- void didReceiveMessageFromInjectedBundle(const String&, API::Object*);
- void didReceiveSynchronousMessageFromInjectedBundle(const String&, API::Object*, RefPtr<API::Object>& returnData);
-
void populateVisitedLinks();
#if ENABLE(NETSCAPE_PLUGIN_API)
@@ -406,11 +402,8 @@
void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, uint64_t& newChangeCount);
#endif
-#if !PLATFORM(COCOA)
- // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
- // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
- void dummy(bool&);
-#endif
+ void handleMessage(IPC::Connection*, const String& messageName, const UserData& messageBody);
+ void handleSynchronousMessage(IPC::Connection*, const String& messageName, const UserData& messageBody, UserData& returnUserData);
void didGetStatistics(const StatisticsData&, uint64_t callbackID);
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.messages.in (177791 => 177792)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.messages.in 2014-12-29 15:31:16 UTC (rev 177791)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.messages.in 2014-12-29 17:46:02 UTC (rev 177792)
@@ -21,6 +21,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messages -> WebProcessPool LegacyReceiver {
+ HandleMessage(String messageName, WebKit::UserData messageBody) WantsConnection
+ HandleSynchronousMessage(String messageName, WebKit::UserData messageBody) -> (WebKit::UserData returnData) WantsConnection
DidGetStatistics(struct WebKit::StatisticsData statisticsData, uint64_t callbackID)
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (177791 => 177792)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2014-12-29 15:31:16 UTC (rev 177791)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2014-12-29 17:46:02 UTC (rev 177792)
@@ -1476,7 +1476,6 @@
BCC5715C115ADAEF001CCAF9 /* WebSystemInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCC5715A115ADAEF001CCAF9 /* WebSystemInterface.mm */; };
BCC8B374125FB69000DE46A4 /* WKGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC8B373125FB69000DE46A4 /* WKGeometry.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCC938E11180DE440085E5FE /* WKContextPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC938E01180DE440085E5FE /* WKContextPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
- BCCB75C61203A1CE00222D1B /* WebContextMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */; };
BCCF672D12C7EDF7008F9C35 /* OriginAndDatabases.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCF672C12C7EDF7008F9C35 /* OriginAndDatabases.h */; };
BCCF673312C7F15C008F9C35 /* OriginAndDatabases.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCF673212C7F15C008F9C35 /* OriginAndDatabases.cpp */; };
BCCF6ABC12C91EF9008F9C35 /* WebImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCF6ABA12C91EF9008F9C35 /* WebImage.cpp */; };
@@ -3596,7 +3595,6 @@
BCC5715A115ADAEF001CCAF9 /* WebSystemInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSystemInterface.mm; sourceTree = "<group>"; };
BCC8B373125FB69000DE46A4 /* WKGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKGeometry.h; sourceTree = "<group>"; };
BCC938E01180DE440085E5FE /* WKContextPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContextPrivate.h; sourceTree = "<group>"; };
- BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextMessageKinds.h; sourceTree = "<group>"; };
BCCF672C12C7EDF7008F9C35 /* OriginAndDatabases.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OriginAndDatabases.h; sourceTree = "<group>"; };
BCCF673212C7F15C008F9C35 /* OriginAndDatabases.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OriginAndDatabases.cpp; sourceTree = "<group>"; };
BCCF6ABA12C91EF9008F9C35 /* WebImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebImage.cpp; sourceTree = "<group>"; };
@@ -6255,7 +6253,6 @@
BC111B5F112F635E00337BAB /* CoreIPCSupport */ = {
isa = PBXGroup;
children = (
- BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */,
);
path = CoreIPCSupport;
sourceTree = "<group>";
@@ -7586,7 +7583,6 @@
510FBB9B1288C95E00AFFDF4 /* WebContextMenuItemData.h in Headers */,
51ACBB82127A8BAD00D203B9 /* WebContextMenuProxy.h in Headers */,
51ACBBA0127A8F2C00D203B9 /* WebContextMenuProxyMac.h in Headers */,
- BCCB75C61203A1CE00222D1B /* WebContextMessageKinds.h in Headers */,
BCF4DE25168FA44800C94AFC /* WebContextSupplement.h in Headers */,
BCB0B0DC12305A2500B1341E /* WebContextUserMessageCoders.h in Headers */,
330934501315B94D0097A7BC /* WebCookieManager.h in Headers */,
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (177791 => 177792)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp 2014-12-29 15:31:16 UTC (rev 177791)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp 2014-12-29 17:46:02 UTC (rev 177792)
@@ -32,11 +32,11 @@
#include "InjectedBundleUserMessageCoders.h"
#include "NotificationPermissionRequestManager.h"
#include "SessionTracker.h"
+#include "UserData.h"
#include "WKAPICast.h"
#include "WKBundleAPICast.h"
#include "WebApplicationCacheManager.h"
#include "WebConnectionToUIProcess.h"
-#include "WebContextMessageKinds.h"
#include "WebCookieManager.h"
#include "WebCoreArgumentCoders.h"
#include "WebDatabaseManager.h"
@@ -47,6 +47,7 @@
#include "WebPreferencesStore.h"
#include "WebProcess.h"
#include "WebProcessCreationParameters.h"
+#include "WebProcessPoolMessages.h"
#include <_javascript_Core/APICast.h>
#include <_javascript_Core/JSLock.h>
#include <WebCore/ApplicationCache.h>
@@ -114,27 +115,17 @@
void InjectedBundle::postMessage(const String& messageName, API::Object* messageBody)
{
- auto encoder = std::make_unique<IPC::MessageEncoder>(WebContextLegacyMessages::messageReceiverName(), WebContextLegacyMessages::postMessageMessageName(), 0);
- encoder->encode(messageName);
- encoder->encode(InjectedBundleUserMessageEncoder(messageBody));
-
- WebProcess::shared().parentProcessConnection()->sendMessage(WTF::move(encoder));
+ WebProcess::shared().parentProcessConnection()->send(Messages::WebProcessPool::HandleMessage(messageName, UserData(WebProcess::shared().transformObjectsToHandles(messageBody))), 0);
}
void InjectedBundle::postSynchronousMessage(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData)
{
- InjectedBundleUserMessageDecoder messageDecoder(returnData);
+ UserData returnUserData;
- uint64_t syncRequestID;
- std::unique_ptr<IPC::MessageEncoder> encoder = WebProcess::shared().parentProcessConnection()->createSyncMessageEncoder(WebContextLegacyMessages::messageReceiverName(), WebContextLegacyMessages::postSynchronousMessageMessageName(), 0, syncRequestID);
- encoder->encode(messageName);
- encoder->encode(InjectedBundleUserMessageEncoder(messageBody));
-
- std::unique_ptr<IPC::MessageDecoder> replyDecoder = WebProcess::shared().parentProcessConnection()->sendSyncMessage(syncRequestID, WTF::move(encoder), std::chrono::milliseconds::max());
- if (!replyDecoder || !replyDecoder->decode(messageDecoder)) {
+ if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebProcessPool::HandleSynchronousMessage(messageName, UserData(WebProcess::shared().transformObjectsToHandles(messageBody))), Messages::WebProcessPool::HandleSynchronousMessage::Reply(returnUserData), 0))
returnData = nullptr;
- return;
- }
+ else
+ returnData = WebProcess::shared().transformHandlesToObjects(returnUserData.object());
}
WebConnection* InjectedBundle::webConnectionToUIProcess() const