nsIFileURL need to be frozen

VERIFIED FIXED in mozilla1.2beta

Status

()

Core
Embedding: APIs
P2
major
VERIFIED FIXED
15 years ago
15 years ago

People

(Reporter: dougt, Assigned: Darin Fisher)

Tracking

({arch, topembed})

Trunk
mozilla1.2beta
x86
Windows 2000
arch, topembed
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

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

maybe this can be on the nsIChannel?

Comment 1

15 years ago
note: nsIChannel is frozen.
Blocks: 70229
(Reporter)

Updated

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

Comment 3

15 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.
(Reporter)

Comment 5

15 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.   :-)

(Assignee)

Comment 6

15 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.
(Reporter)

Comment 7

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

Comment 8

15 years ago
darin
Assignee: dougt → darin
(Assignee)

Updated

15 years ago
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla1.2beta
(Assignee)

Comment 9

15 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
(Assignee)

Updated

15 years ago
Severity: normal → major
Keywords: arch, nsbeta1, topembed
Priority: P3 → P2
(Assignee)

Updated

15 years ago
Keywords: mozilla1.2
(Assignee)

Comment 10

15 years ago
Created attachment 99291 [details] [diff] [review]
v1 patch

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
expect.

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).
(Assignee)

Comment 11

15 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.
(Reporter)

Comment 12

15 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?
(Assignee)

Comment 13

15 years ago
Created attachment 100265 [details] [diff] [review]
v2 patch

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
(Assignee)

Comment 14

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

Updated

15 years ago
QA Contact: mdunn → depstein
(Assignee)

Comment 15

15 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.
(Reporter)

Comment 16

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

Comment 17

15 years ago
If the function returns an error code XPConnect doesn't touch the out parameters.
(Reporter)

Comment 18

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

r=dougt

Before landing this, please see:
http://www.mozilla.org/projects/embedding/HowToFreeze.html

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
macro.
Attachment #100265 - Flags: superreview+
(Assignee)

Comment 20

15 years ago
fixed-on-trunk :)
Status: ASSIGNED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED

Comment 21

15 years ago
Verified patch checkin against Mozilla 1.2b Mozilla/5.0 (Windows; U; WinNT4.0;
en-US; rv:1.2b) Gecko/20021026 build.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.