Bug 1365534 - Remove unneeded IsMainThread assertions - r?cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 18 May 2017 16:17:08 +1200
changeset 580041 6587d2987558d5fb6e86df6d6e2d01cb18c21b10
parent 580040 baf05f61bc14fdf45511bc1165ce76daa08c5c0f
child 580042 a7a9122cbcb902f68ff7763866c05007d475a2b7
push id59433
push usergsquelart@mozilla.com
push dateThu, 18 May 2017 04:39:26 +0000
reviewerscpearce
bugs1365534
milestone55.0a1
Bug 1365534 - Remove unneeded IsMainThread assertions - r?cpearce SetCacheFile, Init, Close, and MoveBlock all had NS_IsMainThread() assertions. However they all use Monitor's to access member data, so they should be thread- safe. (Upcoming patches will actually start using some of these functions from non- main-threads.) MozReview-Commit-ID: E1auNEXuoF9
dom/media/FileBlockCache.cpp
--- a/dom/media/FileBlockCache.cpp
+++ b/dom/media/FileBlockCache.cpp
@@ -18,17 +18,16 @@ namespace mozilla {
 #undef LOG
 LazyLogModule gFileBlockCacheLog("FileBlockCache");
 #define LOG(x, ...) MOZ_LOG(gFileBlockCacheLog, LogLevel::Debug, \
   ("%p " x, this, ##__VA_ARGS__))
 
 void
 FileBlockCache::SetCacheFile(PRFileDesc* aFD)
 {
-  MOZ_ASSERT(NS_IsMainThread());
   LOG("SetFD(aFD=%p) mIsOpen=%d", aFD, mIsOpen);
 
   if (!aFD) {
     // Failed to get a temporary file. Shutdown.
     Close();
     return;
   }
   {
@@ -51,18 +50,16 @@ FileBlockCache::SetCacheFile(PRFileDesc*
   }
 }
 
 nsresult
 FileBlockCache::Init()
 {
   LOG("Init()");
 
-  MOZ_ASSERT(NS_IsMainThread());
-
   MonitorAutoLock mon(mDataMonitor);
   nsresult rv = NS_NewNamedThread("FileBlockCache",
                                   getter_AddRefs(mThread),
                                   nullptr,
                                   SharedThreadPool::kStackSize);
   if (NS_FAILED(rv)) {
     return rv;
   }
@@ -114,18 +111,16 @@ FileBlockCache::~FileBlockCache()
     }
   }
 }
 
 void FileBlockCache::Close()
 {
   LOG("Close()");
 
-  NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
-
   MonitorAutoLock mon(mDataMonitor);
   if (!mIsOpen) {
     return;
   }
   mIsOpen = false;
   if (!mThread) {
     return;
   }
@@ -383,17 +378,16 @@ nsresult FileBlockCache::Read(int64_t aO
     bytesToRead -= bytesRead;
   }
   *aBytes = aLength - bytesToRead;
   return NS_OK;
 }
 
 nsresult FileBlockCache::MoveBlock(int32_t aSourceBlockIndex, int32_t aDestBlockIndex)
 {
-  NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   MonitorAutoLock mon(mDataMonitor);
 
   if (!mIsOpen)
     return NS_ERROR_FAILURE;
 
   mBlockChanges.EnsureLengthAtLeast(std::max(aSourceBlockIndex, aDestBlockIndex) + 1);
 
   // The source block's contents may be the destination of another pending