Bug 127304 - Add a convenience method to unregister remote object.
Summary: Add a convenience method to unregister remote object.
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-20 13:36 PST by Yongjun Zhang
Modified: 2014-01-20 17:38 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yongjun Zhang 2014-01-20 13:36:43 PST
Currently the API to unregister an remote object in WKRemoteObjectRegistry is:

- (void)unregisterExportedObject:(id)object interface:(WKRemoteObjectInterface *)interface

which means the caller has to prepare the WKRemoteObjectInterface object when unregistering object.  It would be nice to have a convenience method only take object as argument.
Comment 1 mitz 2014-01-20 13:40:31 PST
What if the same object is registered for multiple interfaces?
Comment 2 mitz 2014-01-20 13:43:09 PST
FWIW, I do think this API is cumbersome because it requires the caller to pass a WKRemoteObjectInterface, which it typically gets from +remoteObjectInterfaceWithProtocol:. I wonder if there can be methods that take a Protocol instead of a WKRemoteObjectInterface.
Comment 3 Anders Carlsson 2014-01-20 13:47:42 PST
(In reply to comment #2)
> FWIW, I do think this API is cumbersome because it requires the caller to pass a WKRemoteObjectInterface, which it typically gets from +remoteObjectInterfaceWithProtocol:. I wonder if there can be methods that take a Protocol instead of a WKRemoteObjectInterface.

What if the same protocol is registered for multiple interfaces?
Comment 4 Yongjun Zhang 2014-01-20 13:50:59 PST
(In reply to comment #2)
> FWIW, I do think this API is cumbersome because it requires the caller to pass a WKRemoteObjectInterface, which it typically gets from +remoteObjectInterfaceWithProtocol:. I wonder if there can be methods that take a Protocol instead of a WKRemoteObjectInterface.

+remoteObjectInterfaceWithProtocol:. I wonder if there can be methods that take a Protocol instead of a WKRemoteObjectInterface.

The problem with +remoteObjectInterfaceWithProtocol: is that it creates a new WKRemoteObjectInterface* object every time for the same Protocol.  That means we will hit assertion in

 - (void)unregisterExportedObject:(id)object interface:(WKRemoteObjectInterface *)interface

since it is different than the interface argument used on registering.   For now, the only way to get around this is to save interface on the caller and use that exact object on both registering and unregistering.
Comment 5 Yongjun Zhang 2014-01-20 17:38:37 PST
It is hard to predict the usage pattern now, but I think sometimes we probably just want to unregister the object before destroying the object, in that case, it would be helpful if we provide a method to remove an object (for all interfaces) from the registry.  Some thing like:

- (void)unregisterObjectForAllInterfaces:(id)object;

what do you think?