Closed Bug 1711078 Opened 4 years ago Closed 4 years ago

Mark immutable nsIPrincipal fields as `const`

Categories

(Core :: DOM: Security, task)

task

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: nika, Assigned: nika)

References

Details

Attachments

(2 files)

This requires changing the way that principals are created, so that they aren't constructed using an Init function, but rather using constructors, so that important internal fields can be marked as const. This is a step towards bug 1443925 by making the remaining mutable fields clearly mutable. These fields will need to be stored behind a mutex of some sort before nsIPrincipal can be made properly threadsafe.

This is necessary to remove the Init methods from principals, allowing
immutable fields to be marked as const and clearly separated from mutable
fields to improve threadsafety.

This is a step towards separating the mutable state on principals from const
state which can be made threadsafe. The remaining mutable fields will either
need to be moved off of nsIPrincipal or made threadsafe to destroy (e.g. using
nsMainThreadPtrHandle) and stored behind a mutex.

Serialization is handled for most types using a separate Deserializer class,
like how it was handled with nsIURI mutators. SystemPrincipal wasn't changed
as the Read method is a no-op for that class.

Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f8e166c5eb17 Part 1: Stop using the component manager to create non-system principals, r=ckerschb https://hg.mozilla.org/integration/autoland/rev/0eaf4b701fa2 Part 2: Mark immutable fields in principal types as const, r=ckerschb
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
See Also: → 1711670
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: