Closed Bug 855952 Opened 7 years ago Closed 6 years ago

[DeviceStorage] support append file operation on b2g device

Categories

(Core :: DOM: Device Interfaces, defect)

ARM
Gonk (Firefox OS)
defect
Not set

Tracking

()

RESOLVED FIXED
2.0 S4 (20june)
tracking-b2g backlog

People

(Reporter: rlin, Assigned: alchen)

References

Details

(Keywords: dev-doc-needed, Whiteboard: [priority][p=5])

Attachments

(3 files, 9 obsolete files)

3.20 KB, patch
Details | Diff | Splinter Review
17.58 KB, patch
Details | Diff | Splinter Review
5.25 KB, patch
Details | Diff | Splinter Review
The MediaRecorder would get encoder data in js context during recording.
We need an API which allows application can save fragmental data during recording.
Otherwise, application only can save the whole blob when user stop it. (Or use a timer try to save the whole data...)
oh, API has implemented this by
getEditable and add function. close it.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INVALID
Status: RESOLVED → UNCONFIRMED
Ever confirmed: false
Resolution: INVALID → ---
Assignee: nobody → ahuang
Hardware: x86_64 → ARM
Attached patch WIP, v1 (obsolete) — Splinter Review
I think this bug needs something like this, an Append API.

Hello Doug,
Can you help to take a look and give some advise? Many thanks.
Attachment #743412 - Flags: feedback?(doug.turner)
Comment on attachment 743412 [details] [diff] [review]
WIP, v1

Hello Dave,

I know DeviceStorage has lots of changes after this proposal. Can you help to take a look at this, to see is this a right direction to do this? Thank you.
Attachment #743412 - Flags: feedback?(doug.turner) → feedback?(dhylands)
Comment on attachment 743412 [details] [diff] [review]
WIP, v1

Review of attachment 743412 [details] [diff] [review]:
-----------------------------------------------------------------

So overall, it looks reasonable. You'll need to add in the composite file support.

::: dom/devicestorage/nsDeviceStorage.cpp
@@ +673,5 @@
>  
>  nsresult
> +DeviceStorageFile::Append(nsIInputStream* aInputStream)
> +{
> +  if (!aInputStream) {

This will need to also check || !mFile (as per ::Write)

@@ +692,5 @@
> +
> +  if (!outputStream) {
> +    return NS_ERROR_FAILURE;
> +  }
> +

It would be good to factor the common code (from about here to the end of the function) and have Write and Append both call the common code. Perhaps call the new function WriteInternal (and make it private to DeviceStorageFile)

The only real difference is how the file is opened.

@@ +1545,5 @@
> +      NS_DispatchToMainThread(event);
> +      return NS_OK;
> +    }
> +
> +    nsresult rv = mFile->Write(stream);

Shouldn't this be calling Append?

@@ +1548,5 @@
> +
> +    nsresult rv = mFile->Write(stream);
> +
> +    if (NS_FAILED(rv)) {
> +      mFile->mFile->Remove(false);

And we probably don't want to remove the file if the append fails

@@ +2266,5 @@
> +  DeviceStorageTypeChecker* typeChecker = DeviceStorageTypeChecker::CreateOrGet();
> +  if (!typeChecker) {
> +    return NS_ERROR_FAILURE;
> +  }
> +

You'll need to add a similar IsComposite() check as you'll find in AddNamed.

::: dom/ipc/PContent.ipdl
@@ +88,5 @@
>  };
>  
> +struct DeviceStorageAppendParams
> +{
> +  nsString type;

It looks like you haven't picked up the composite file changes. You'll need to add a storageName field here as well.
Attachment #743412 - Flags: feedback?(dhylands) → feedback+
No longer blocks: 803414
Unrelated to media recording API directly, so I'm removing this from that tracker bug.
No longer blocks: MediaRecording
I'd like to shake a little this bug, as it's also needed for exporting contacts (bug 910182 comment 16).

Not sure if it's better to reuse this one or create one specifically for contacts, but the title is descriptive enough, so I'll go with former option.

Hey Alan, any chance that you have some free cycles to keep working on it? :)
Blocks: 910182
Status: UNCONFIRMED → NEW
blocking-b2g: --- → 1.5?
Ever confirmed: true
Flags: needinfo?(ahuang)
Yeah it has been in the backlog for a long time. Let's do this in 1.5 :)
Flags: needinfo?(ahuang)
We also have bug 859696 tracking this issue, shall we merge the two bugs and DUP one of them?
I don't think that bug 859656 is a dup. You could implement the append operation if you had the getEditable operation, but append certainly can't' be used to implement getEditable.
Attempting to move noms out of the general component into a component that will give them action. If I've guessed the wrong component, reassign as necessary.
Component: General → Hardware
Component: Hardware → DOM: Device Interfaces
Product: Firefox OS → Core
Moving it out of blocking, but adding priority flag so it gets some traction.
blocking-b2g: 2.0? → backlog
Whiteboard: [priority]
Assignee: ahuang → alchen
Whiteboard: [priority] → [priority][p=5]
Target Milestone: --- → 2.0 S3 (6june)
Hi Dave,
here is the update patch for append file operation.
Please have a review.
Thanks.
Attachment #743412 - Attachment is obsolete: true
Attachment #8430580 - Flags: review?(dhylands)
Mochitest for append file operation.
Attachment #8430581 - Flags: review?(dhylands)
Correct one typo.
Attachment #8430581 - Attachment is obsolete: true
Attachment #8430581 - Flags: review?(dhylands)
Attachment #8430634 - Flags: review?(dhylands)
Refactor the testcase.
And run it on try server first.
Attachment #8430634 - Attachment is obsolete: true
Attachment #8430634 - Flags: review?(dhylands)
Comment on attachment 8430580 [details] [diff] [review]
[DeviceStorage] support append file operation

Review of attachment 8430580 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good so far, but I'd like to see some refactoring (as mentioned) and you really need to add some tests, and I'd like to see a try run (devicestorage tests are currently running as M2)

Please put DeviceStorage.webidl as a separate patch and request review from :bzbarsky

::: dom/devicestorage/DeviceStorageRequestParent.cpp
@@ +59,5 @@
>      }
>  
> +    case DeviceStorageParams::TDeviceStorageAppendParams:
> +    {
> +      DeviceStorageAddParams p = mParams;

nit: Shouldn't this me AppendParams? (not AddParams)

@@ +267,5 @@
>      }
>  
> +    case DeviceStorageParams::TDeviceStorageAppendParams:
> +    {
> +      DeviceStorageAddParams p = mParams;

nit: Shouldn't this be DeviceStorageAppendParams?

::: dom/devicestorage/nsDeviceStorage.cpp
@@ +1155,5 @@
> +//  bool check = false;
> +//  mFile->Exists(&check);
> +//  if (!check) {
> +//    return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
> +//  }

Why is this code commented out?

I'm going to guess that it's because you're allowing the file to be created below. However, if you create the file, you should be generating a "created" IOCompleteEvent. If so, please remove the commented out code.

Since the tail end of this and the tail end of Write are identical, I'd like to see some refactoring.

Perhaps have Write create the file and then call an Append method which takes an input and output stream, and have Append(inputStream) create/open the output stream and then call the Append method which takes an input/output stream.

@@ +2481,4 @@
>    nsRefPtr<DOMRequest> mRequest;
>  };
>  
> +class AppendFileEvent : public nsRunnable

I think that this logic and the logic from WriteFileEvent can be combined into WriteFileEvent.

The only difference seems to be whether the file exists already or not, so you could just add an additional argument to the constructor to determine whether the file should exist already or not exist.

The same should be done with DeviceStorageRequestParent::AppendFileEvent (fold it into WriteFileEvent)

@@ +3684,5 @@
> +}
> +
> +already_AddRefed<DOMRequest>
> +nsDOMDeviceStorage::AppendNamed(nsIDOMBlob* aBlob, const nsAString& aPath,
> +                                ErrorResult& aRv)

I think that AppendNamed and AddNamed are virtually identical, so you should create one common function (perhaps called AddOrAppendNamed) which takes DEVICE_STORAGE_REQUEST_APPEND or DEVICE_STORAGE_REQUEST_CREATE as an argument.
Attachment #8430580 - Flags: review?(dhylands) → review-
(In reply to Dave Hylands [:dhylands] from comment #16)
> Comment on attachment 8430580 [details] [diff] [review]
> [DeviceStorage] support append file operation
> 
> Review of attachment 8430580 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> This looks good so far, but I'd like to see some refactoring (as mentioned)
> and you really need to add some tests, and I'd like to see a try run
> (devicestorage tests are currently running as M2)
> 
> Please put DeviceStorage.webidl as a separate patch and request review from
> :bzbarsky
> 
> ::: dom/devicestorage/DeviceStorageRequestParent.cpp
> @@ +59,5 @@
> >      }
> >  
> > +    case DeviceStorageParams::TDeviceStorageAppendParams:
> > +    {
> > +      DeviceStorageAddParams p = mParams;
> 
> nit: Shouldn't this me AppendParams? (not AddParams)
> 
> @@ +267,5 @@
> >      }
> >  
> > +    case DeviceStorageParams::TDeviceStorageAppendParams:
> > +    {
> > +      DeviceStorageAddParams p = mParams;
> 
> nit: Shouldn't this be DeviceStorageAppendParams?
> 
> ::: dom/devicestorage/nsDeviceStorage.cpp
> @@ +1155,5 @@
> > +//  bool check = false;
> > +//  mFile->Exists(&check);
> > +//  if (!check) {
> > +//    return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
> > +//  }
> 
> Why is this code commented out?

At first, I comment this out due to duplication.
There is same check in "DeviceStorageRequestParent::AppendFileEvent::CancelableRun()".

I will have new patch with "Append" and "Add" refactory.
(In reply to Alphan Chen[:Alphan] from comment #17)
> (In reply to Dave Hylands [:dhylands] from comment #16)
> > ::: dom/devicestorage/nsDeviceStorage.cpp
> > @@ +1155,5 @@
> > > +//  bool check = false;
> > > +//  mFile->Exists(&check);
> > > +//  if (!check) {
> > > +//    return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
> > > +//  }
> > 
> > Why is this code commented out?
> 
> At first, I comment this out due to duplication.
> There is same check in
> "DeviceStorageRequestParent::AppendFileEvent::CancelableRun()".
> 
> I will have new patch with "Append" and "Add" refactory.

So my point was, that you shouldn't check it a patch with code that's commented out. The commented-out code should either be removed entirely, or it should be uncommented.
Here is the patch with the suggestion above.
Please have a review.
Thanks.
Attachment #8430580 - Attachment is obsolete: true
Attachment #8436676 - Flags: review?(dhylands)
I add appendNamed for append file operation.
Please have a look.
Thanks.
Attachment #8436677 - Flags: review?(bzbarsky)
Comment on attachment 8436678 [details] [diff] [review]
(0609) [DeviceStorage] Test case for append file operation

Review of attachment 8436678 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with nits addressed

::: dom/devicestorage/test/test_fs_appendFile.html
@@ +17,5 @@
> +<body>
> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=855952">Mozilla Bug 855952</a>
> +<p id="display"></p>
> +<div id="content" style="display: none">
> +  

nit: trailing space

@@ +24,5 @@
> +<script class="testbody" type="text/javascript">
> +
> +var file   = new Blob(["This is a text file."], {type: "text/plain"});
> +var appendFile   = new Blob([" Another text file."], {type: "text/plain"});
> +var filename = "devicestorage/append.asc"

nit: call this gFilename, or just remove it entirely and just pass "devicestorage/append.asc" into the call to addNamed on line 79.

All of the follow on functions should be able to use e.target.result (or a sub-field) to get a full qualified filename.

@@ +40,5 @@
> +
> +function appendSuccess(e) {
> +  ok(true, "appendSuccess was called.");
> +  var storage = navigator.getDeviceStorage("sdcard");
> +  request = storage.delete(filename)

nit: use e.target.result rather than filename.

If you want to clarify, then add:

var filename = e.target.result

@@ +56,5 @@
> +
> +  var storage = navigator.getDeviceStorage("sdcard");
> +  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
> +
> +  request = storage.appendNamed(appendFile, filename);

nit: rather than reusing filename, use e.target.result

@@ +78,5 @@
> +  // Add a file first
> +  request = storage.addNamed(file, filename);
> +  ok(request, "Should have a non-null request");
> +  request.onsuccess = addSuccess;
> +  request.onerror = addError;  

nit: trailing space

@@ +82,5 @@
> +  request.onerror = addError;  
> +}
> +
> +function runtest() {
> +  var storage = navigator.getDeviceStorage("sdcard");

nit: If you were to store storage as a global (i.e. put these 2 lines just before the call to runtest) then you could just use it rather than re-fetching in all of the other functions (like appendSuccess, addSuccess, addError, addFile)

@@ +84,5 @@
> +
> +function runtest() {
> +  var storage = navigator.getDeviceStorage("sdcard");
> +  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
> +  

nit: trailing space
Attachment #8436678 - Flags: review?(dhylands) → review+
Comment on attachment 8436676 [details] [diff] [review]
(0609) [DeviceStorage] support append file operation

Review of attachment 8436676 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great.

r=me with nits addressed.

::: dom/devicestorage/nsDeviceStorage.cpp
@@ +2450,4 @@
>      if (NS_FAILED(rv)) {
> +      if (mRequestType == DEVICE_STORAGE_REQUEST_CREATE) {
> +        mFile->mFile->Remove(false);
> +      }

nit: I'd move the file removal into the if statement above (if the write fails, remove the file)

@@ +3617,5 @@
> +        (aRequestType == DEVICE_STORAGE_REQUEST_CREATE))
> +    {
> +      return ds->AddOrAppendNamed(aBlob, storagePath,
> +                                  aRequestType, aRv);
> +    } else {

nit: No need for else after a return. Remove the else and unindent the following 2 lines.

@@ +3621,5 @@
> +    } else {
> +      aRv.Throw(NS_ERROR_UNEXPECTED);
> +      return nullptr;
> +    }
> +

nit: I'd probably lose the extra checking here. You can replace the entire if statement above with:

return ds->AddOrAppendNamed(aBlob, storagePath, aRequestType, aRv);

The checking of aRequestType is being done below on line 3639.

@@ +3635,5 @@
>    } else if (!typeChecker->Check(mStorageType, dsf->mFile) ||
>        !typeChecker->Check(mStorageType, aBlob)) {
>      r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_TYPE);
>    } else {
> +    if (aRequestType == DEVICE_STORAGE_REQUEST_APPEND) {

nit: I'd probably just make this an else if () { rather than an else { if ()

It probably makes sense to make it look like:

} else if (aRequestType == DEVICE_STORAGE_REQUEST_APPEND || aRequestType == DEVICE_STORAGE_REQUEST_CREATE) {
  r = new DeviceStorageRequest(aRequestType,
		win, mPrincipal, dsf, request, aBlob);
} else {
  aRv.Throw(NS_ERROR_UNEXPECTED);
  return nullptr;
}
Attachment #8436676 - Flags: review?(dhylands) → review+
Comment on attachment 8436677 [details] [diff] [review]
(0609)  [DeviceStorage] add appendNamed into DeviceStorage webidl

How does appendNamed() differ from addNamed()?  Documentation is sorely needed.

Also, in general asking for review of just IDL with no context is not very useful.  It just means I have to go try to find the context myself...

In this case, why do we need to change nsIDOMDeviceStorage.idl?
Attachment #8436677 - Flags: review?(bzbarsky) → review-
(In reply to Boris Zbarsky [:bz] from comment #24)
> Comment on attachment 8436677 [details] [diff] [review]
> (0609)  [DeviceStorage] add appendNamed into DeviceStorage webidl
> 
> How does appendNamed() differ from addNamed()?  Documentation is sorely
> needed.

appendNamed() is used for append context into one existing file.
In some use cases, append operation is useful.

> 
> Also, in general asking for review of just IDL with no context is not very
> useful.  It just means I have to go try to find the context myself...
> 

Sorry about that, I will re-create new patches.

> In this case, why do we need to change nsIDOMDeviceStorage.idl?

In this implementation, I try to let AppendNamed much the same as AddNamed.
There are both idl and webidl for AddNamed case.
What is your opinion? 
Does "remove .idl part for AppendNamed case" make sense to you?
Flags: needinfo?(bzbarsky)
Upload a revised version with some fixes.
Attachment #8436678 - Attachment is obsolete: true
> appendNamed() is used for append context into one existing file.

Don't tell _me_ that.  Put in in comments in the IDL.  What does it do if there is no existing file?  How does it pick the file to append to?

Basically, document the interface.  That's something that every interface not already documented by a spec should have, and I'm a bit sad that DeviceStorage is totally undocumented right now... but at least document the new thing.

> Does "remove .idl part for AppendNamed case" make sense to you?

Yes, unless you expect people to use it from C++.
Flags: needinfo?(bzbarsky)
Upload a revised version.
Attachment #8436676 - Attachment is obsolete: true
Hi Boris,
The patch is based on comment 24 and comment 27.
Please have a review.
Thanks.
Attachment #8436677 - Attachment is obsolete: true
Attachment #8438185 - Flags: review?(bzbarsky)
Comment on attachment 8438185 [details] [diff] [review]
(0610) [DeviceStorage] add appendNamed into DeviceStorage webidl

>+   * Append a file inside a given file.

Maybe "append data to a given file"?

>+   * If the file doesn't exist, a POST_ERROR_EVENT_FILE_DOES_NOT_EXIST event will be dispatched.

That's an odd way to write "NotFoundError" in this case...

Also, what will be returned in this situation?

>+   * @parameter aBlob: A Blob object representing the file to append

s/file/data/?

>+   * @parameter aName: A string representing the full name (path + file name) of the file.

"of the file to append data to"?

r=me with that, assuming people have sane ways of getting the full names from somwhere.
Attachment #8438185 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky [:bz] from comment #30)
> Comment on attachment 8438185 [details] [diff] [review]
> (0610) [DeviceStorage] add appendNamed into DeviceStorage webidl
> r=me with that, assuming people have sane ways of getting the full names
> from somwhere.

I'll have to make a bug to get everything in the .idl/webidl stuff documented properly - I inherited that way :(

All of the device storage APIs that return paths always try to return fully-qualified paths. By fully qualified I mean /volume-name/path/file  These paths are only usable inside device storage, and you can't use an nsIFile with the same path (so device storage is hiding the physical location).
I filed bug 1024029 for getting the remainder of the devicestorage stuff documented.
> 
> Maybe "append data to a given file"?
> 
> >+   * If the file doesn't exist, a POST_ERROR_EVENT_FILE_DOES_NOT_EXIST event will be dispatched.
> 
> That's an odd way to write "NotFoundError" in this case...

Now "appending data to a non-existing file" is the same behavior as "reading data from a non-existing file".
Do you suggest creating the file if it doesn't exist?

> 
> Also, what will be returned in this situation?
> 
It is a request.onerror case.
Since we share the same base function with "Add" (nsDOMDeviceStorage::AddOrAppendNamed), it will return null when blob file is null and other unexpected situations.
Flags: needinfo?(bzbarsky)
> Do you suggest creating the file if it doesn't exist?

I'm not suggesting changing the behavior, just that it might be clearer to actually write out the "NotFoundError" string so it's clear what's being dispatched.

> It is a request.onerror case.

Don't tell _me_ that.  Tell the IDL documetation reader.  ;)
Flags: needinfo?(bzbarsky)
Update webidl patch based on comment 30.

Here is the try server result.
It looks fine.
https://tbpl.mozilla.org/?tree=Try&rev=ca2c65694653
Attachment #8438185 - Attachment is obsolete: true
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/705e176f1beb
https://hg.mozilla.org/mozilla-central/rev/bc5f910e98da
https://hg.mozilla.org/mozilla-central/rev/a485b8a93a3d
Status: NEW → RESOLVED
Closed: 7 years ago6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: 2.0 S3 (6june) → 2.0 S4 (20june)
>+   * If the file doesn't exist, a "NotFoundError" event will be dispatched.

On this DeviceStorage object, right?  Is it dispatched before the function returns, or asynchronously?

>+   * In the same time, it is a request.onerror case.

What does that mean, exactly?

>+   * The function will return null when blob file is null and other unexpected
> situations.

Return null instead of throwing?

When does this function throw, and what does it throw?
Flags: needinfo?(alchen)
(In reply to Boris Zbarsky [:bz] from comment #38)
> >+   * If the file doesn't exist, a "NotFoundError" event will be dispatched.
> 
> On this DeviceStorage object, right?  Is it dispatched before the function
> returns, or asynchronously?
> 
> >+   * In the same time, it is a request.onerror case.
> 
> What does that mean, exactly?

The method is asynchronous and return a DOMRequest object to handle the success or error of the operation.

> 
> >+   * The function will return null when blob file is null and other unexpected
> > situations.
> 
> Return null instead of throwing?
> 
> When does this function throw, and what does it throw?

Except for blob file is null case, they will throw error before return in other cases.
When blob file is null, it just return null without throwing.
In the beginning, the function is return NS_OK. (NS_IMETHODIMP nsDOMDeviceStorage::AddNamed)
Then in the patch of "move DeviceStorage to WebIDL", Ms2ger return null without throwing.
So do you think we need to throw error before return null in this case?





I will update the comment later.

Here is the revised version.
  /*
   * Append data to a given file.
   * The method is asynchronous and return a DOMRequest object to 
   *   handle the success or error of the operation.
   * If the file doesn't exist, the error name will be "NotFoundError".
   * If the file exists, it will be opened with the following permission:
   *                                         "PR_WRONLY|PR_CREATE_FILE|PR_APPEND".
   * @parameter aBlob: A Blob object representing the data to append
   * @parameter aName: A string representing the full name (path + file name) of the file
   *                   to append data to.
   */
Flags: needinfo?(alchen) → needinfo?(bzbarsky)
> The method is asynchronous and return a DOMRequest object to handle the success or error
> of the operation.

Yes, I know that.  But what does "it is a request.onerror case" mean?  Presumably it's trying to say something about the DOMRequest object that will be returned, but it's not clear what.

The new comment is much better in this regard, thank you.

> So do you think we need to throw error before return null in this case?

That's an API design decision.  How do you expect typical code that uses this API to look?

>   * If the file doesn't exist, the error name will be "NotFoundError".

Ah, so there are no DOM events involved at all, ok.

What is the result of the returned DOMRequest in success cases?
Flags: needinfo?(bzbarsky)
(In reply to Boris Zbarsky [:bz] from comment #40)

> >Except for blob file is null case, they will throw error before return in other cases.
> >When blob file is null, it just return null without throwing.
> >In the beginning, the function is return NS_OK. (NS_IMETHODIMP nsDOMDeviceStorage::AddNamed)
> >Then in the patch of "move DeviceStorage to WebIDL", Ms2ger return null without throwing.
> > So do you think we need to throw error before return null in this case?
> 
> That's an API design decision.  How do you expect typical code that uses
> this API to look?

Hi Dave, do you have any comment about blob file is null case?
In my opinion, when adding/appending null data, we can throw an error(maybe NS_ERROR_UNEXPECTED) before return.
However, I don't know if there is any concern or reason for today's code. (just return null without throwing)
Flags: needinfo?(dhylands)
(In reply to Boris Zbarsky [:bz] from comment #40)
> 
> >   * If the file doesn't exist, the error name will be "NotFoundError".
> 
> Ah, so there are no DOM events involved at all, ok.
> 
> What is the result of the returned DOMRequest in success cases?
I will add a description for it as below.

(Revise version)
  /*
   * Append data to a given file.
   * The method is asynchronous and return a DOMRequest object to 
   *   handle the success or error of the operation.
   * If the file doesn't exist, the error name will be "NotFoundError".
   * If the file exists, it will be opened with the following permission:
   *                                         "PR_WRONLY|PR_CREATE_FILE|PR_APPEND".
   * The result of the retruned DOMRequest in success cases will be fully-qualified paths.
   * @parameter aBlob: A Blob object representing the data to append
   * @parameter aName: A string representing the full name (path + file name) of the file
   *                   to append data to.
   */
(In reply to Alphan Chen[:Alphan] from comment #41)
> (In reply to Boris Zbarsky [:bz] from comment #40)
> 
> > >Except for blob file is null case, they will throw error before return in other cases.
> > >When blob file is null, it just return null without throwing.
> > >In the beginning, the function is return NS_OK. (NS_IMETHODIMP nsDOMDeviceStorage::AddNamed)
> > >Then in the patch of "move DeviceStorage to WebIDL", Ms2ger return null without throwing.
> > > So do you think we need to throw error before return null in this case?
> > 
> > That's an API design decision.  How do you expect typical code that uses
> > this API to look?
> 
> Hi Dave, do you have any comment about blob file is null case?
> In my opinion, when adding/appending null data, we can throw an error(maybe
> NS_ERROR_UNEXPECTED) before return.
> However, I don't know if there is any concern or reason for today's code.
> (just return null without throwing)

This seems unusual. Sending a null blob might be interpreted as write zero bytes, and that returns success immediately.

You could also interpret it as an error, but I think I would treat it like "write zero bytes".
Flags: needinfo?(dhylands)
Duplicate of this bug: 1066675
blocking-b2g: backlog → ---
You need to log in before you can comment on or make changes to this bug.