[whatwg] RFC: Alternatives to storage mutex for cookies and localStorage

On Fri, Sep 4, 2009 at 12:02 AM, Chris Jones<cjones at mozilla.com> wrote:
> I propose adding the functions
>
> ?window.localStorage.beginTransaction()
> ?window.localStorage.commitTransaction()
> or
> ?window.beginTransaction()
> ?window.commitTransaction()

I think this is a good idea! I would modify it to follow the pattern
set by the current SQLDatabase proposal, to have a callback, like
this:

window.localStorage.transaction(function() {
  // use local storage here
});

I'm against having explicit begin/commit methods for the same reason
as I am for the SQLDatabase feature:

- It is easy to forget to commit
- The most likely paths in an application to be wrong are ones that
are rarely run
- Therefore many applications will contain uncommon paths that end up
hung (responsive, but still unable to make forward progress) and with
uncommitted data

But those issues are easily fixable with the callback model above.

On Fri, Sep 4, 2009 at 12:32 AM, Jeremy Orlow<jorlow at chromium.org> wrote:
> I actually think the idea of
> throwing an exception whenever there's a serialization problem could be very
> compelling, and could keep the door wide open for future performance
> enhancements.

What problem would this solve? It seems like it would require
cross-app coordination to avoid exceptions.

On Fri, Sep 4, 2009 at 12:32 AM, Jeremy Orlow<jorlow at chromium.org> wrote:
> Note that if we do decide to break backwards compatibility, there are some
> other things we should consider...but I won't bring those up unless we do
> decide to move in this direction.
> Btw, I want to make it clear that I take the idea of
> breaking compatibility VERY seriously.  I know LocalStorage is fairly well
> adopted and that changing this would be pretty major.  But having a
> cross-event-loop, synchronous API is really a terrible idea.  And changing
> it now will be easier than changing it later.

I think it is possible to make this change with a very small breaking
change. Just add window.localStorage.transaction() and keep the rest
of the API as-is. Existing implementations can add the method, but
supporting using window.localStorage without transaction(), too.

- a

Received on Tuesday, 8 September 2009 00:00:55 UTC