Simplify reference counting implementation of PendingTaskSafetyFlag.

On a 32bit system, this reduces the allocation size of the flag
down from 12 bytes to 8, and removes the need for a vtable (the extra
4 bytes are the vtable pointer).

The downside is that this change makes the binary layout of the
flag, less compatible with RefCountedObject<> based reference counting
objects and thus we don't immediately get the benefits of identical
COMDAT folding and subsequently there's a slight binary size increase.
With wider use, the binary size benefits will come.

Bug: none
Change-Id: I04129771790a3258d6accaf0ab1258b7a798a55e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215681
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33793}
diff --git a/pc/connection_context.h b/pc/connection_context.h
index 0c69c17..8fad13c 100644
--- a/pc/connection_context.h
+++ b/pc/connection_context.h
@@ -17,6 +17,7 @@
 #include "api/call/call_factory_interface.h"
 #include "api/media_stream_interface.h"
 #include "api/peer_connection_interface.h"
+#include "api/ref_counted_base.h"
 #include "api/scoped_refptr.h"
 #include "api/sequence_checker.h"
 #include "api/transport/sctp_transport_factory_interface.h"
@@ -27,7 +28,6 @@
 #include "rtc_base/checks.h"
 #include "rtc_base/network.h"
 #include "rtc_base/network_monitor_factory.h"
-#include "rtc_base/ref_count.h"
 #include "rtc_base/rtc_certificate_generator.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/thread_annotations.h"
@@ -47,7 +47,8 @@
 // interferes with the operation of other PeerConnections.
 //
 // This class must be created and destroyed on the signaling thread.
-class ConnectionContext : public rtc::RefCountInterface {
+class ConnectionContext final
+    : public rtc::RefCountedNonVirtual<ConnectionContext> {
  public:
   // Creates a ConnectionContext. May return null if initialization fails.
   // The Dependencies class allows simple management of all new dependencies
@@ -92,7 +93,8 @@
  protected:
   explicit ConnectionContext(PeerConnectionFactoryDependencies* dependencies);
 
-  virtual ~ConnectionContext();
+  friend class rtc::RefCountedNonVirtual<ConnectionContext>;
+  ~ConnectionContext();
 
  private:
   // The following three variables are used to communicate between the