Closed Bug 752724 Opened 13 years ago Closed 7 years ago

Implement Device Storage editable features

Categories

(Core :: DOM: Device Interfaces, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE
mozilla16

People

(Reporter: dougt, Unassigned)

References

()

Details

Attachments

(1 file)

Follow up from bug 717103 - this implements the file handle methods.
Attached patch patch v.1 (deleted) β€” β€” Splinter Review
Attachment #621769 - Flags: review?(Jan.Varga)
If I understood it correctly, .get() and .getEditable() return two different objects (File and FileHandle) backed by the same OS file. The whole point of FileHandle is to provide automatic locking. Now, when you have a (big sized) File object returned by .get(), you pass it to FileReader, then you immediatelly call .getEditable() and do some writing (FileReader is still reading) ...

Jonas, should DeviceStorage.get() delegate to FileHandle.getFile() ?
So File objects would not be created directly.
>  The whole point of FileHandle is to provide automatic locking.

I thought it was so that you'd be able to write to the file.
oh, i like what you're saying Jan.  Just expose .get() on device storage -- which is the common case.  If you want to write, you use the FileReader and getEditable?
FileHandle != FileWriter
FileHandle.getFile() creates only a read lock
The point of FileHandle is to provide the ability to write, as well the locking mechanisms needed to allow writing safely.

And yes, DeviceStorage.get should simply return the same Blob as you'd get from DeviceStorage.getEditable().getFile() (modulo the asynchronous syntax needed).

The main advantages with DeviceStorage.get is that it provides a simpler syntax for the common case of simply wanting to read a file, and it also allows for safer security models since it allows read-only access.
Sorry, I wanted to say "The main point" instead of "whole point"
And it provides the ability to write indeed.
Doug, I still think that you should pass an object that implements nsIFileStorage to DOMFileHandle::Create()
For now, only StorageId() has to be implemented.

Anyway, we might want to add additional methods to nsIFileStorage to lock the file at
OS level to interact with other processes.

SQLite has a cross platform implementation of shared and exclusive locks. That might
serve as a good example once we need it.
jan, as on IRC, I still do not understand why you need StorageID.  I do not think you need nsIFileStorage to provide OS locking -- you can do that based on the nsIFile used to create the FileHandle.
Some things need to be (or might be needed) done only for DeviceStorage some only for IndexedDB and some for both, so I created the abstract nsIFileStorage interface.
Feel free to ignore it if you are convinced it's completely useless for DeviceStorage.

We don't need the OS file locking in IndexedDB, but FileHandle has to work with both "file storages". If you want to put OS file locking insided DOMFileHandle ok, up to you.
Attachment #621769 - Flags: review?(Jan.Varga) → review-
Lucas - What specifically do you want reviewed here, the implementation or the whole concept?
This API permits writing to a file, so it seems like it should get a secreview and possibly an implementation review as well.  A flaw here would be pretty bad.
Assignee: doug.turner → Jan.Varga
Target Milestone: --- → mozilla16
Version: unspecified → Trunk
Flags: sec-review? → sec-review?(ptheriault)
Assignee: Jan.Varga → nobody
Any news?
Flags: needinfo?(doug.turner)
We're going to implement FileHandle in child processes first.
Flags: needinfo?(doug.turner)
Depends on: 771288
No longer blocks: 891030
Removing secreview tag here for now. Please re-flag if/when this progresses.
Flags: sec-review?(ptheriault)
FxOS/Gonk has been removed from the codebase. Mass-invalidating FxOS related Device Interface bugs to clean up the component. 

If I incorrectly invalidated something, please let me know.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INVALID
Bulk correction of resolution of B2G bugs to INCOMPLETE.
Resolution: INVALID → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: