Make nsHttpConnectionInfo immutable, mutability only via a 'mutator' as in the URI case
Categories
(Core :: Networking: HTTP, task, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox69 | --- | affected |
People
(Reporter: mayhemer, Assigned: kershaw, Mentored)
Details
(Whiteboard: [necko-triaged])
Attachments
(1 file, 3 obsolete files)
(deleted),
text/x-phabricator-request
|
Details |
Comment 1•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Hello @Honza
I would like to work on this !!
It would be great if you can explain this a bit more :)
thanks
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Comment 3•5 years ago
|
||
Thanks for the offer of help.
The idea is to make all Set*
methods of nsHttpConnectionInfo
private-friend to a newly written "mutor" helper class. The mutator will have a mirror of all the Set*
methods, public. It will create a clone of the given nsHttpConnectionInfo, modify this clone, and spit it out with a method alreaday_AddRefed<nsHttpConnectionInfo> Finalize()
. Since then any Set*
method call on the mutator will fail, best by throwing the reference to the nsHttpConnectionInfo object away. The Clone
method of nsHttpConnectionInfo should also be made private or simply removed, when found fit.
Then, on all places where nsHttpConnectionInfo is modified by one of its Set* methods in our current code base (will simply pop-up during the build as an error when made private), replace it to use the mutator.
hey @Honza Bambas
You said I need to create class mutor(or mutator ?) . so it should be inside nsHttpConnectionInfo or outside it ?
How should I create it ? Can you explain a bit ?
and I need to create all set* functions like this inside mutor class ?
friend void nsHttpConnectionInfo::SetAnonymous(bool anon);
And what do you mean by clone of the given nsHttpConnectionInfo
?
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Comment 5•5 years ago
|
||
It's mostly about turning this:
class nsHttpConnectionInfo {
public:
void SetFoo(Foo foo);
Foo GetFoo();
private:
Foo mFoo;
};
into something like this (not with necessarily the methods being inline):
class nsHttpConnectionInfo {
public:
Foo GetFoo();
Mutator {
public:
Mutator(nsHttpConnectionInfo* ci) {
mCI = ci->Clone();
}
void SetFoo(Foo foo) {
mCI->mFoo = foo; // this will work becaues nested classes see private members
}
already_AddRefed<nsHttpConnectionInfo> Finalize() {
return mCI.forget();
}
private:
RefPtr<nsHttpConnectionInfo> mCI;
};
private:
Foo mFoo;
};
the use of the Mutator is I believe obvious?
@Honza
Got it and will submit the patch as soon as possible :)
Thanks for help !!
hey @honza
Can you help me with this error
/home/mahak/mozilla-central/netwerk/protocol/http/TRRServiceChannel.cpp:391:22: error: no member named 'SetNoSpdy' in 'mozilla::net::nsHttpConnectionInfo'
0:05.73 mConnectionInfo->SetNoSpdy(true);
how do I change this using mutator class ?
@Honza
Should I submit the patch so that you can guide me in a better way ?
Assignee | ||
Comment 9•5 years ago
|
||
(In reply to Mahak from comment #8)
@Honza
Should I submit the patch so that you can guide me in a better way ?
Yes, I think it'd be good to submit your WIP patch.
Comment 10•5 years ago
|
||
Comment 11•5 years ago
|
||
Not sure whom to add as the reviewer ?
Updated•5 years ago
|
Assignee | ||
Comment 12•4 years ago
|
||
Hi Mahak,
I'd like to work on this one.
Please let me know if you'd like to continue with this.
Thank you.
Comment 13•4 years ago
|
||
Hi Kershaw!
Go ahead. I'm not working on this anymore
Thanks :)
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 14•4 years ago
|
||
Assignee | ||
Comment 15•4 years ago
|
||
Assignee | ||
Comment 16•4 years ago
|
||
Depends on D91904
Assignee | ||
Comment 17•4 years ago
|
||
Depends on D91905
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 18•2 years ago
|
||
I think this is a WONTFIX, since copying a connection info every time introduce some extra performance overhead.
Description
•