Closed Bug 1723807 Opened 4 years ago Closed 4 years ago

Make getURLSpecFromFile [noscript] and improve idl comments to indicate why you should use one or the other

Categories

(Core :: Networking: File, defect, P3)

defect

Tracking

()

RESOLVED FIXED
92 Branch
Tracking Status
firefox92 --- fixed

People

(Reporter: Gijs, Assigned: Gijs)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

From Florian's feedback:

While reviewing, I wondered "so what happens if the wrong function is called, or if the user messed with a preference in about:config and we are no longer pointing to a folder, ..." and I found the comments at https://searchfox.org/mozilla-central/rev/4f05a46731c1f7f111ec7a41ce38a34594aa0d37/netwerk/protocol/file/nsIFileProtocolHandler.idl#32-58 quite unhelpful.

I don't think this needs to be part of this patch, but I think it would be nice to rephrase the comments to explain that it's fine to call getURLSpecFromActualFile on any file, and that the only difference with getURLSpecFromDir is that it will ensure the url ends with a trailing /.

Comments like "NOTE: Callers should use getURLSpecFromActualFile or getURLSpecFromDirFile if possible, for performance reasons." and "identical to getURLSpecFromFile, but is usually more efficient." don't make much sense to me. Is it just slightly more efficient? When reading such a comment I would never guess that we can block the main thread for 5s.

getURLSpecFromFile should probably be made [noscript], but if we want to do it we should give our Thunderbird friends a heads up, as there are 8 uses (+6 in tests) in mail/.

Depends on: 1723811
Severity: -- → S3
Priority: -- → P3
Whiteboard: [necko-triaged]
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/c9d056f74217 make getURLSpecFromFile [noscript] and clarify its idl comments to discourage use more forcefully, r=valentin,necko-reviewers
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 92 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: