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
--- 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