RE: Lazy Blob

Hi Glenn and all,

> From: Glenn Maynard [mailto:glenn@zewt.org] 
> Sent: Thursday, August 02, 2012 12:45 AM
> To: Robin Berjon
> Cc: WebApps WG; Jungkee Song
> Subject: Re: Lazy Blob
>
>>  On Wed, Aug 1, 2012 at 9:59 AM, Robin Berjon <robin@berjon.com> wrote:
>>  var bb = new BlobBuilder()
>>,   blob = bb.getBlobFromURL("http://specifiction.com/kitten.png", "GET", { Authorization: "Basic DEADBEEF" });
>>
>>  Everything is the same as the previous version but the method and some headers can be set by enumerating the Object. I *think* that those are all that would ever be needed.
>
> We already have an API to allow scripts to make network requests: XHR.  Please don't create a new API that will > end up duplicating all of that.  However this might be done, it should hang off of XHR.

* Let me use the word *Lazy* until we get a consensus upon the term.

As stated at the proposal, we came up with certain use cases in Web Intents postResult() callback. In this use case, there is no certain moment at which the client can explicitly trigger XHR request. Rather, it has to wait  huge Blobs of data (e.g., an array of Media objects in the Pick Media Intent [1]) on its intents callback.

Here is an example:

[Client]
navigator.startActivity(intent, mediaOK, mediaFail);

function mediaOK (mediaObjectArray) {
    // iterate over the array of media objects to do something useful with them
    console.log(mediaObjectArray.length + "media objects") // In console, "> 250 media objects"
    for (var i = 0; i < mediaObjectArray.length; i++) {
        // read mediaObjectArray[i].content.blob triggers actual resource transfer
    }
}

At the point the mediaOK() callback is called, 250 *Lazy* Blobs from an image gallery is ready.

[Service]
var mediaObjectArray = [];
// e.g., the service builds *mediaObjectArray* containing hundreds of png files from an image gallery
{ // loop
    var bb = new BlobBuilder()
    ,   blob = bb.getBlobFromURL("http://specification.com/kitten00.png", "GET", { Authorization: "Basic DEADBEEF" });

    var content = {};
    content.blob = blob;

    mediaObject.content = content;
    mediaObjectArray.push(mediaObject);
}

window.intent.postResult(mediaObjectArray);


Personally, I prefer option B (used in this email) as it is fairly simple to developers while providing useful options.

[1] http://w3c-test.org/dap/gallery/


Regards,
Jungkee

Jungkee Song
Samsung Electronics

Received on Thursday, 2 August 2012 12:35:12 UTC