Update call/ to not use implicit T* --> scoped_refptr<T> conversion

Also change the class SharedModuleThread to final and
without any virtual methods.

Bug: webrtc:13464
Change-Id: If440e4c794955781f7d6bfce67f4554bcc3dc77e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246205
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35695}
This commit is contained in:
Niels Möller
2022-01-14 09:18:23 +01:00
committed by WebRTC LUCI CQ
parent 05dbc5804c
commit 6b7b255e2d
4 changed files with 15 additions and 13 deletions

View File

@ -32,7 +32,8 @@ class BroadcastResourceListener::AdapterResource : public Resource {
MutexLock lock(&lock_);
if (!listener_)
return;
listener_->OnResourceUsageStateMeasured(this, usage_state);
listener_->OnResourceUsageStateMeasured(rtc::scoped_refptr<Resource>(this),
usage_state);
}
// Resource implementation.

View File

@ -29,7 +29,8 @@ FakeResource::~FakeResource() {}
void FakeResource::SetUsageState(ResourceUsageState usage_state) {
if (listener_) {
listener_->OnResourceUsageStateMeasured(this, usage_state);
listener_->OnResourceUsageStateMeasured(rtc::scoped_refptr<Resource>(this),
usage_state);
}
}

View File

@ -591,8 +591,9 @@ SharedModuleThread::~SharedModuleThread() = default;
rtc::scoped_refptr<SharedModuleThread> SharedModuleThread::Create(
std::unique_ptr<ProcessThread> process_thread,
std::function<void()> on_one_ref_remaining) {
return new SharedModuleThread(std::move(process_thread),
std::move(on_one_ref_remaining));
// Using `new` to access a non-public constructor.
return rtc::scoped_refptr<SharedModuleThread>(new SharedModuleThread(
std::move(process_thread), std::move(on_one_ref_remaining)));
}
void SharedModuleThread::EnsureStarted() {

View File

@ -40,13 +40,7 @@ namespace webrtc {
// SharedModuleThread supports a callback that is issued when only one reference
// remains, which is used to indicate to the original owner that the thread may
// be discarded.
class SharedModuleThread : public rtc::RefCountInterface {
protected:
SharedModuleThread(std::unique_ptr<ProcessThread> process_thread,
std::function<void()> on_one_ref_remaining);
friend class rtc::scoped_refptr<SharedModuleThread>;
~SharedModuleThread() override;
class SharedModuleThread final {
public:
// Allows injection of an externally created process thread.
static rtc::scoped_refptr<SharedModuleThread> Create(
@ -58,8 +52,13 @@ class SharedModuleThread : public rtc::RefCountInterface {
ProcessThread* process_thread();
private:
void AddRef() const override;
rtc::RefCountReleaseStatus Release() const override;
friend class rtc::scoped_refptr<SharedModuleThread>;
SharedModuleThread(std::unique_ptr<ProcessThread> process_thread,
std::function<void()> on_one_ref_remaining);
~SharedModuleThread();
void AddRef() const;
rtc::RefCountReleaseStatus Release() const;
class Impl;
mutable std::unique_ptr<Impl> impl_;