nsIFileURL need to be frozen

VERIFIED FIXED in mozilla1.2beta


17 years ago
25 days ago


(Reporter: dougt, Assigned: darin.moz)


({arch, topembed})

Windows 2000
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)



(1 attachment, 1 obsolete attachment)

31.16 KB, patch
: review+
: superreview+
Details | Diff | Splinter Review


17 years ago
Needed Functionality
    using nsIFileChannel to determine if channel is file.

maybe this can be on the nsIChannel?

Comment 1

17 years ago
note: nsIChannel is frozen.
Blocks: 70229


17 years ago
Blocks: 157137
-> schemeis("file", &ret) will allow you "to determine if channel is file",
won't it?

Comment 3

17 years ago
if the answer to that is a definitive yes, then we can close this bug.  
IF you can give an example of why/where this is needed, then I can tell you if
it will.

nsIFileChannel gives you more functionality, though, which you may or may not need.

Comment 5

17 years ago
> IF you can give an example of why/where this is needed, then I can tell you if
it will

If i had a concrete example, I could *also* tell if this is a problem.  This bug
is mainly for me to figure out if it is needed.   :-)


Comment 6

17 years ago
SchemeIs("file", &ret) tells you the protocol type of a nsIURI, which also tells
you that the URL is handled by the file protocol handler.  so, the SchemeIs test
is sufficient.

however, doug, i thought you mentioned that there was also need for nsIFileURL
to be frozen?  what i really wanted to do was add a new parameter to
nsIStandardURL::Init that would determine if the nsStandardURL object could QI
to nsIFileURL.  then the HTTP protocol handler for example could pass FALSE, and
the file protocol handler could pass TRUE.  this would allow people to QI a
nsIURI to nsIFileURL to determine the nsIFile without having to first call
SchemeIs("file").  this is important since the resource URLs also map to local
files exposed via nsIFileURL.

Comment 7

17 years ago
good plan.  I never like QI to nsIFileURL, have it succeed, then detecting the
failure when you call getFile().

Comment 8

17 years ago
Assignee: dougt → darin


17 years ago
Priority: -- → P3
Target Milestone: --- → mozilla1.2beta

Comment 9

17 years ago
ok, to summarize what needs to be done here: **freeze nsIFileURL only**

i'll work on the necessary changes to nsStandardURL and nsIStandardURL to
implement comment #6 paragraph 2.
Summary: File Interface need to be frozen → nsIFileURL need to be frozen


17 years ago
Severity: normal → major
Keywords: arch, nsbeta1, topembed
Priority: P3 → P2


17 years ago
Keywords: mozilla1.2

Comment 10

17 years ago
Posted patch v1 patch (obsolete) — Splinter Review
this patch breaks nsIFileURL out of nsStandardURL, and introduces a subclass of
nsStandardURL specific to the file protocol handler.  nsResURL, which has
always been a subclass of nsStandardURL, now explicitly implements nsIFileURL
(instead of just overriding the impl from nsStandardURL).

this cleans up the "QI to nsIFileURL" issue... now only file: and resource:
nsIURI's can QI to nsIFileURL.	i think this is way more inline with what folks

i've also gotten rid of a couple of create instance calls, and added in a
cleanup/optimization in the HTTP NewURI code (now it just calls new on a
nsStandardURL instead of talking to the component manager to get a
nsStandardURL object).

Comment 11

17 years ago
oh, one more important thing... it seemed cleaner to make nsIFileURL inherit
from nsISupports instead of nsIURL.  this simplifies the inheritance, and i
found that it doesn't really hurt the usability of the interface since most
folks just QI to nsIFileURL to get/set the nsIFile... few actually keep a
nsIFileURL around in order to access the nsIURI/nsIURL methods.  FWIW,
nsIStandardURL also inherits from nsISupports.

Comment 12

17 years ago
Comment on attachment 99291 [details] [diff] [review]
v1 patch

fix the spacing in nsExternalHelperAppService.cpp
+      nsCOMPtr <nsIFile> file;

please replace the comments that you removed from nsIStandardURL.idl with
something that reflects reality.

net_GetFileFromURLSpec doesn't null the in result.  In nsFileURLImpl::GetFile,
we should null *result if there is a failur.  You can fix this either in
nsFileURLImpl::GetFile or in the net_ calls.

Do we really have to clone the file in SetFile()?  Shouldn't the caller just
not mess with the object it passes?

If nsIFileURL doesn't derive from nsIURL, why is it named nsXXXURL?

Comment 13

17 years ago
Posted patch v2 patchSplinter Review
dougt and i talked about this bug, and we came up with a much better solution. 
now, instead of subclassing nsStandardURL to add support for nsIFileURL,
nsStandardURL now provides a constructor, which allows support for nsIFileURL
to be conditionally allowed.  this simplifies the inheritance structure as well
as the patch :)

a lot of the changes that i made throughout the tree in the v1 patch are still
needed since the assumption that nsStandardURL always implements nsIFileURL is
no longer valid.
Attachment #99291 - Attachment is obsolete: true

Comment 14

17 years ago
darn, looks like i didn't address all of dougt's comments... new patch coming up.


17 years ago
QA Contact: mdunn → depstein

Comment 15

17 years ago
> net_GetFileFromURLSpec doesn't null the in result.  In nsFileURLImpl::GetFile,
> we should null *result if there is a failur.  You can fix this either in
> nsFileURLImpl::GetFile or in the net_ calls.

nsStandardURL::GetFile() never NULL'd out the return param on failure.  that's
not required by XPCOM.  consumers are supposed to check the nsresult returned
for failure.

otherwise, i just tweaked the patch to fix the "nsCOMPtr <nsIFile>" issue.

Comment 16

17 years ago
I could have swore that xpconnect had problems with not nulling the out var.

Comment 17

17 years ago
If the function returns an error code XPConnect doesn't touch the out parameters.

Comment 18

17 years ago
Comment on attachment 100265 [details] [diff] [review]
v2 patch


Before landing this, please see:

You should send a mail announcing that this interface is frozen.
Attachment #100265 - Flags: review+
Comment on attachment 100265 [details] [diff] [review]
v2 patch

sr=bzbarsky if you file another bug on an NS_INTERFACE_MAP_ENTRY_CONDITIONAL
Attachment #100265 - Flags: superreview+

Comment 20

17 years ago
fixed-on-trunk :)
Last Resolved: 17 years ago
Resolution: --- → FIXED

Comment 21

17 years ago
Verified patch checkin against Mozilla 1.2b Mozilla/5.0 (Windows; U; WinNT4.0;
en-US; rv:1.2b) Gecko/20021026 build.


25 days ago
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.