Bug 1028140 - Privitizing public destructor of DummySocket. r=bwc
authorAnuj Agarwal <anujagarwal464@gmail.com>
Wed, 19 Nov 2014 21:52:42 -0500
changeset 216581 2f954beef9cc1bd03eb961fb20eed3f886a940b1
parent 216580 91f983c5cb46d8aceaea4d50869ceb5a96050b94
child 216582 8aad622123672568fa9c90c2a69a17507892016d
push idunknown
push userunknown
push dateunknown
reviewersbwc
bugs1028140
milestone36.0a1
Bug 1028140 - Privitizing public destructor of DummySocket. r=bwc
media/mtransport/test/buffered_stun_socket_unittest.cpp
--- a/media/mtransport/test/buffered_stun_socket_unittest.cpp
+++ b/media/mtransport/test/buffered_stun_socket_unittest.cpp
@@ -37,28 +37,16 @@ MtransportTestUtils *test_utils;
 static uint8_t kStunMessage[] = {
   0x00, 0x01, 0x00, 0x08, 0x21, 0x12, 0xa4, 0x42,
   0x9b, 0x90, 0xbe, 0x2c, 0xae, 0x1a, 0x0c, 0xa8,
   0xa0, 0xd6, 0x8b, 0x08, 0x80, 0x28, 0x00, 0x04,
   0xdb, 0x35, 0x5f, 0xaa
 };
 static size_t kStunMessageLen = sizeof(kStunMessage);
 
-class DummySocket;
-
-// Temporary whitelist for refcounted class dangerously exposing its destructor.
-// Filed bug 1028140 to address this class.
-namespace mozilla {
-template<>
-struct HasDangerousPublicDestructor<DummySocket>
-{
-  static const bool value = true;
-};
-}
-
 class DummySocket : public NrSocketBase {
  public:
   DummySocket()
       : writable_(UINT_MAX),
         write_buffer_(nullptr),
         readable_(UINT_MAX),
         read_buffer_(nullptr),
         cb_(nullptr),
@@ -202,16 +190,18 @@ class DummySocket : public NrSocketBase 
     }
 
     return self_;
   }
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DummySocket);
 
  private:
+  ~DummySocket() {}
+
   DISALLOW_COPY_ASSIGN(DummySocket);
 
   size_t writable_;  // Amount we allow someone to write.
   ScopedDeletePtr<DataBuffer> write_buffer_;
   size_t readable_;   // Amount we allow someone to read.
   ScopedDeletePtr<DataBuffer> read_buffer_;
 
   NR_async_cb cb_;
@@ -225,17 +215,17 @@ class BufferedStunSocketTest : public ::
       : dummy_(nullptr),
         test_socket_(nullptr) {}
 
   ~BufferedStunSocketTest() {
     nr_socket_destroy(&test_socket_);
   }
 
   void SetUp() {
-    ScopedDeletePtr<DummySocket> dummy(new DummySocket());
+    nsRefPtr<DummySocket> dummy(new DummySocket());
 
     int r = nr_socket_buffered_stun_create(
         dummy->get_nr_socket(),
         kStunMessageLen,
         &test_socket_);
     ASSERT_EQ(0, r);
     dummy_ = dummy.forget();  // Now owned by test_socket_.
 
@@ -246,17 +236,17 @@ class BufferedStunSocketTest : public ::
     r = nr_socket_connect(test_socket_,
                           &remote_addr_);
     ASSERT_EQ(0, r);
   }
 
   nr_socket *socket() { return test_socket_; }
 
  protected:
-  DummySocket *dummy_;
+  nsRefPtr<DummySocket> dummy_;
   nr_socket *test_socket_;
   nr_transport_addr remote_addr_;
 };
 
 
 TEST_F(BufferedStunSocketTest, TestCreate) {
 }