Mark AsyncInvoker as deprecated

Also fix similar annotation on NackModule to have effect
(when defining an alias with C++ using, ABSL_DEPRECATED should appear
on the left hand side).

Bug: webrtc:12339
Change-Id: Id80a20bf2c56a826777b8a40e06ac5c65e4f8db7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217242
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33905}
diff --git a/modules/video_coding/deprecated/nack_module.h b/modules/video_coding/deprecated/nack_module.h
index 0ad009b..2fac6ce 100644
--- a/modules/video_coding/deprecated/nack_module.h
+++ b/modules/video_coding/deprecated/nack_module.h
@@ -125,7 +125,7 @@
   const absl::optional<BackoffSettings> backoff_settings_;
 };
 
-using NackModule = ABSL_DEPRECATED("") DEPRECATED_NackModule;
+using NackModule ABSL_DEPRECATED("") = DEPRECATED_NackModule;
 
 }  // namespace webrtc
 
diff --git a/rtc_base/async_invoker.cc b/rtc_base/async_invoker.cc
index f758670..87d0393 100644
--- a/rtc_base/async_invoker.cc
+++ b/rtc_base/async_invoker.cc
@@ -15,12 +15,12 @@
 
 namespace rtc {
 
-AsyncInvoker::AsyncInvoker()
+DEPRECATED_AsyncInvoker::DEPRECATED_AsyncInvoker()
     : pending_invocations_(0),
       invocation_complete_(make_ref_counted<Event>()),
       destroying_(false) {}
 
-AsyncInvoker::~AsyncInvoker() {
+DEPRECATED_AsyncInvoker::~DEPRECATED_AsyncInvoker() {
   destroying_.store(true, std::memory_order_relaxed);
   // Messages for this need to be cleared *before* our destructor is complete.
   ThreadManager::Clear(this);
@@ -37,7 +37,7 @@
   }
 }
 
-void AsyncInvoker::OnMessage(Message* msg) {
+void DEPRECATED_AsyncInvoker::OnMessage(Message* msg) {
   // Get the AsyncClosure shared ptr from this message's data.
   ScopedMessageData<AsyncClosure>* data =
       static_cast<ScopedMessageData<AsyncClosure>*>(msg->pdata);
@@ -46,7 +46,8 @@
   delete data;
 }
 
-void AsyncInvoker::Flush(Thread* thread, uint32_t id /*= MQID_ANY*/) {
+void DEPRECATED_AsyncInvoker::Flush(Thread* thread,
+                                    uint32_t id /*= MQID_ANY*/) {
   // If the destructor is waiting for invocations to finish, don't start
   // running even more tasks.
   if (destroying_.load(std::memory_order_relaxed))
@@ -67,14 +68,14 @@
   }
 }
 
-void AsyncInvoker::Clear() {
+void DEPRECATED_AsyncInvoker::Clear() {
   ThreadManager::Clear(this);
 }
 
-void AsyncInvoker::DoInvoke(const Location& posted_from,
-                            Thread* thread,
-                            std::unique_ptr<AsyncClosure> closure,
-                            uint32_t id) {
+void DEPRECATED_AsyncInvoker::DoInvoke(const Location& posted_from,
+                                       Thread* thread,
+                                       std::unique_ptr<AsyncClosure> closure,
+                                       uint32_t id) {
   if (destroying_.load(std::memory_order_relaxed)) {
     // Note that this may be expected, if the application is AsyncInvoking
     // tasks that AsyncInvoke other tasks. But otherwise it indicates a race
@@ -87,11 +88,12 @@
                new ScopedMessageData<AsyncClosure>(std::move(closure)));
 }
 
-void AsyncInvoker::DoInvokeDelayed(const Location& posted_from,
-                                   Thread* thread,
-                                   std::unique_ptr<AsyncClosure> closure,
-                                   uint32_t delay_ms,
-                                   uint32_t id) {
+void DEPRECATED_AsyncInvoker::DoInvokeDelayed(
+    const Location& posted_from,
+    Thread* thread,
+    std::unique_ptr<AsyncClosure> closure,
+    uint32_t delay_ms,
+    uint32_t id) {
   if (destroying_.load(std::memory_order_relaxed)) {
     // See above comment.
     RTC_LOG(LS_WARNING) << "Tried to invoke while destroying the invoker.";
@@ -101,7 +103,7 @@
                       new ScopedMessageData<AsyncClosure>(std::move(closure)));
 }
 
-AsyncClosure::AsyncClosure(AsyncInvoker* invoker)
+AsyncClosure::AsyncClosure(DEPRECATED_AsyncInvoker* invoker)
     : invoker_(invoker), invocation_complete_(invoker_->invocation_complete_) {
   invoker_->pending_invocations_.fetch_add(1, std::memory_order_relaxed);
 }
diff --git a/rtc_base/async_invoker.h b/rtc_base/async_invoker.h
index 01ab19e..fd42ca7 100644
--- a/rtc_base/async_invoker.h
+++ b/rtc_base/async_invoker.h
@@ -15,6 +15,7 @@
 #include <memory>
 #include <utility>
 
+#include "absl/base/attributes.h"
 #include "api/scoped_refptr.h"
 #include "rtc_base/async_invoker_inl.h"
 #include "rtc_base/constructor_magic.h"
@@ -86,10 +87,10 @@
 //   destruction. This can be done by starting each chain of invocations on the
 //   same thread on which it will be destroyed, or by using some other
 //   synchronization method.
-class AsyncInvoker : public MessageHandlerAutoCleanup {
+class DEPRECATED_AsyncInvoker : public MessageHandlerAutoCleanup {
  public:
-  AsyncInvoker();
-  ~AsyncInvoker() override;
+  DEPRECATED_AsyncInvoker();
+  ~DEPRECATED_AsyncInvoker() override;
 
   // Call |functor| asynchronously on |thread|, with no callback upon
   // completion. Returns immediately.
@@ -165,9 +166,12 @@
 
   friend class AsyncClosure;
 
-  RTC_DISALLOW_COPY_AND_ASSIGN(AsyncInvoker);
+  RTC_DISALLOW_COPY_AND_ASSIGN(DEPRECATED_AsyncInvoker);
 };
 
+using AsyncInvoker ABSL_DEPRECATED("bugs.webrtc.org/12339") =
+    DEPRECATED_AsyncInvoker;
+
 }  // namespace rtc
 
 #endif  // RTC_BASE_ASYNC_INVOKER_H_
diff --git a/rtc_base/async_invoker_inl.h b/rtc_base/async_invoker_inl.h
index d731f99..9fb3287 100644
--- a/rtc_base/async_invoker_inl.h
+++ b/rtc_base/async_invoker_inl.h
@@ -21,20 +21,20 @@
 
 namespace rtc {
 
-class AsyncInvoker;
+class DEPRECATED_AsyncInvoker;
 
 // Helper class for AsyncInvoker. Runs a task and triggers a callback
 // on the calling thread if necessary.
 class AsyncClosure {
  public:
-  explicit AsyncClosure(AsyncInvoker* invoker);
+  explicit AsyncClosure(DEPRECATED_AsyncInvoker* invoker);
   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:
-  AsyncInvoker* invoker_;
+  DEPRECATED_AsyncInvoker* invoker_;
   // Reference counted so that if the AsyncInvoker destructor finishes before
   // an AsyncClosure's destructor that's about to call
   // "invocation_complete_->Set()", it's not dereferenced after being
@@ -46,7 +46,8 @@
 template <class FunctorT>
 class FireAndForgetAsyncClosure : public AsyncClosure {
  public:
-  explicit FireAndForgetAsyncClosure(AsyncInvoker* invoker, FunctorT&& functor)
+  explicit FireAndForgetAsyncClosure(DEPRECATED_AsyncInvoker* invoker,
+                                     FunctorT&& functor)
       : AsyncClosure(invoker), functor_(std::forward<FunctorT>(functor)) {}
   virtual void Execute() { functor_(); }
 
diff --git a/rtc_base/thread_unittest.cc b/rtc_base/thread_unittest.cc
index 1883c6d..789bdd9 100644
--- a/rtc_base/thread_unittest.cc
+++ b/rtc_base/thread_unittest.cc
@@ -521,7 +521,7 @@
 
     // Asynchronously invoke SetAndInvokeSet on |thread1| and wait until
     // |thread1| starts the call.
-    static void AsyncInvokeSetAndWait(AsyncInvoker* invoker,
+    static void AsyncInvokeSetAndWait(DEPRECATED_AsyncInvoker* invoker,
                                       Thread* thread1,
                                       Thread* thread2,
                                       LockedBool* out) {
@@ -536,7 +536,7 @@
     }
   };
 
-  AsyncInvoker invoker;
+  DEPRECATED_AsyncInvoker invoker;
   LockedBool thread_a_called(false);
 
   // Start the sequence A --(invoke)--> B --(async invoke)--> C --(invoke)--> A.
@@ -761,7 +761,7 @@
 };
 
 TEST_F(AsyncInvokeTest, FireAndForget) {
-  AsyncInvoker invoker;
+  DEPRECATED_AsyncInvoker invoker;
   // Create and start the thread.
   auto thread = Thread::CreateWithSocketServer();
   thread->Start();
@@ -773,7 +773,7 @@
 }
 
 TEST_F(AsyncInvokeTest, NonCopyableFunctor) {
-  AsyncInvoker invoker;
+  DEPRECATED_AsyncInvoker invoker;
   // Create and start the thread.
   auto thread = Thread::CreateWithSocketServer();
   thread->Start();
@@ -804,7 +804,7 @@
       EXPECT_FALSE(invoker_destroyed);
       functor_finished.Set();
     };
-    AsyncInvoker invoker;
+    DEPRECATED_AsyncInvoker invoker;
     invoker.AsyncInvoke<void>(RTC_FROM_HERE, thread.get(), functor);
     functor_started.Wait(Event::kForever);
 
@@ -833,7 +833,7 @@
   Thread thread(std::make_unique<NullSocketServer>());
   thread.Start();
   {
-    AsyncInvoker invoker;
+    DEPRECATED_AsyncInvoker invoker;
     auto reentrant_functor = [&reentrant_functor_run] {
       reentrant_functor_run = true;
     };
@@ -852,7 +852,7 @@
 }
 
 TEST_F(AsyncInvokeTest, Flush) {
-  AsyncInvoker invoker;
+  DEPRECATED_AsyncInvoker invoker;
   AtomicBool flag1;
   AtomicBool flag2;
   // Queue two async calls to the current thread.
@@ -868,7 +868,7 @@
 }
 
 TEST_F(AsyncInvokeTest, FlushWithIds) {
-  AsyncInvoker invoker;
+  DEPRECATED_AsyncInvoker invoker;
   AtomicBool flag1;
   AtomicBool flag2;
   // Queue two async calls to the current thread, one with a message id.