Open
Bug 1260774
Opened 10 years ago
Updated 3 years ago
Create RAII class for IPC Actors that should get __delete__'d unless some conditions are met
Categories
(Core :: IPC, defect, P3)
Core
IPC
Tracking
()
NEW
People
(Reporter: mconley, Unassigned)
Details
(Whiteboard: btpp-backlog)
In bug 1251032, kanru rightly noted that we have this pattern:
``` Pseudocode
ThingChild* thing = someActor->SendThingConstructor();
if (!foo) {
// ... things happen in here.
// Oh no, things have gone wrong - delete the child
PThingChild::Send__delete__(thing);
} else if (bar) {
// ... do some things
nsresult rv = something->DoTheJob();
if (NS_FAILED(rv)) {
PThingChild::Send__delete__(thing);
}
} else {
// All is well, don't delete the Thing
}
```
This can get more complicated as more checks are put into place for the various conditions where ThingChild should be deleted.
An RAII class might allow us to do something like this:
``` Pseudocode
ThingChild* thing = someActor->SendThingConstructor();
{
AutoIPCDeleter autoThingDeleter(thing);
if (!foo) {
// ... things happen in here.
// No need to delete the child - that'll occur once AutoIPCDeleter goes out of scope.
} else if (bar) {
// ... do some things
nsresult rv = something->DoTheJob();
if (NS_FAILED(rv)) {
// No need to delete the child - that'll occur once AutoIPCDeleter goes out of scope.
}
} else {
// All is well, don't delete the Thing
autoThingDeleter.Preserve();
}
}
```
I wonder if something more like this second pattern will allow us to avoid cases where we forget to delete some Actors when things go wrong.
Component: DOM: Content Processes → IPC
Updated•10 years ago
|
Whiteboard: btpp-backlog
Updated•9 years ago
|
Priority: -- → P3
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•