Bug 1309794 - Make RefCnt types non-copyable. r=froydnj draft
authorXidorn Quan <me@upsuper.org>
Thu, 13 Oct 2016 16:52:54 +1100
changeset 424773 31ef46add0b2b4b2e62b425d0740199f0e4d4f85
parent 424681 af0e07e418e6ff18cb1384cf02da9c50f353eddd
child 533753 8b4db63f4f4eb02a2a43574b1704c1e638c0ff84
push id32243
push userxquan@mozilla.com
push dateThu, 13 Oct 2016 12:38:00 +0000
reviewersfroydnj
bugs1309794
milestone52.0a1
Bug 1309794 - Make RefCnt types non-copyable. r=froydnj MozReview-Commit-ID: Lx344xrXDZT
xpcom/glue/nsISupportsImpl.h
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -166,16 +166,19 @@ class nsCycleCollectingAutoRefCnt
 public:
   nsCycleCollectingAutoRefCnt() : mRefCntAndFlags(0) {}
 
   explicit nsCycleCollectingAutoRefCnt(uintptr_t aValue)
     : mRefCntAndFlags(aValue << NS_NUMBER_OF_FLAGS_IN_REFCNT)
   {
   }
 
+  nsCycleCollectingAutoRefCnt(const nsCycleCollectingAutoRefCnt&) = delete;
+  void operator=(const nsCycleCollectingAutoRefCnt&) = delete;
+
   MOZ_ALWAYS_INLINE uintptr_t incr(nsISupports* aOwner)
   {
     return incr(aOwner, nullptr);
   }
 
   MOZ_ALWAYS_INLINE uintptr_t incr(void* aOwner,
                                    nsCycleCollectionParticipant* aCp)
   {
@@ -260,16 +263,19 @@ private:
 };
 
 class nsAutoRefCnt
 {
 public:
   nsAutoRefCnt() : mValue(0) {}
   explicit nsAutoRefCnt(nsrefcnt aValue) : mValue(aValue) {}
 
+  nsAutoRefCnt(const nsAutoRefCnt&) = delete;
+  void operator=(const nsAutoRefCnt&) = delete;
+
   // only support prefix increment/decrement
   nsrefcnt operator++() { return ++mValue; }
   nsrefcnt operator--() { return --mValue; }
 
   nsrefcnt operator=(nsrefcnt aValue) { return (mValue = aValue); }
   operator nsrefcnt() const { return mValue; }
   nsrefcnt get() const { return mValue; }
 
@@ -282,16 +288,19 @@ private:
 
 namespace mozilla {
 class ThreadSafeAutoRefCnt
 {
 public:
   ThreadSafeAutoRefCnt() : mValue(0) {}
   explicit ThreadSafeAutoRefCnt(nsrefcnt aValue) : mValue(aValue) {}
 
+  ThreadSafeAutoRefCnt(const ThreadSafeAutoRefCnt&) = delete;
+  void operator=(const ThreadSafeAutoRefCnt&) = delete;
+
   // only support prefix increment/decrement
   MOZ_ALWAYS_INLINE nsrefcnt operator++() { return ++mValue; }
   MOZ_ALWAYS_INLINE nsrefcnt operator--() { return --mValue; }
 
   MOZ_ALWAYS_INLINE nsrefcnt operator=(nsrefcnt aValue)
   {
     return (mValue = aValue);
   }