Closed Bug 1779829 Opened 2 years ago Closed 2 years ago

Shmem::PrivateIPDLCaller is a poor substitute for `friend` and `private`

Categories

(Core :: IPC, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: jimb, Assigned: jimb, NeedInfo)

Details

Attachments

(1 file)

The mozilla::ipc::Shmem class's PrivateIPDLCaller member type is used to discourage developers from adding calls to certain Shmem methods - but this purpose is better served using C++'s private members and friend specifiers: IProtocol and IToplevelProtocol should become friends of Shmem.

Note that, if a class C designates some other class F as a friend, classes derived from F are not considered friends of C. So making IProtocol and IToplevelProtocol friends of Shmem does not grant all IPDL actors access to Shmem's private members.

However, using friend does grant IProtocol and IToplevelProtocol access to Shmems private data members, not just their member functions, as with disciplined use of PrivateIPDLCaller. But this seems like a reasonable compromise in exchange for better static checks and error messages.

Instead of using the public member type PrivateIPDLCaller to
restrict access to certain Shmem member functions, make them
private, and designated IProtocol and ITopLevelProtocol as
friends of Shmem.

Assignee: nobody → jimb
Status: NEW → ASSIGNED
Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b94861755266
Replace `Shmem::PrivateIPDLCaller` with `friend` specifiers. r=nika

Backed out for causing build bustages on ProtocolFuzzer.h

Backout link

Push with failures

Failure log

Flags: needinfo?(jimb)
Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3772e557a8b9
Replace `Shmem::PrivateIPDLCaller` with `friend` specifiers. r=nika
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: