Index: webrtc/base/asyncinvoker-inl.h |
diff --git a/webrtc/base/asyncinvoker-inl.h b/webrtc/base/asyncinvoker-inl.h |
index c3691b5659b78935fe6381fd744622cbc11030ef..15fafa888b1fca715f28bb8b4161432f82f9e538 100644 |
--- a/webrtc/base/asyncinvoker-inl.h |
+++ b/webrtc/base/asyncinvoker-inl.h |
@@ -15,6 +15,8 @@ |
#include "webrtc/base/callback.h" |
#include "webrtc/base/criticalsection.h" |
#include "webrtc/base/messagehandler.h" |
+#include "webrtc/base/refcount.h" |
+#include "webrtc/base/scoped_ref_ptr.h" |
#include "webrtc/base/sigslot.h" |
#include "webrtc/base/thread.h" |
@@ -23,13 +25,15 @@ |
class AsyncInvoker; |
// Helper class for AsyncInvoker. Runs a task and triggers a callback |
-// on the calling thread if necessary. |
-class AsyncClosure { |
+// on the calling thread if necessary. Instances are ref-counted so their |
+// lifetime can be independent of AsyncInvoker. |
+class AsyncClosure : public RefCountInterface { |
public: |
- virtual ~AsyncClosure() {} |
// Runs the asynchronous task, and triggers a callback to the calling |
// thread if needed. Should be called from the target thread. |
virtual void Execute() = 0; |
+ protected: |
+ ~AsyncClosure() override {} |
}; |
// Simple closure that doesn't trigger a callback for the calling thread. |