Closed Bug 157135 Opened 22 years ago Closed 22 years ago

nsIFileURL need to be frozen

Categories

(Core Graveyard :: Embedding: APIs, defect, P2)

x86
Windows 2000

Tracking

(Not tracked)

VERIFIED FIXED
mozilla1.2beta

People

(Reporter: dougt, Assigned: darin.moz)

References

Details

(Keywords: arch, topembed)

Attachments

(1 file, 1 obsolete file)

Needed Functionality using nsIFileChannel to determine if channel is file. maybe this can be on the nsIChannel?
note: nsIChannel is frozen.
Blocks: 70229
Blocks: 157137
-> schemeis("file", &ret) will allow you "to determine if channel is file", won't it?
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.
> 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. :-)
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.
good plan. I never like QI to nsIFileURL, have it succeed, then detecting the failure when you call getFile().
darin
Assignee: dougt → darin
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla1.2beta
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
Severity: normal → major
Keywords: arch, nsbeta1, topembed
Priority: P3 → P2
Keywords: mozilla1.2
Attached 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 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).
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 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?
Attached 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
darn, looks like i didn't address all of dougt's comments... new patch coming up.
QA Contact: mdunn → depstein
> 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.
I could have swore that xpconnect had problems with not nulling the out var.
If the function returns an error code XPConnect doesn't touch the out parameters.
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+
fixed-on-trunk :)
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
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
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: