Delete almost unused utility rtc::Ref

Instead, use explicit declaration
scoped_ref_ptr<FinalRefCountedObject<Event>> in AsyncInvoker classes.

Bug: webrtc:12701
Change-Id: I7ce43e2dc99a51b610852b4feda79e4bf86ee4ea
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265803
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37210}
diff --git a/rtc_base/async_invoker.h b/rtc_base/async_invoker.h
index c1f2060..f1b0311 100644
--- a/rtc_base/async_invoker.h
+++ b/rtc_base/async_invoker.h
@@ -153,7 +153,7 @@
   // Reference counted so that if the destructor finishes before an
   // AsyncClosure's destructor that's about to call
   // "invocation_complete_->Set()", it's not dereferenced after being destroyed.
-  rtc::Ref<Event>::Ptr invocation_complete_;
+  rtc::scoped_refptr<FinalRefCountedObject<Event>> invocation_complete_;
 
   // This flag is used to ensure that if an application AsyncInvokes tasks that
   // recursively AsyncInvoke other tasks ad infinitum, the cycle eventually
diff --git a/rtc_base/async_invoker_inl.h b/rtc_base/async_invoker_inl.h
index c2b6413..0ab0efb 100644
--- a/rtc_base/async_invoker_inl.h
+++ b/rtc_base/async_invoker_inl.h
@@ -39,7 +39,7 @@
   // an AsyncClosure's destructor that's about to call
   // "invocation_complete_->Set()", it's not dereferenced after being
   // destroyed.
-  rtc::Ref<Event>::Ptr invocation_complete_;
+  rtc::scoped_refptr<FinalRefCountedObject<Event>> invocation_complete_;
 };
 
 // Simple closure that doesn't trigger a callback for the calling thread.
diff --git a/rtc_base/ref_counted_object.h b/rtc_base/ref_counted_object.h
index 8309ba4..d94e670 100644
--- a/rtc_base/ref_counted_object.h
+++ b/rtc_base/ref_counted_object.h
@@ -185,59 +185,6 @@
       new FinalRefCountedObject<T>(std::forward<Args>(args)...));
 }
 
-// `Ref<>`, `Ref<>::Type` and `Ref<>::Ptr`:
-//
-// `Ref` is a type declaring utility that is compatible with `make_ref_counted`
-// and can be used in classes and methods where it's more convenient (or
-// readable) to have the compiler figure out the fully fleshed out type for a
-// class rather than spell it out verbatim in all places the type occurs (which
-// can mean maintenance work if the class layout changes).
-//
-// Usage examples:
-//
-// If you want to declare the parameter type that's always compatible with
-// this code:
-//
-//   Bar(make_ref_counted<Foo>());
-//
-// You can use `Ref<>::Ptr` to declare a compatible scoped_refptr type:
-//
-//   void Bar(Ref<Foo>::Ptr p);
-//
-// This might be more practically useful in templates though.
-//
-// In rare cases you might need to be able to declare a parameter that's fully
-// compatible with the reference counted T type - and just using T* is not
-// enough. To give a code example, we can declare a function, `Foo` that is
-// compatible with this code:
-//   auto p = make_ref_counted<Foo>();
-//   Foo(p.get());
-//
-//   void Foo(Ref<Foo>::Type* foo_ptr);
-//
-// Alternatively this would be:
-//   void Foo(Foo* foo_ptr);
-// or
-//   void Foo(FinalRefCountedObject<Foo>* foo_ptr);
-
-// Declares the approprate reference counted type for T depending on whether
-// T is convertible to RefCountInterface or not.
-// For classes that are convertible, the type will simply be T.
-// For classes that cannot be converted to RefCountInterface, the type will be
-// FinalRefCountedObject<T>.
-// This is most useful for declaring a scoped_refptr<T> instance for a class
-// that may or may not implement a virtual reference counted interface:
-// * scoped_refptr<Ref<Foo>::Type> my_ptr;
-template <typename T>
-struct Ref {
-  typedef typename std::conditional<
-      webrtc_make_ref_counted_internal::HasAddRefAndRelease<T>::value,
-      T,
-      FinalRefCountedObject<T>>::type Type;
-
-  typedef scoped_refptr<Type> Ptr;
-};
-
 }  // namespace rtc
 
 #endif  // RTC_BASE_REF_COUNTED_OBJECT_H_
diff --git a/rtc_base/ref_counted_object_unittest.cc b/rtc_base/ref_counted_object_unittest.cc
index ab051d4..c06a61e 100644
--- a/rtc_base/ref_counted_object_unittest.cc
+++ b/rtc_base/ref_counted_object_unittest.cc
@@ -151,12 +151,6 @@
   static_assert(std::is_polymorphic<FooItf>::value, "");
   static_assert(!std::is_polymorphic<Foo>::value, "");
 
-  // Check if Ref generates the expected types for Foo and FooItf.
-  static_assert(std::is_base_of<Foo, Ref<Foo>::Type>::value &&
-                    !std::is_same<Foo, Ref<Foo>::Type>::value,
-                "");
-  static_assert(std::is_same<FooItf, Ref<FooItf>::Type>::value, "");
-
   {
     // Test with FooItf, a class that inherits from RefCountInterface.
     // Check that we get a valid FooItf reference counted object.
@@ -164,10 +158,8 @@
     EXPECT_NE(p.get(), nullptr);
     EXPECT_EQ(p->foo_, 5);  // the FooItf ctor just stores 2+3 in foo_.
 
-    // Use a couple of different ways of declaring what should result in the
-    // same type as `p` is of.
-    scoped_refptr<Ref<FooItf>::Type> p2 = p;
-    Ref<FooItf>::Ptr p3 = p;
+    // Declaring what should result in the same type as `p` is of.
+    scoped_refptr<FooItf> p2 = p;
   }
 
   {
@@ -175,8 +167,7 @@
     auto p = make_ref_counted<Foo>(2, 3);
     EXPECT_NE(p.get(), nullptr);
     EXPECT_EQ(p->foo_, 5);
-    scoped_refptr<Ref<Foo>::Type> p2 = p;
-    Ref<Foo>::Ptr p3 = p;
+    scoped_refptr<FinalRefCountedObject<Foo>> p2 = p;
   }
 }