W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

Re: [FileAPI] Deterministic release of Blob proposal

From: Glenn Maynard <glenn@zewt.org>
Date: Mon, 5 Mar 2012 19:56:09 -0600
Message-ID: <CABirCh9F9QPOvLRMDgYL76F46PMM1LKPNeUreTPiLpCWcV-Udg@mail.gmail.com>
To: Charles Pritchard <chuck@jumis.com>
Cc: Feras Moussa <ferasm@microsoft.com>, "public-webapps@w3.org" <public-webapps@w3.org>, Adrian Bateman <adrianba@microsoft.com>
On Mon, Mar 5, 2012 at 7:04 PM, Charles Pritchard <chuck@jumis.com> wrote:

>  Do you see old behavior working something like the following?

> var blob = new Blob("my new big blob");
> var keepBlob = blob.slice();
> destination.postMessage(blob, '*', [blob]); // is try/catch needed here?
> blob = keepBlob; // keeping a copy of my blob still in thread.
Sorry to cover too many angles: if Blob is Transferable, then it'll neuter;
> so if we do want a local copy, we'd use slice ahead of time to keep it.

You don't need to do that.  If you don't want postMessage to transfer the
blob, then simply don't include it in the transfer parameter, and it'll
perform a normal structured clone.  postMessage behaves this way in part
for backwards-compatibility: so exactly in cases like this, we can make
Blob implement Transferable without breaking existing code.

See http://dev.w3.org/html5/postmsg/#posting-messages and similar
postMessage APIs.

> And we might have an error on postMessage stashing it in the transfer
> array if it's not a Transferable on an older browser.

It'll throw TypeError, which you'll need to handle if you need to support
older browsers.

The new behavior is pretty easy.
> var blob = new Blob("my big blob");
> blob.close(); // My blob has been neutered before it could procreate.

Sorry, I'm not really sure what you're trying to say.  This still works
when using the "neutered" concept; it just uses an existing mechanism, and
allows transfers.

Glenn Maynard
Received on Tuesday, 6 March 2012 01:56:37 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 13:55:48 UTC