Closed Bug 412691 Opened 17 years ago Closed 17 years ago

Remove unnecessary nsCOMPtr's from caps code.

Categories

(Core :: Security: CAPS, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9beta3

People

(Reporter: jst, Assigned: jst)

References

Details

(Keywords: perf)

Attachments

(1 file)

CheckPropertyAccessImpl() uses a nsCOMPtr for a principal when it doesn't need to, and also does a QI on all objects that claim to be nsIClassInfo::CONTENT_NODE objects to QI from nsISupports to nsIContent. Removing the former is obvious, the latter can safely be replaced with a cast because the only objects that claim to be CONTENT_NODE objects are ones that implement nsIContent, and their nsISupport pointers are safe to cast to nsIContent (we depend on that elsewhere). And also note, that if the QI that's there now would fail, we'd crash in the current code, so we can already be sure that nothing that doesn't implement nsIContent comes into this code.
Flags: blocking1.9+
Attachment #297435 - Flags: superreview?(jonas)
Attachment #297435 - Flags: review?(jonas)
Assignee: dveditz → jst
Comment on attachment 297435 [details] [diff] [review]
Remove unnecessary nsCOMPtr and replace QI with a cast.

I think technically 'kungFuDeathGrip' is wrong here. I think we call this *Owner or something in other places, so principalOwner here or some such.

r/sr=me either way
Attachment #297435 - Flags: superreview?(jonas)
Attachment #297435 - Flags: superreview+
Attachment #297435 - Flags: review?(jonas)
Attachment #297435 - Flags: review+
Checked in with s/kungFuDeathGrip/principalHolder/. Marking FIXED.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Version: unspecified → Trunk
Comment on attachment 297435 [details] [diff] [review]
Remove unnecessary nsCOMPtr and replace QI with a cast.

>-        nsCOMPtr<nsIContent> content(do_QueryInterface(aObj));
>+        nsIContent *content = static_cast<nsIContent*>(aObj);
>         NS_ASSERTION(content, "classinfo had CONTENT_NODE set but node did not"
>                               "implement nsIContent!  Fasten your seat belt.");
Unlike the QI, the cast will always "succeed", so the ASSERTION is useless, no?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: