W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2010

BlobWriter simplification/split

From: Eric Uhrhane <ericu@google.com>
Date: Tue, 29 Jun 2010 17:17:35 -0700
Message-ID: <AANLkTinf_5q9cyIS49HCKmcu8H0HOP3Z3Cs-Ggt4eALJ@mail.gmail.com>
To: Web Applications Working Group WG <public-webapps@w3.org>
Following up on discussions mainly at [1] and use cases at [2], I'd
like to propose splitting the BlobWriter [née FileWriter] class, with
an eye to solving some UI problems and simplifying implementation.

When saving a Blob to a location outside the FileSystem API sandbox,
we want to prompt the user exactly once, and want to be able to
indicate that a write is taking place, e.g. by throbbing the download
indicator.  We want the throbbing to go away as soon as the write is
done, and we don't want the app to have continued privileges to write
outside the sandbox.  [That's been debated, but I think it's beyond
the scope of what we're working on so far, so let's leave that case
for later expansion.]

When writing inside the sandbox, we probably don't need the throbber
at all, and we definitely don't want to prompt the user on each write.
 Leaving aside the question of how one obtains a BlobWriter without
using the sandbox and when exactly prompts happen [I'll open another
thread for that], I think that:

*  We don't want to have the same API call cause prompts to pop up on
some instances of BlobWriter and not others.
*  We don't want to have the same API call be reusable on some
instances of BlobWriter and not others.

I propose the following split:

Define a parent class, SimpleBlobWriter, that's used for one-shot Blob
export.  This is what you use when you don't have the FileSystem API,
when the user selects the save location.  It contains a writeFile()
method, which writes a Blob to a file in a single operation.  It is an
error to call writeFile if readyState is not INIT, so SimpleBlobWriter
is single-use.  Its other members are abort(), readyState, the ready
state constants, error, length, and the progress event handlers, as
defined in the current spec.

Derive from SimpleBlobWriter the class BlobWriter, which adds
position, truncate(), seek(), and write(), as defined in the current
spec.  This is what the FileSystem API's createWriter() call would
return.

This lets you have different APIs for different behaviors, and removes
fields from SimpleBlobWriter that aren't actually useful without the
FileSystem API.

How does that sound?  [Better names for SimpleBlobWriter and
BlobWriter would be quite welcome, BTW.]

     Eric

[1] http://lists.w3.org/Archives/Public/public-webapps/2010JanMar/0910.html
[buried rather deep in the thread]
[2] http://lists.w3.org/Archives/Public/public-webapps/2010AprJun/1206.html
Received on Wednesday, 30 June 2010 00:18:19 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:39 GMT