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

Jeremy Orlow jorlow at chromium.org
Tue Sep 8 01:08:55 PDT 2009

On Tue, Sep 8, 2009 at 4:54 PM, Jonas Sicking <jonas at sicking.cc> wrote:

> On Tue, Sep 8, 2009 at 12:00 AM, Aaron Boodman<aa at google.com> wrote:
> > 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
> > });
> We have discussed similar APIs in the past. Something like a:
> window.getLocalStorage(function (storage) {
>  ...use storage...
> });
> This is nice because it can be expanded to something like:
> window.getSharedItems(window.SHARED_ITEM_LOCALSTORAGE |
> window.SHARED_ITEM_COOKIES, function (...) { ... });
> to let you access both cookies and localStorage safely at the same time.
> However, this requires breaking compatibility with existing syntax,
> something that seems impossible at this point given that Microsoft has
> shipped localStorage. I know Hixie has asked them in the past about
> how they plan to deal with the mutex problem, but I'm not sure if an
> answer has been received as of yet.

First of all, I'm not sure I agree that we're at the point where
breaking compatibility is impossible.  It really doesn't seem like it's
terribly widely used, and what's implemented is based on an early draft of
the spec.  Yes, I agree that it's really unfortunate we didn't iron these
problems out better before everyone implemented it, but if LocalStorage
changed today, it definitely wouldn't break the web.  (Of course, it's
possible that we would be breaking the web by the time the next gen of the
major browsers ship.....it's hard to know for sure.)

But, if we're going to say that the way things are now is sacred, then how
do we reconcile the fact that an app that works fine on Safari (and others)
may break in IE due to races?  If we're so worried about compatibility,
maybe we need to cater to the lowest common denominator (IE8....so no run to
completion guarantees for LocalStorage) and add in a mechanism that does
give you guarantees (like a callback).

As a side note, I'd be very interested to hear what Microsoft's response

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090908/91ecb197/attachment-0002.htm>

More information about the whatwg mailing list