Closed Bug 1163388 Opened 9 years ago Closed 9 years ago

Get rid of nsIDOMFile

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox40 --- affected

People

(Reporter: baku, Assigned: baku)

References

Details

(Keywords: addon-compat)

Attachments

(3 files, 1 obsolete file)

      No description provided.
Attached patch patch 2 - get rid nsIDOMFile (obsolete) — Splinter Review
Attachment #8605824 - Flags: review?(ehsan)
Keywords: addon-compat
Attachment #8605785 - Flags: review?(ehsan) → review+
Comment on attachment 8605824 [details] [diff] [review]
patch 2 - get rid nsIDOMFile

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

Minusing because of the nsFilePickerProxy.cpp comment.

::: dom/base/nsIDOMFile.idl
@@ -58,5 @@
> -// nsIDOMBlob to Blob safely.  Our chain is:
> -//  - Blob -> nsIDOMBlob
> -//  - File -> nsIDOMFile and Blob
> -[scriptable, builtinclass, uuid(26e292a6-f5aa-4560-b523-ae22a4c7dfca)]
> -interface nsIDOMFile : nsISupports

It would be nice if you renamed this file as nsIDOMBlob.idl (perhaps in a follow-up.)

::: dom/interfaces/base/nsIDOMWindowUtils.idl
@@ +1448,2 @@
>     */
> +  nsISupports wrapDOMFile(in nsIFile aFile);

Please rev the uuid of this interface.

::: dom/interfaces/html/nsIDOMHTMLCanvasElement.idl
@@ +37,5 @@
>    // Valid calls are
>    // mozGetAsFile(name);              -- defaults to image/png
>    // mozGetAsFile(name, type);        -- uses given type
> +  // The return value is a File object.
> +  nsISupports mozGetAsFile(in DOMString name, [optional] in DOMString type);

Same.

::: widget/nsFilePickerProxy.cpp
@@ +193,5 @@
>  
>  NS_IMETHODIMP
>  nsFilePickerProxy::GetDomfiles(nsISimpleEnumerator** aDomfiles)
>  {
> +  // TODO

Hmm, you're breaking this method, right?  I don't understand what makes that OK.  :-)

::: widget/nsIFilePicker.idl
@@ +146,4 @@
>    *
>    * @return Returns the file currently selected as File
>    */
> +  readonly attribute nsISupports domfile;

Please rev the uuid of this interface as well.
Attachment #8605824 - Flags: review?(ehsan) → review-
Sorry, completely forgot about that TODO.
Attachment #8605824 - Attachment is obsolete: true
Attachment #8605844 - Flags: review?(ehsan)
Keywords: leave-open
Comment on attachment 8605844 [details] [diff] [review]
patch 2 - get rid nsIDOMFile

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

::: widget/nsFilePickerProxy.cpp
@@ +197,5 @@
> +{
> +public:
> +  NS_DECL_ISUPPORTS
> +
> +  SimpleEnumerator(nsTArray<nsRefPtr<File>>& aFiles)

Please make this explicit.

Also shouldn't the argument be const nsTArray&?
Attachment #8605844 - Flags: review?(ehsan) → review+
Comment on attachment 8605867 [details] [diff] [review]
patch 3 - make nsIDOMBlob an empty interface

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

r=me if the below are intentional.

::: dom/devicestorage/nsDeviceStorage.cpp
@@ +2635,5 @@
> +    if (NS_WARN_IF(rv.Failed())) {
> +      rv.SuppressException();
> +      nsCOMPtr<nsIRunnable> event =
> +        new PostErrorEvent(mRequest.forget(), POST_ERROR_EVENT_UNKNOWN);
> +      return NS_DispatchToMainThread(event);

This behavior change is intentional, right?

::: dom/filesystem/CreateFileTask.cpp
@@ +41,5 @@
>    if (aBlobData) {
>      if (FileSystemUtils::IsParentProcess()) {
> +      aBlobData->GetInternalStream(getter_AddRefs(mBlobStream), aRv);
> +      if (NS_WARN_IF(aRv.Failed())) {
> +        return;

Is this correct?  This can leave the object half-initialized.
Attachment #8605867 - Flags: review?(ehsan) → review+
> >      if (FileSystemUtils::IsParentProcess()) {
> > +      aBlobData->GetInternalStream(getter_AddRefs(mBlobStream), aRv);
> > +      if (NS_WARN_IF(aRv.Failed())) {
> > +        return;
> 
> Is this correct?  This can leave the object half-initialized.

No, but the bug is in the current implementation. We should have a Init() method that can return errors instead having all of this code in the CTOR. I'll revert my code and file a follow up.
Summary: Ged rid of nsIDOMFile → Get rid of nsIDOMFile
I'm landing the last patch separately because it introduces a memory leak.

https://treeherder.mozilla.org/#/jobs?repo=try&revision=83525eb46832
I'll work on the last patch in a separate bug because it's not related to nsIDOMFile.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Blocks: 1166231
Target Milestone: --- → mozilla41
Comment on attachment 8605844 [details] [diff] [review]
patch 2 - get rid nsIDOMFile

>-  return NS_NewArrayEnumerator(aDomfiles, mDomfiles);
>+  nsRefPtr<SimpleEnumerator> enumerator = new SimpleEnumerator(mDomfiles);
Rather than rolling your own enumerator, could you not make mDomFiles an nsCOMArray<nsISupports>?
> >-  return NS_NewArrayEnumerator(aDomfiles, mDomfiles);
> >+  nsRefPtr<SimpleEnumerator> enumerator = new SimpleEnumerator(mDomfiles);
> Rather than rolling your own enumerator, could you not make mDomFiles an
> nsCOMArray<nsISupports>?

More than this would be nice to have a template enumerator that take a nsTArray<nsRefPtr<T>>.
Otherwise all the code has to deal with a generic nsCOMArray<nsISupports> and this doesn't make the code readable.
Removing leave-open keyword from resolved bugs, per :sylvestre.
Keywords: leave-open
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: