Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1535)

Unified Diff: webrtc/base/asyncinvoker.cc

Issue 2689233003: Relanding: Use std::unique_ptr instead of rtc::scoped_refptr in AsyncInvoker. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/asyncinvoker.h ('k') | webrtc/base/asyncinvoker-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/asyncinvoker.cc
diff --git a/webrtc/base/asyncinvoker.cc b/webrtc/base/asyncinvoker.cc
index 83a873811e7258a16a982c39609598114ca78055..77b63a4e66a6f82de6e9ac47c0d1d7d8db00a317 100644
--- a/webrtc/base/asyncinvoker.cc
+++ b/webrtc/base/asyncinvoker.cc
@@ -26,14 +26,11 @@ AsyncInvoker::~AsyncInvoker() {
void AsyncInvoker::OnMessage(Message* msg) {
// Get the AsyncClosure shared ptr from this message's data.
- ScopedRefMessageData<AsyncClosure>* data =
- static_cast<ScopedRefMessageData<AsyncClosure>*>(msg->pdata);
- scoped_refptr<AsyncClosure> closure = data->data();
- delete msg->pdata;
- msg->pdata = NULL;
-
+ ScopedMessageData<AsyncClosure>* data =
+ static_cast<ScopedMessageData<AsyncClosure>*>(msg->pdata);
// Execute the closure and trigger the return message if needed.
- closure->Execute();
+ data->inner_data().Execute();
+ delete data;
}
void AsyncInvoker::Flush(Thread* thread, uint32_t id /*= MQID_ANY*/) {
@@ -56,19 +53,19 @@ void AsyncInvoker::Flush(Thread* thread, uint32_t id /*= MQID_ANY*/) {
void AsyncInvoker::DoInvoke(const Location& posted_from,
Thread* thread,
- const scoped_refptr<AsyncClosure>& closure,
+ std::unique_ptr<AsyncClosure> closure,
uint32_t id) {
if (destroying_) {
LOG(LS_WARNING) << "Tried to invoke while destroying the invoker.";
return;
}
thread->Post(posted_from, this, id,
- new ScopedRefMessageData<AsyncClosure>(closure));
+ new ScopedMessageData<AsyncClosure>(std::move(closure)));
}
void AsyncInvoker::DoInvokeDelayed(const Location& posted_from,
Thread* thread,
- const scoped_refptr<AsyncClosure>& closure,
+ std::unique_ptr<AsyncClosure> closure,
uint32_t delay_ms,
uint32_t id) {
if (destroying_) {
@@ -76,7 +73,7 @@ void AsyncInvoker::DoInvokeDelayed(const Location& posted_from,
return;
}
thread->PostDelayed(posted_from, delay_ms, this, id,
- new ScopedRefMessageData<AsyncClosure>(closure));
+ new ScopedMessageData<AsyncClosure>(std::move(closure)));
}
GuardedAsyncInvoker::GuardedAsyncInvoker() : thread_(Thread::Current()) {
« no previous file with comments | « webrtc/base/asyncinvoker.h ('k') | webrtc/base/asyncinvoker-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698