Bug 998097 - Make DeviceStorageUsedSpaceCache use a thread-safe ref count. r=ehsan
authorDave Hylands <dhylands@mozilla.com>
Tue, 22 Apr 2014 18:31:04 -0700
changeset 180135 395976994a92803727dbfc6f44677bd5ab66aef0
parent 180134 ece426b71e9fb23b259fcefebf75fe8213e4df1d
child 180136 392a5456fbfe03f9bb645a98bdc6fd5ef9910a68
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersehsan
bugs998097
milestone31.0a1
Bug 998097 - Make DeviceStorageUsedSpaceCache use a thread-safe ref count. r=ehsan DeviceStorageUsedSpaceCache uses the LazyIdleThread, and the underlying OS thread can change from time to time, which in turn triggers a not thread safe assert in the reference counting code.
dom/devicestorage/nsDeviceStorage.h
--- a/dom/devicestorage/nsDeviceStorage.h
+++ b/dom/devicestorage/nsDeviceStorage.h
@@ -116,17 +116,20 @@ public:
                     uint64_t aPictureSize, uint64_t aVideosSize,
                     uint64_t aMusicSize, uint64_t aTotalSize);
 
 private:
   friend class InvalidateRunnable;
 
   struct CacheEntry
   {
-    NS_INLINE_DECL_REFCOUNTING(DeviceStorageUsedSpaceCache::CacheEntry)
+    // Technically, this doesn't need to be threadsafe, but the implementation
+    // of the non-thread safe one causes ASSERTS due to the underlying thread
+    // associated with a LazyIdleThread changing from time to time.
+    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DeviceStorageUsedSpaceCache::CacheEntry)
 
     bool mDirty;
     nsString mStorageName;
     int64_t  mFreeBytes;
     uint64_t mPicturesUsedSize;
     uint64_t mVideosUsedSize;
     uint64_t mMusicUsedSize;
     uint64_t mTotalUsedSize;