Title: [158595] trunk
Revision
158595
Author
[email protected]
Date
2013-11-04 14:30:34 -0800 (Mon, 04 Nov 2013)

Log Message

More WKRemoteObjectRegistry work
https://bugs.webkit.org/show_bug.cgi?id=123754

Reviewed by Dan Bernstein.

Source/WebKit2:

* Shared/API/Cocoa/WKRemoteObjectCoder.h:
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(-[WKRemoteObjectEncoder rootObjectDictionary]):
Add a getter for the root object dictionary.

* Shared/API/Cocoa/WKRemoteObjectRegistry.mm:
(-[WKRemoteObjectRegistry _sendInvocation:interface:]):
Call _sendMessageWithBody:.
(-[WKRemoteObjectRegistry _sendMessageWithBody:]):
Call WebConnection::postMessage.

Tools:

* TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm:
(TestWebKitAPI::TEST):
Use the correct bundle test name. Call Util::run.

* TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm:
(-[BundleObject sayHello]):
(-[BundleObject testMethodWithString:double:integer:]):
Add BundleObject implementation. Register the bundle object with
the remote object registry. Call _handleMessageWithName:body: on the incoming message.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (158594 => 158595)


--- trunk/Source/WebKit2/ChangeLog	2013-11-04 21:56:58 UTC (rev 158594)
+++ trunk/Source/WebKit2/ChangeLog	2013-11-04 22:30:34 UTC (rev 158595)
@@ -1,3 +1,21 @@
+2013-11-04  Anders Carlsson  <[email protected]>
+
+        More WKRemoteObjectRegistry work
+        https://bugs.webkit.org/show_bug.cgi?id=123754
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/API/Cocoa/WKRemoteObjectCoder.h:
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+        (-[WKRemoteObjectEncoder rootObjectDictionary]):
+        Add a getter for the root object dictionary.
+
+        * Shared/API/Cocoa/WKRemoteObjectRegistry.mm:
+        (-[WKRemoteObjectRegistry _sendInvocation:interface:]):
+        Call _sendMessageWithBody:.
+        (-[WKRemoteObjectRegistry _sendMessageWithBody:]):
+        Call WebConnection::postMessage.
+
 2013-11-03  Dan Bernstein  <[email protected]>
 
         [Cocoa] Wrappers' -copyWithZone: should copy if the collection is mutable

Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.h (158594 => 158595)


--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.h	2013-11-04 21:56:58 UTC (rev 158594)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.h	2013-11-04 22:30:34 UTC (rev 158595)
@@ -27,7 +27,14 @@
 
 #if WK_API_ENABLED
 
+namespace WebKit {
+class ImmutableDictionary;
+}
+
 @interface WKRemoteObjectEncoder : NSCoder
+
+- (WebKit::ImmutableDictionary*)rootObjectDictionary;
+
 @end
 
 #endif // WK_API_ENABLED

Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm (158594 => 158595)


--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm	2013-11-04 21:56:58 UTC (rev 158594)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm	2013-11-04 22:30:34 UTC (rev 158595)
@@ -65,6 +65,11 @@
 }
 #endif
 
+- (ImmutableDictionary*)rootObjectDictionary
+{
+    return _rootDictionary.get();
+}
+
 - (BOOL)allowsKeyedCoding
 {
     return YES;

Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.mm (158594 => 158595)


--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.mm	2013-11-04 21:56:58 UTC (rev 158594)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.mm	2013-11-04 22:30:34 UTC (rev 158595)
@@ -27,6 +27,7 @@
 #import "WKRemoteObjectRegistryInternal.h"
 
 #import "Connection.h"
+#import "ImmutableDictionary.h"
 #import "WKConnectionRef.h"
 #import "WKRemoteObject.h"
 #import "WKRemoteObjectCoder.h"
@@ -36,6 +37,8 @@
 
 #if WK_API_ENABLED
 
+const char* const messageName = "WKRemoteObjectRegistryMessage";
+
 using namespace WebKit;
 
 @implementation WKRemoteObjectRegistry {
@@ -74,8 +77,15 @@
 
     [encoder encodeObject:interface.identifier forKey:@"interfaceIdentifier"];
     [encoder encodeObject:invocation forKey:@"invocation"];
+
+    [self _sendMessageWithBody:[encoder rootObjectDictionary]];
 }
 
+- (void)_sendMessageWithBody:(PassRefPtr<ImmutableDictionary>)body
+{
+    _connection->postMessage(messageName, body.get());
+}
+
 @end
 
 @implementation WKRemoteObjectRegistry (WKPrivate)

Modified: trunk/Tools/ChangeLog (158594 => 158595)


--- trunk/Tools/ChangeLog	2013-11-04 21:56:58 UTC (rev 158594)
+++ trunk/Tools/ChangeLog	2013-11-04 22:30:34 UTC (rev 158595)
@@ -1,3 +1,20 @@
+2013-11-04  Anders Carlsson  <[email protected]>
+
+        More WKRemoteObjectRegistry work
+        https://bugs.webkit.org/show_bug.cgi?id=123754
+
+        Reviewed by Dan Bernstein.
+
+        * TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm:
+        (TestWebKitAPI::TEST):
+        Use the correct bundle test name. Call Util::run.
+
+        * TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm:
+        (-[BundleObject sayHello]):
+        (-[BundleObject testMethodWithString:double:integer:]):
+        Add BundleObject implementation. Register the bundle object with
+        the remote object registry. Call _handleMessageWithName:body: on the incoming message.
+
 2013-11-04  Krzysztof Czech  <[email protected]>
 
         [EFL] Change ATK version to 2.10.0

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm (158594 => 158595)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm	2013-11-04 21:56:58 UTC (rev 158594)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm	2013-11-04 22:30:34 UTC (rev 158595)
@@ -39,8 +39,8 @@
 
 static bool connectionEstablished;
 static WKRemoteObjectRegistry *remoteObjectRegistry;
+static bool testFinished;
 
-
 /* WKConnectionClient */
 static void connectionDidReceiveMessage(WKConnectionRef connection, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
 {
@@ -73,7 +73,7 @@
 
 TEST(WebKit2, WKRemoteObjectRegistryTest)
 {
-    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("WKConnectionTest"));
+    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("WKRemoteObjectRegistry"));
 
     // Set up the context's connection client so that we can access the connection when
     // it is created.
@@ -100,6 +100,11 @@
 
     [remoteObjectProxy sayHello];
     [remoteObjectProxy testMethodWithString:@"Hello" double:123.456 integer:789];
+
+    // FIXME: Set this once the test actually is finished.
+    testFinished = true;
+
+    Util::run(&testFinished);
 }
 
 } // namespace TestWebKitAPI

Modified: trunk/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm (158594 => 158595)


--- trunk/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm	2013-11-04 21:56:58 UTC (rev 158594)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm	2013-11-04 22:30:34 UTC (rev 158595)
@@ -23,21 +23,37 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "InjectedBundleTest.h"
-#include "PlatformUtilities.h"
-#include <WebKit2/WKRetainPtr.h>
+#import "config.h"
+#import "InjectedBundleTest.h"
 
+#import "PlatformUtilities.h"
+#import "WKRemoteObjectRegistry_Shared.h"
+#import <WebKit2/WKRemoteObjectRegistryPrivate.h>
+#import <WebKit2/WKRemoteObjectInterface.h>
+#import <WebKit2/WKRetainPtr.h>
+#import <wtf/RetainPtr.h>
+
 #if WK_API_ENABLED
 
-namespace TestWebKitAPI {
+@interface BundleObject : NSObject <BundleInterface>
+@end
 
-/* WKConnectionClient */
-static void connectionDidReceiveMessage(WKConnectionRef connection, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
+@implementation BundleObject
+
+- (void)sayHello
 {
-    // FIXME: Implement this.
+    // FIXME: Implement.
 }
 
+- (void)testMethodWithString:(NSString *)string double:(double)d integer:(int)i
+{
+    // FIXME: Implement.
+}
+
+@end
+
+namespace TestWebKitAPI {
+
 class WKRemoteObjectRegistryTest : public InjectedBundleTest {
 public:
     WKRemoteObjectRegistryTest(const std::string& identifier)
@@ -45,15 +61,30 @@
     {
     }
 
-    virtual void initialize(WKBundleRef bundle, WKTypeRef)
+    virtual void initialize(WKBundleRef bundle, WKTypeRef) override
     {
+        m_objectRegistry = adoptNS([[WKRemoteObjectRegistry alloc] _initWithConnectionRef:WKBundleGetApplicationConnection(bundle)]);
+
+        WKRemoteObjectInterface *bundleInterface = [WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(BundleInterface)];
+
+        BundleObject *bundleObject = [[BundleObject alloc] init];
+        [m_objectRegistry registerExportedObject:bundleObject interface:bundleInterface];
+
         WKConnectionClient connectionClient;
         memset(&connectionClient, 0, sizeof(connectionClient));
         connectionClient.version = WKConnectionClientCurrentVersion;
-        connectionClient.clientInfo = 0;
-        connectionClient.didReceiveMessage = connectionDidReceiveMessage;
+        connectionClient.clientInfo = this;
+        connectionClient.didReceiveMessage = [](WKConnectionRef connection, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo) {
+            const WKRemoteObjectRegistryTest* test = static_cast<const WKRemoteObjectRegistryTest*>(clientInfo);
+
+            [test->m_objectRegistry.get() _handleMessageWithName:messageName body:messageBody];
+        };
+
         WKConnectionSetConnectionClient(WKBundleGetApplicationConnection(bundle), &connectionClient);
     }
+
+private:
+    RetainPtr<WKRemoteObjectRegistry> m_objectRegistry;
 };
 
 static InjectedBundleTest::Register<WKRemoteObjectRegistryTest> registrar("WKRemoteObjectRegistry");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to