RefCountInterface: Make AddRef() and Release() const
This CL makes AddRef() and Release() const member methods and the refcount integer mutable. This is reasonable, because they only manage the lifetime of the object, and this is also how it's done in Chromium.
The purpose is to be able to capture a const pointer in a scoped_refptr, which is currenty impossible. The practial problem this CL solves is this:
void Foo::Bar() const {}
rtc::Callback0<void> Foo::MakeClosure() const {
return rtc::Bind(&Foo::Bar, this);
}
We currently capture |this| as const Foo*. With this CL, |this| will be captured as scoped_refptr<const Foo>.
A test is also added in bind_unittest to check this behaviour.
BUG=webrtc:5065
R=perkj@webrtc.org, tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1403683004 .
Cr-Original-Commit-Position: refs/heads/master@{#10253}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 1b40a9a8afe0d7b2244ad8dea19e8222fec3c207
6 files changed