Make WKObjectRegistry objects be per page
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Dec 2013 20:20:55 +0000 (20:20 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Dec 2013 20:20:55 +0000 (20:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125937

Reviewed by Andreas Kling.

Remove WKObjectRegistry from WKConnection. Also, add a C++ object that is in charge
of actually sending and receiving messages.

* DerivedSources.make:
* Shared/API/Cocoa/RemoteObjectRegistry.h: Added.
* Shared/API/Cocoa/RemoteObjectRegistry.messages.in: Added.
* Shared/API/Cocoa/RemoteObjectRegistry.mm: Added.
(WebKit::RemoteObjectRegistry::RemoteObjectRegistry):
(WebKit::RemoteObjectRegistry::~RemoteObjectRegistry):
(WebKit::RemoteObjectRegistry::sendInvocation):
(WebKit::RemoteObjectRegistry::invokeMethod):
* Shared/API/Cocoa/WKRemoteObjectRegistry.mm:
(-[WKRemoteObjectRegistry _initWithMessageSender:IPC::]):
(-[WKRemoteObjectRegistry _invalidate]):
(-[WKRemoteObjectRegistry _sendInvocation:interface:]):
(-[WKRemoteObjectRegistry WebKit::]):
(-[WKRemoteObjectRegistry _invokeMethod:]):
* Shared/API/Cocoa/WKRemoteObjectRegistryInternal.h:
* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController dealloc]):
(-[WKBrowsingContextController remoteObjectRegistry]):
* UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h:
* UIProcess/API/Cocoa/WKConnection.h:
* UIProcess/API/Cocoa/WKConnection.mm:
(didReceiveMessage):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(-[WKWebProcessPlugInBrowserContextController remoteObjectRegistry]):
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160787 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/DerivedSources.make
Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.h [new file with mode: 0644]
Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.messages.in [new file with mode: 0644]
Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.mm [moved from Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistryPrivate.h with 63% similarity]
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.mm
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistryInternal.h
Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm
Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKConnection.h
Source/WebKit2/UIProcess/API/Cocoa/WKConnection.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h

index fdfe822..7ad9233 100644 (file)
@@ -1,3 +1,40 @@
+2013-12-18  Anders Carlsson  <andersca@apple.com>
+
+        Make WKObjectRegistry objects be per page
+        https://bugs.webkit.org/show_bug.cgi?id=125937
+
+        Reviewed by Andreas Kling.
+
+        Remove WKObjectRegistry from WKConnection. Also, add a C++ object that is in charge 
+        of actually sending and receiving messages.
+
+        * DerivedSources.make:
+        * Shared/API/Cocoa/RemoteObjectRegistry.h: Added.
+        * Shared/API/Cocoa/RemoteObjectRegistry.messages.in: Added.
+        * Shared/API/Cocoa/RemoteObjectRegistry.mm: Added.
+        (WebKit::RemoteObjectRegistry::RemoteObjectRegistry):
+        (WebKit::RemoteObjectRegistry::~RemoteObjectRegistry):
+        (WebKit::RemoteObjectRegistry::sendInvocation):
+        (WebKit::RemoteObjectRegistry::invokeMethod):
+        * Shared/API/Cocoa/WKRemoteObjectRegistry.mm:
+        (-[WKRemoteObjectRegistry _initWithMessageSender:IPC::]):
+        (-[WKRemoteObjectRegistry _invalidate]):
+        (-[WKRemoteObjectRegistry _sendInvocation:interface:]):
+        (-[WKRemoteObjectRegistry WebKit::]):
+        (-[WKRemoteObjectRegistry _invokeMethod:]):
+        * Shared/API/Cocoa/WKRemoteObjectRegistryInternal.h:
+        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+        (-[WKBrowsingContextController dealloc]):
+        (-[WKBrowsingContextController remoteObjectRegistry]):
+        * UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h:
+        * UIProcess/API/Cocoa/WKConnection.h:
+        * UIProcess/API/Cocoa/WKConnection.mm:
+        (didReceiveMessage):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
+        (-[WKWebProcessPlugInBrowserContextController remoteObjectRegistry]):
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:
+
 2013-12-18  Conrad Shultz  <conrad_shultz@apple.com>
 
         API to set a favicon
index a65ad71..40f61b0 100644 (file)
@@ -30,9 +30,10 @@ VPATH = \
     $(WebKit2)/PluginProcess/mac \
     $(WebKit2)/Shared/Plugins \
     $(WebKit2)/Shared \
-    $(WebKit2)/Shared/mac \
+    $(WebKit2)/Shared/API/Cocoa \
     $(WebKit2)/Shared/Authentication \
     $(WebKit2)/Shared/Network/CustomProtocols \
+    $(WebKit2)/Shared/mac \
     $(WebKit2)/WebProcess/ApplicationCache \
     $(WebKit2)/WebProcess/Cookies \
     $(WebKit2)/WebProcess/Databases/IndexedDB \
@@ -85,6 +86,7 @@ MESSAGE_RECEIVERS = \
     PluginProcessProxy \
     PluginProxy \
     RemoteLayerTreeHost \
+    RemoteObjectRegistry \
     SecItemShim \
     SecItemShimProxy \
     StorageAreaMap \
diff --git a/Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.h b/Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.h
new file mode 100644 (file)
index 0000000..10d8f6f
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RemoteObjectRegistry_h
+#define RemoteObjectRegistry_h
+
+#include "MessageReceiver.h"
+
+OBJC_CLASS WKRemoteObjectRegistry;
+
+namespace IPC {
+class MessageSender;
+}
+
+namespace WebKit {
+
+class UserData;
+
+class RemoteObjectRegistry FINAL : public CoreIPC::MessageReceiver {
+public:
+    RemoteObjectRegistry(WKRemoteObjectRegistry *, IPC::MessageSender&);
+    ~RemoteObjectRegistry();
+
+    void sendInvocation(const UserData&);
+
+private:
+    // CoreIPC::MessageReceiver
+    virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
+
+    // Message handlers
+    void invokeMethod(const UserData&);
+
+    WKRemoteObjectRegistry *m_remoteObjectRegistry;
+    IPC::MessageSender& m_messageSender;
+};
+
+} // namespace WebKit
+
+#endif // RemoteObjectRegistry_h
diff --git a/Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.messages.in b/Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.messages.in
new file mode 100644 (file)
index 0000000..c352024
--- /dev/null
@@ -0,0 +1,25 @@
+# Copyright (C) 2013 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+messages -> RemoteObjectRegistry {
+    InvokeMethod(WebKit::UserData invocation)
+}
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import <WebKit2/WKFoundation.h>
+#import "config.h"
+#import "RemoteObjectRegistry.h"
 
-#if WK_API_ENABLED
+#import "MessageSender.h"
+#import "RemoteObjectRegistryMessages.h"
+#import "UserData.h"
+#import "WKRemoteObjectRegistryInternal.h"
 
-#import <WebKit2/WKBase.h>
-#import <WebKit2/WKRemoteObjectRegistry.h>
+namespace WebKit {
 
-@interface WKRemoteObjectRegistry (WKPrivate)
+RemoteObjectRegistry::RemoteObjectRegistry(WKRemoteObjectRegistry *remoteObjectRegistry, IPC::MessageSender& messageSender)
+    : m_remoteObjectRegistry(remoteObjectRegistry)
+    , m_messageSender(messageSender)
+{
+}
 
-- (id)_initWithConnectionRef:(WKConnectionRef)connectionRef;
-- (BOOL)_handleMessageWithName:(WKStringRef)name body:(WKTypeRef)body;
+RemoteObjectRegistry::~RemoteObjectRegistry()
+{
+}
 
-@end
+void RemoteObjectRegistry::sendInvocation(const UserData& userData)
+{
+    m_messageSender.send(Messages::RemoteObjectRegistry::InvokeMethod(userData));
+}
 
-#endif // WK_API_ENABLED
+void RemoteObjectRegistry::invokeMethod(const UserData& invocation)
+{
+    [m_remoteObjectRegistry _invokeMethod:invocation];
+}
+
+} // namespace WebKit
index 44ab5f0..7cb0911 100644 (file)
@@ -31,6 +31,8 @@
 #import "Connection.h"
 #import "ImmutableDictionary.h"
 #import "MutableDictionary.h"
+#import "RemoteObjectRegistry.h"
+#import "UserData.h"
 #import "WKConnectionRef.h"
 #import "WKRemoteObject.h"
 #import "WKRemoteObjectCoder.h"
@@ -38,8 +40,6 @@
 #import "WKSharedAPICast.h"
 #import "WebConnection.h"
 
-const char* const messageName = "WKRemoteObjectRegistryMessage";
-
 const char* const encodedInvocationKey = "encodedInvocation";
 const char* const interfaceIdentifierKey = "interfaceIdentifier";
 
@@ -48,7 +48,8 @@ NSString * const invocationKey = @"invocation";
 using namespace WebKit;
 
 @implementation WKRemoteObjectRegistry {
-    RefPtr<WebConnection> _connection;
+    std::unique_ptr<RemoteObjectRegistry> _remoteObjectRegistry;
+
     RetainPtr<NSMapTable> _remoteObjectProxies;
     HashMap<String, std::pair<RetainPtr<id>, RetainPtr<WKRemoteObjectInterface>>> _exportedObjects;
 }
@@ -82,6 +83,21 @@ using namespace WebKit;
     return [remoteObject.leakRef() autorelease];
 }
 
+- (id)_initWithMessageSender:(IPC::MessageSender&)messageSender
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _remoteObjectRegistry = std::make_unique<RemoteObjectRegistry>(self, messageSender);
+
+    return self;
+}
+
+- (void)_invalidate
+{
+    _remoteObjectRegistry = nullptr;
+}
+
 - (void)_sendInvocation:(NSInvocation *)invocation interface:(WKRemoteObjectInterface *)interface
 {
     RetainPtr<WKRemoteObjectEncoder> encoder = adoptNS([[WKRemoteObjectEncoder alloc] init]);
@@ -91,47 +107,34 @@ using namespace WebKit;
     body->set(interfaceIdentifierKey, API::String::create(interface.identifier));
     body->set(encodedInvocationKey, [encoder rootObjectDictionary]);
 
-    [self _sendMessageWithBody:body.release()];
-}
+    if (!_remoteObjectRegistry)
+        return;
 
-- (void)_sendMessageWithBody:(PassRefPtr<ImmutableDictionary>)body
-{
-    _connection->postMessage(messageName, body.get());
+    _remoteObjectRegistry->sendInvocation(UserData(body.get()));
 }
 
-@end
-
-@implementation WKRemoteObjectRegistry (WKPrivate)
-
-- (id)_initWithConnectionRef:(WKConnectionRef)connectionRef
+- (WebKit::RemoteObjectRegistry&)remoteObjectRegistry
 {
-    if (!(self = [super init]))
-        return nil;
-
-    _connection = toImpl(connectionRef);
-
-    return self;
+    return *_remoteObjectRegistry;
 }
 
-- (BOOL)_handleMessageWithName:(WKStringRef)name body:(WKTypeRef)body
+- (BOOL)_invokeMethod:(const UserData&)invocation
 {
-    if (toImpl(name)->string() != messageName)
+    if (!invocation.object() || invocation.object()->type() != API::Object::Type::Dictionary)
         return NO;
+    
+    const ImmutableDictionary& dictionary = static_cast<const ImmutableDictionary&>(*invocation.object());
 
-    if (!toImpl(body) || toImpl(body)->type() != API::Object::Type::Dictionary)
-        return NO;
-
-    const ImmutableDictionary* dictionary = toImpl(static_cast<WKDictionaryRef>(body));
-
-    API::String* interfaceIdentifier = dictionary->get<API::String>(interfaceIdentifierKey);
+    API::String* interfaceIdentifier = dictionary.get<API::String>(interfaceIdentifierKey);
     if (!interfaceIdentifier)
         return NO;
 
-    const ImmutableDictionary* encodedInvocation = dictionary->get<ImmutableDictionary>(encodedInvocationKey);
+    const ImmutableDictionary* encodedInvocation = dictionary.get<ImmutableDictionary>(encodedInvocationKey);
     if (!encodedInvocationKey)
         return NO;
 
     [self _invokeMessageWithInterfaceIdentifier:interfaceIdentifier->string() encodedInvocation:encodedInvocation];
+
     return YES;
 }
 
index 327062f..cad2ef2 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "WKRemoteObjectRegistryPrivate.h"
+#import "WKRemoteObjectRegistry.h"
 
 #if WK_API_ENABLED
 
+namespace IPC {
+class MessageSender;
+}
+
+namespace WebKit {
+class RemoteObjectRegistry;
+class UserData;
+}
+
 @interface WKRemoteObjectRegistry ()
 
+@property (nonatomic, readonly) WebKit::RemoteObjectRegistry& remoteObjectRegistry;
+
+- (id)_initWithMessageSender:(IPC::MessageSender&)messageSender;
+- (void)_invalidate;
+
 - (void)_sendInvocation:(NSInvocation *)invocation interface:(WKRemoteObjectInterface *)interface;
+- (BOOL)_invokeMethod:(const WebKit::UserData&)invocation;
 
 @end
 
index a1205fb..5c24aff 100644 (file)
@@ -30,6 +30,8 @@
 
 #import "APIData.h"
 #import "ObjCObjectGraph.h"
+#import "RemoteObjectRegistry.h"
+#import "RemoteObjectRegistryMessages.h"
 #import "WKBackForwardListInternal.h"
 #import "WKBackForwardListItemInternal.h"
 #import "WKBrowsingContextGroupInternal.h"
@@ -45,6 +47,7 @@
 #import "WKNSURLExtras.h"
 #import "WKNSURLProtectionSpace.h"
 #import "WKProcessGroupInternal.h"
+#import "WKRemoteObjectRegistryInternal.h"
 #import "WKRetainPtr.h"
 #import "WKURLRequestNS.h"
 #import "WKURLResponseNS.h"
@@ -139,6 +142,8 @@ static NSString * const frameErrorKey = @"WKBrowsingContextFrameErrorKey";
 
     WeakObjCPtr<id <WKBrowsingContextLoadDelegate>> _loadDelegate;
     WeakObjCPtr<id <WKBrowsingContextPolicyDelegate>> _policyDelegate;
+    
+    RetainPtr<WKRemoteObjectRegistry> _remoteObjectRegistry;
 }
 
 - (void)dealloc
@@ -146,6 +151,8 @@ static NSString * const frameErrorKey = @"WKBrowsingContextFrameErrorKey";
     _page->pageLoadState().removeObserver(*_pageLoadStateObserver);
     _page->~WebPageProxy();
 
+    [_remoteObjectRegistry _invalidate];
+
     [super dealloc];
 }
 
@@ -904,6 +911,16 @@ static void setUpPagePolicyClient(WKBrowsingContextController *browsingContext,
     return [[[WKBrowsingContextHandle alloc] _initWithPageID:_page->pageID()] autorelease];
 }
 
+- (WKRemoteObjectRegistry *)remoteObjectRegistry
+{
+    if (!_remoteObjectRegistry) {
+        _remoteObjectRegistry = [[WKRemoteObjectRegistry alloc] _initWithMessageSender:*_page];
+        _page->process().context().addMessageReceiver(Messages::RemoteObjectRegistry::messageReceiverName(), _page->pageID(), [_remoteObjectRegistry remoteObjectRegistry]);
+    }
+
+    return _remoteObjectRegistry.get();
+}
+
 @end
 
 #endif // WK_API_ENABLED
index 14512e4..0647be7 100644 (file)
@@ -38,6 +38,7 @@ typedef NS_ENUM(NSUInteger, WKBrowsingContextPaginationMode) {
 };
 
 @class WKBrowsingContextHandle;
+@class WKRemoteObjectRegistry;
 
 @interface WKBrowsingContextController (Private)
 
@@ -59,6 +60,7 @@ typedef NS_ENUM(NSUInteger, WKBrowsingContextPaginationMode) {
 
 @property (nonatomic, readonly) WKBrowsingContextHandle *handle;
 
+@property (nonatomic, readonly) WKRemoteObjectRegistry *remoteObjectRegistry;
 @end
 
 #endif // WK_API_ENABLED
index 7c7012c..6e983da 100644 (file)
@@ -30,7 +30,6 @@
 #import <Foundation/Foundation.h>
 
 @class WKConnection;
-@class WKRemoteObjectRegistry;
 
 @protocol WKConnectionDelegate <NSObject>
 
@@ -46,8 +45,6 @@ WK_API_CLASS
 
 @property (assign) id <WKConnectionDelegate> delegate;
 
-@property (nonatomic, readonly) WKRemoteObjectRegistry *remoteObjectRegistry;
-
 @end
 
 #endif // WK_API_ENABLED
index 6ad0e48..e57d2e1 100644 (file)
@@ -29,7 +29,6 @@
 #if WK_API_ENABLED
 
 #import "ObjCObjectGraph.h"
-#import "WKRemoteObjectRegistryInternal.h"
 #import "WKRetainPtr.h"
 #import "WKSharedAPICast.h"
 #import "WKStringCF.h"
@@ -40,7 +39,6 @@
 using namespace WebKit;
 
 @implementation WKConnection {
-    RetainPtr<WKRemoteObjectRegistry> _remoteObjectRegistry;
     WeakObjCPtr<id <WKConnectionDelegate>> _delegate;
 }
 
@@ -54,10 +52,8 @@ using namespace WebKit;
 static void didReceiveMessage(WKConnectionRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo)
 {
     WKConnection *connection = (WKConnection *)clientInfo;
-    if ([connection->_remoteObjectRegistry _handleMessageWithName:messageName body:messageBody])
-        return;
-
     auto delegate = connection->_delegate.get();
+
     if ([delegate respondsToSelector:@selector(connection:didReceiveMessageWithName:body:)]) {
         RetainPtr<CFStringRef> nsMessageName = adoptCF(WKStringCopyCFString(kCFAllocatorDefault, messageName));
         RetainPtr<id> nsMessageBody = ((ObjCObjectGraph*)messageBody)->rootObject();
@@ -107,14 +103,6 @@ static void setUpClient(WKConnection *wrapper, WebConnection& connection)
     self._connection.postMessage(messageName, wkMessageBody.get());
 }
 
-- (WKRemoteObjectRegistry *)remoteObjectRegistry
-{
-    if (!_remoteObjectRegistry)
-        _remoteObjectRegistry = adoptNS([[WKRemoteObjectRegistry alloc] _initWithConnectionRef:toAPI(&self._connection)]);
-
-    return _remoteObjectRegistry.get();
-}
-
 - (WebConnection&)_connection
 {
     return *static_cast<WebConnection*>(object_getIndexedIvars(self));
index b497aec..7471c04 100644 (file)
                1A9E328A1821636900F5D04C /* WKRemoteObjectRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E32881821636900F5D04C /* WKRemoteObjectRegistry.mm */; };
                1A9E328D182165A900F5D04C /* WKRemoteObjectInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E328B182165A900F5D04C /* WKRemoteObjectInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A9E328E182165A900F5D04C /* WKRemoteObjectInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E328C182165A900F5D04C /* WKRemoteObjectInterface.mm */; };
-               1A9E329718219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A9E329A1822E1CC00F5D04C /* WKRemoteObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E32981822E1CC00F5D04C /* WKRemoteObject.mm */; };
                1A9E329B1822E1CC00F5D04C /* WKRemoteObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E32991822E1CC00F5D04C /* WKRemoteObject.h */; };
                1A9E329E1822FEDD00F5D04C /* WKRemoteObjectCoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E329C1822FEDD00F5D04C /* WKRemoteObjectCoder.mm */; };
                1AC1337118566C7C00F3EC05 /* APIFrameHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC1336F18566C7C00F3EC05 /* APIFrameHandle.cpp */; };
                1AC1337218566C7C00F3EC05 /* APIFrameHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC1337018566C7C00F3EC05 /* APIFrameHandle.h */; };
                1AC133741857C21E00F3EC05 /* APIGeometry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC133731857C21E00F3EC05 /* APIGeometry.cpp */; };
+               1AC1337F18590AE400F3EC05 /* RemoteObjectRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AC1337D18590AE400F3EC05 /* RemoteObjectRegistry.mm */; };
+               1AC1338018590AE400F3EC05 /* RemoteObjectRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC1337E18590AE400F3EC05 /* RemoteObjectRegistry.h */; };
+               1AC1338518590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC1338318590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp */; };
+               1AC1338618590C4600F3EC05 /* RemoteObjectRegistryMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC1338418590C4600F3EC05 /* RemoteObjectRegistryMessages.h */; };
                1AC25FC212A48F6000BD2671 /* PluginProcessShim.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AC25F8A12A48E0300BD2671 /* PluginProcessShim.mm */; };
                1AC4C82916B876A90069DCCD /* MessageFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC4C82816B876A90069DCCD /* MessageFlags.h */; };
                1AC5FFC2174BFD1B0001483D /* PluginProcessAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC5FFC1174BFD1B0001483D /* PluginProcessAttributes.h */; };
                1A9E32881821636900F5D04C /* WKRemoteObjectRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRemoteObjectRegistry.mm; sourceTree = "<group>"; };
                1A9E328B182165A900F5D04C /* WKRemoteObjectInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObjectInterface.h; sourceTree = "<group>"; };
                1A9E328C182165A900F5D04C /* WKRemoteObjectInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRemoteObjectInterface.mm; sourceTree = "<group>"; };
-               1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObjectRegistryPrivate.h; sourceTree = "<group>"; };
                1A9E32981822E1CC00F5D04C /* WKRemoteObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRemoteObject.mm; sourceTree = "<group>"; };
                1A9E32991822E1CC00F5D04C /* WKRemoteObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObject.h; sourceTree = "<group>"; };
                1A9E329C1822FEDD00F5D04C /* WKRemoteObjectCoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRemoteObjectCoder.mm; sourceTree = "<group>"; };
                1AC1336F18566C7C00F3EC05 /* APIFrameHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIFrameHandle.cpp; sourceTree = "<group>"; };
                1AC1337018566C7C00F3EC05 /* APIFrameHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIFrameHandle.h; sourceTree = "<group>"; };
                1AC133731857C21E00F3EC05 /* APIGeometry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIGeometry.cpp; sourceTree = "<group>"; };
+               1AC1337D18590AE400F3EC05 /* RemoteObjectRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteObjectRegistry.mm; sourceTree = "<group>"; };
+               1AC1337E18590AE400F3EC05 /* RemoteObjectRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteObjectRegistry.h; sourceTree = "<group>"; };
+               1AC1338118590B0500F3EC05 /* RemoteObjectRegistry.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RemoteObjectRegistry.messages.in; sourceTree = "<group>"; };
+               1AC1338318590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteObjectRegistryMessageReceiver.cpp; sourceTree = "<group>"; };
+               1AC1338418590C4600F3EC05 /* RemoteObjectRegistryMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteObjectRegistryMessages.h; sourceTree = "<group>"; };
                1AC25F8912A48E0300BD2671 /* PluginProcessShim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProcessShim.h; sourceTree = "<group>"; };
                1AC25F8A12A48E0300BD2671 /* PluginProcessShim.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProcessShim.mm; sourceTree = "<group>"; };
                1AC25FB012A48EA700BD2671 /* PluginProcessShim.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = PluginProcessShim.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
                37DFA6FE1810BB2D001F4A9F /* Cocoa */ = {
                        isa = PBXGroup;
                        children = (
+                               1AC1337E18590AE400F3EC05 /* RemoteObjectRegistry.h */,
+                               1AC1338118590B0500F3EC05 /* RemoteObjectRegistry.messages.in */,
+                               1AC1337D18590AE400F3EC05 /* RemoteObjectRegistry.mm */,
                                1AE00D4B182D6EB000087DD7 /* WKBrowsingContextHandle.h */,
                                1AE00D4A182D6EB000087DD7 /* WKBrowsingContextHandle.mm */,
                                1AE00D4E182D6F5000087DD7 /* WKBrowsingContextHandleInternal.h */,
                                1A9E32871821636900F5D04C /* WKRemoteObjectRegistry.h */,
                                1A9E32881821636900F5D04C /* WKRemoteObjectRegistry.mm */,
                                1A9E32A01823018900F5D04C /* WKRemoteObjectRegistryInternal.h */,
-                               1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */,
                        );
                        path = Cocoa;
                        sourceTree = "<group>";
                                1A8EFA6F1252B84100F7067F /* PluginProxyMessages.h */,
                                1AA3D75F1651B7D3008713D0 /* RemoteLayerTreeHostMessageReceiver.cpp */,
                                1AA3D7601651B7D3008713D0 /* RemoteLayerTreeHostMessages.h */,
+                               1AC1338318590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp */,
+                               1AC1338418590C4600F3EC05 /* RemoteObjectRegistryMessages.h */,
                                E18E6911169B667B009B6670 /* SecItemShimMessageReceiver.cpp */,
                                E18E6912169B667B009B6670 /* SecItemShimMessages.h */,
                                E18E6913169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp */,
                                33AA1067131F060000D4A575 /* WebCookieManagerProxyClient.h in Headers */,
                                3309344A1315B9220097A7BC /* WebCookieManagerProxyMessages.h in Headers */,
                                BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
-                               1A9E329718219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h in Headers */,
                                512F589B12A8838800629530 /* WebCredential.h in Headers */,
                                51578B831209ECEF00A37C4A /* APIData.h in Headers */,
                                F6A25FDD12ADC6CC00DC40CC /* WebDatabaseManager.h in Headers */,
                                F62A765D12B1ABC30005F1B6 /* WebDatabaseManagerProxy.h in Headers */,
                                1F7506B11859163700EC0FF7 /* WKWebProcessPlugInFrame.h in Headers */,
                                1A445BA3184D5FCF004B3414 /* WKContextDownloadClient.h in Headers */,
+                               1AC1338618590C4600F3EC05 /* RemoteObjectRegistryMessages.h in Headers */,
                                BCAC111F12C92C1F00B08EEE /* WebDatabaseManagerProxyClient.h in Headers */,
                                F62A76B912B1B25F0005F1B6 /* WebDatabaseManagerProxyMessages.h in Headers */,
                                1AB7D72C1288CAAD00CFD08C /* WebDownloadClient.h in Headers */,
                                1A043A09124D11A900FFBFB5 /* WebProcessConnection.h in Headers */,
                                1A043F6A12514D8B00FFBFB5 /* WebProcessConnectionMessages.h in Headers */,
                                BC306824125A6B9400E71278 /* WebProcessCreationParameters.h in Headers */,
+                               1AC1338018590AE400F3EC05 /* RemoteObjectRegistry.h in Headers */,
                                BC3066BF125A442100E71278 /* WebProcessMessages.h in Headers */,
                                BC032DD510F4389F0058C15A /* WebProcessProxy.h in Headers */,
                                51032F19180F73BB00961BB7 /* WebToDatabaseProcessConnection.h in Headers */,
                                374436881820E7240049579F /* WKObject.mm in Sources */,
                                1A0F29E3120B44420053D1B9 /* VisitedLinkProvider.cpp in Sources */,
                                1A0F29CB120B37160053D1B9 /* VisitedLinkTable.cpp in Sources */,
+                               1AC1337F18590AE400F3EC05 /* RemoteObjectRegistry.mm in Sources */,
                                CEDA12E2152CD1AE00D9E08D /* WebAlternativeTextClient.cpp in Sources */,
                                512E352E130B55AF00ABD19A /* WebApplicationCacheManager.cpp in Sources */,
                                51E35205180F5D4F00E53BE9 /* DatabaseProcessMain.mm in Sources */,
                                51BA24461858F55D00EA2811 /* WebCrossThreadCopier.cpp in Sources */,
                                BC407609124FF0270068F20A /* WKURL.cpp in Sources */,
                                BC40761B124FF0370068F20A /* WKURLCF.mm in Sources */,
+                               1AC1338518590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp in Sources */,
                                BC40760B124FF0270068F20A /* WKURLRequest.cpp in Sources */,
                                BC40762A124FF0400068F20A /* WKURLRequestNS.mm in Sources */,
                                512A9760180E031D0039A149 /* DatabaseProcessMessageReceiver.cpp in Sources */,
index 264a9ba..7b40e3f 100644 (file)
 
 #if WK_API_ENABLED
 
+#import "RemoteObjectRegistry.h"
+#import "RemoteObjectRegistryMessages.h"
 #import "WKBrowsingContextHandleInternal.h"
 #import "WKBundleAPICast.h"
 #import "WKBundlePage.h"
 #import "WKBundlePagePrivate.h"
 #import "WKDOMInternals.h"
+#import "WKRemoteObjectRegistryInternal.h"
 #import "WKRetainPtr.h"
 #import "WKWebProcessPluginFrameInternal.h"
 #import "WKWebProcessPlugInInternal.h"
@@ -50,6 +53,8 @@ using namespace WebKit;
 @implementation WKWebProcessPlugInBrowserContextController {
     API::ObjectStorage<WebPage> _page;
     WeakObjCPtr<id <WKWebProcessPlugInLoadDelegate>> _loadDelegate;
+    
+    RetainPtr<WKRemoteObjectRegistry> _remoteObjectRegistry;
 }
 
 static void didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userDataRef, const void *clientInfo)
@@ -163,6 +168,16 @@ static void setUpPageLoaderClient(WKWebProcessPlugInBrowserContextController *co
     return wrapper(*webPage);
 }
 
+- (WKRemoteObjectRegistry *)remoteObjectRegistry
+{
+    if (!_remoteObjectRegistry) {
+        _remoteObjectRegistry = [[WKRemoteObjectRegistry alloc] _initWithMessageSender:*_page];
+        WebProcess::shared().addMessageReceiver(Messages::RemoteObjectRegistry::messageReceiverName(), _page->pageID(), [_remoteObjectRegistry remoteObjectRegistry]);
+    }
+
+    return _remoteObjectRegistry.get();
+}
+
 @end
 
 #endif // WK_API_ENABLED
index cff9807..1f1f28e 100644 (file)
@@ -30,6 +30,7 @@
 #import <WebKit2/WKBase.h>
 
 @class WKBrowsingContextHandle;
+@class WKRemoteObjectRegistry;
 
 @interface WKWebProcessPlugInBrowserContextController (Private)
 
@@ -37,6 +38,8 @@
 
 @property (nonatomic, readonly) WKBrowsingContextHandle *handle;
 
+@property (nonatomic, readonly) WKRemoteObjectRegistry *remoteObjectRegistry;
+
 + (instancetype)lookUpBrowsingContextFromHandle:(WKBrowsingContextHandle *)handle;
 
 @end