Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Issue 7477027: Support Transferable objects (Closed)

Created:
9 years, 5 months ago by zarko
Modified:
5 years, 1 month ago
Reviewers:
jam
CC:
chromium-reviews, joi+watch-content_chromium.org, pam+watch_chromium.org, jam, darin-cc_chromium.org
Visibility:
Public.

Description

This is the pure-Chromium side for the WebKit patch detailed at https://bugs.webkit.org/show_bug.cgi?id=65209 . This patch can compile independently of that WebKit patch; it contains some temporary preprocessor blocks to accomplish this. The Structured Clone algorithm describes an interface for Transferable objects (http://www.whatwg.org/specs/web-apps/current-work/complete/common-dom-interfaces.html#transferable-objects). Currently the only official Transferable object is the MessagePort, but ArrayBuffers are expected to be sanctioned as such soon. This is particularly important for Chrome because it will allow for cheap (copy-free) passing of ArrayBuffer data to and from in-process dedicated workers (once these land). ArrayBuffers are used heavily with WebGL; clients of that API have noted that they have found the existing implementation of message passing to be a little slow. Imagine that we're trying to transfer an ArrayBuffer to a dedicated worker. - JS calls postMessage(msg, [buffer]), where buffer is mentioned somewhere in msg. - The ArrayBuffer backing the JS buffer is a Transferable; we transfer it out, getting back a TransferableReceipt that we can later exchange for an equivalent ArrayBuffer. The original Transferable is marked as closed. - msg is serialized (with buffer being maintained as an external reference). The serialized msg and the TransferableReceipt for buffer are passed around together. - Since we never touch IPC, we never need to copy the underlying array data; under the covers, it belongs to the TransferableReceipt. - When it comes time to deserialize msg in the context of the destination dedicated worker, we exchange buffer's TransferableReceipt back for its promised Transferable-- an ArrayBuffer that takes control of the original array's memory. If it turns out that the message needs to cross an IPC boundary, some TransferableReceipts will need to be flattened-- that is, the IPC system will redeem them and paste the data they contain to the beginning of the serialized message. Note that certain Transferables have special semantics (like MessagePorts) under which it either doesn't make sense or isn't useful to clone the objects in this way. This flattening happens just before the message gets sent out (because at the time the message is generated there isn't a clear way to determine that it will eventually need to travel across an IPC boundary).

Patch Set 1 #

Patch Set 2 : Compile independently of WebKit changes. #

Patch Set 3 : Rebase. #

Total comments: 2

Patch Set 4 : Fix a style issue. #

Patch Set 5 : Rebase; some fixes. #

Patch Set 6 : Rebase. #

Patch Set 7 : Flatten everywhere necessary. #

Patch Set 8 : Update for interface changes. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+224 lines, -53 lines) Patch
M content/common/webmessageportchannel_impl.h View 1 2 3 4 5 6 7 2 chunks +18 lines, -2 lines 0 comments Download
M content/common/webmessageportchannel_impl.cc View 1 2 3 4 5 6 7 3 chunks +58 lines, -16 lines 0 comments Download
M content/renderer/webworker_base.cc View 1 chunk +1 line, -1 line 0 comments Download
M content/renderer/webworker_proxy.h View 1 2 3 4 2 chunks +11 lines, -1 line 0 comments Download
M content/renderer/webworker_proxy.cc View 1 2 3 4 5 6 7 3 chunks +56 lines, -15 lines 0 comments Download
M content/worker/webworker_stub.cc View 1 2 3 4 5 6 7 2 chunks +16 lines, -3 lines 0 comments Download
M content/worker/webworkerclient_proxy.h View 1 2 3 4 2 chunks +11 lines, -1 line 0 comments Download
M content/worker/webworkerclient_proxy.cc View 1 2 3 4 5 6 7 3 chunks +41 lines, -12 lines 0 comments Download
M webkit/tools/test_shell/test_web_worker.h View 1 2 3 4 3 chunks +12 lines, -2 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
zarko
This change is part of an effort in making ArrayBuffer passing to and from dedicated ...
9 years, 4 months ago (2011-07-29 23:10:36 UTC) #1
jam
Can you add some background in the description of the change (since that's what goes ...
9 years, 4 months ago (2011-08-01 06:24:56 UTC) #2
zarko
On 2011/08/01 06:24:56, John Abd-El-Malek wrote: > Can you add some background in the description ...
9 years, 4 months ago (2011-08-01 23:04:50 UTC) #3
jam
I see, thanks for the explanation, much clearer now. Can I wait till WebKit folks ...
9 years, 4 months ago (2011-08-02 05:43:43 UTC) #4
zarko
9 years, 4 months ago (2011-08-02 16:25:59 UTC) #5
On 2011/08/02 05:43:43, John Abd-El-Malek wrote:
> I see, thanks for the explanation, much clearer now.
> 
> Can I wait till WebKit folks are ok with it to review it?

Sure-- the WebKit reviews might change some interfaces after all. This patch
will need to land before the WebKit side does, though (because of the
aforementioned interface changes).

Powered by Google App Engine
This is Rietveld 408576698