JSONFile.jsm, a new module to help with serializing JSON to disk
Matthew N.
MattN at mozilla.com
Wed Oct 12 03:03:05 UTC 2016
Hi David,
Can you file Toolkit::General bugs blocking 1304322 for the first two
issues please? Note that this module is just a refactoring of
LoginStore.jsm from a few years ago to make it more generic so these issues
already existed before.
Regarding ensureDataReady, code review and developer judgement can be used
to judge whether that method should be used by an individual consumer.
Perhaps we could have warnings in the JSDoc comment to make it more clear
that it should be avoided but in the original code (LoginStore.jsm) it was
needed.
Thanks,
Matthew
On Tue, Oct 11, 2016 at 1:39 PM, David Teller <dteller at mozilla.com> wrote:
> Thanks for writing this, I believe that it can be useful.
>
> A few remarks:
>
> - you should never mix nsIFile/FileUtils and OS.File, as they operate on
> different threads, so you could end up with data loss;
>
> - to improve durability in case of I/O error, you should consider using
> backups in addition to `tmpPath`;
>
> - by definition, `ensureDataReady` blocks the main thread, I don't think
> it is such a good idea – maybe for some very specific use cases, but
> probably not in a library meant to be reused.
>
> Cheers,
> David
>
>
> On 11/10/16 16:53, Luke Chang wrote:
> > Hey folks,
> >
> > This is a notice about a module, JSONFile.jsm, just landed in
> > "toolkit/modules".
> >
> > Matt, Steve and I have been working on Form Autofill [1]. While
> > implementing, we intend to leverage modules of Password Manager because
> > of their similar behaviors. LoginStore.jsm [2] is one of those modules.
> >
> > The above-mentioned JSONFile.jsm is basically separated from
> > LoginStore.jsm, which is in charge of storing login-related data in a
> > ".json" file. In order to increase the reusability of such
> > JSON-formatted storage that we're going to use in Form Autofill as well,
> > we refactored LoginStore.jsm. More specifically, those IO-specific APIs
> > were generalized and moved to JSONFile.jsm. Therefore, LoginStore.jsm
> > will focus on schema-related operations such as data migrations.
> >
> > To sum up, you can now utilize JSONFile.jsm to store simple data in a
> > single file as long as the data can be serialized to JSON format. More
> > details can be found in bug 1304322 [3].
> >
> > Thanks,
> > Luke
> >
> > [1] https://wiki.mozilla.org/Firefox/Features/Form_Autofill
> > [2]
> > https://dxr.mozilla.org/mozilla-central/source/toolkit/components/
> passwordmgr/LoginStore.jsm
> > [3] https://bugzilla.mozilla.org/show_bug.cgi?id=1304322
> >
> >
> >
> > _______________________________________________
> > firefox-dev mailing list
> > firefox-dev at mozilla.org
> > https://mail.mozilla.org/listinfo/firefox-dev
> >
> _______________________________________________
> firefox-dev mailing list
> firefox-dev at mozilla.org
> https://mail.mozilla.org/listinfo/firefox-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/firefox-dev/attachments/20161011/aa1ef569/attachment.html>
More information about the firefox-dev
mailing list