Bug 26902 - postMessage() spec now supports sending arrays of ports
Summary: postMessage() spec now supports sending arrays of ports
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Andrew Wilson
Depends on:
Blocks: 28460
  Show dependency treegraph
Reported: 2009-07-01 13:43 PDT by Andrew Wilson
Modified: 2009-08-31 17:13 PDT (History)
1 user (show)

See Also:

proposed patch (41.16 KB, patch)
2009-08-19 17:25 PDT, Andrew Wilson
levin: review+
levin: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Wilson 2009-07-01 13:43:59 PDT
Currently, the various flavors of postMessage (DOMWindow.postMessage, MessagePort.postMessage, Worker.postMessage, etc) take a single optional MessagePort argument which is passed to the destination via the MessageEvent.messagePort attribute.

The HTML5 spec has changed to allow passing an array of ports instead, and  renames MessageEvent.messagePort to MessageEvent.ports. This spec change didn't seem to generate much feedback one way or the other, so I'm not certain whether it's going to stick (we're the first platform to support MessagePorts) but there's no technical reason not to implement it.
Comment 1 Andrew Wilson 2009-08-18 18:01:58 PDT
Splitting this bug into two parts - part 1 will get the WebCore infrastructure working with passing multiple ports around, and part 2 will hookup the JS bindings.
Comment 2 Andrew Wilson 2009-08-19 17:25:33 PDT
Created attachment 35162 [details]
proposed patch
Comment 3 David Levin 2009-08-20 22:51:45 PDT
Comment on attachment 35162 [details]
proposed patch

A few things to consider but nothing that couldn't get checked in.

> diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
> +2009-08-19  Drew Wilson  <atwilson@google.com>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        postMessage() spec now supports sending arrays of ports
> +        https://bugs.webkit.org/show_bug.cgi?id=26902
> +
> +        Added OwnPtr to VectorTraits so we can store OwnPtrs in Vectors.


In WebCore/ChangeLog
 "No new tests, " needs an indentation fix.

> diff --git a/WebCore/dom/MessagePort.cpp b/WebCore/dom/MessagePort.cpp

> +    // Passed-in ports passed validity checks, so we can disentangle them.
> +    MessagePortChannelArray* result = new

"result" seems as generic as "i" to me.  portArray?

> +    for (unsigned int i = 0 ; i < ports->size() ; ++i) {
> +        OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle(ec);
> +        ASSERT(!ec);  // Can't generate exception here if passed above

One space before end of line comments.  Want to do a patch to cpp_style.py? :)

> +PassOwnPtr<MessagePortArray>
MessagePort::entanglePorts(ScriptExecutionContext& context,
PassOwnPtr<MessagePortChannelArray> channels)
> +    MessagePortArray* result = new MessagePortArray(channels->size());

Personal nit: "result"