Bug 1366647 - Adopt NS_ASSERT_OWNINGTHREAD for PRThread equality. r=janv

MozReview-Commit-ID: 4j1ifEtrsvD
This commit is contained in:
Bevis Tseng 2017-06-07 13:55:00 +08:00
Родитель 8fb20a5801
Коммит e98d22391d
13 изменённых файлов: 52 добавлений и 281 удалений

Просмотреть файл

@ -83,12 +83,7 @@ namespace indexedDB {
ThreadLocal::ThreadLocal(const nsID& aBackgroundChildLoggingId)
: mLoggingInfo(aBackgroundChildLoggingId, 1, -1, 1)
, mCurrentTransaction(0)
#ifdef DEBUG
, mOwningThread(PR_GetCurrentThread())
#endif
{
MOZ_ASSERT(mOwningThread);
MOZ_COUNT_CTOR(mozilla::dom::indexedDB::ThreadLocal);
// NSID_LENGTH counts the null terminator, SetLength() does not.
@ -103,16 +98,6 @@ ThreadLocal::~ThreadLocal()
MOZ_COUNT_DTOR(mozilla::dom::indexedDB::ThreadLocal);
}
#ifdef DEBUG
void
ThreadLocal::AssertIsOnOwningThread() const
{
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
}
#endif // DEBUG
/*******************************************************************************
* Helpers
******************************************************************************/
@ -1668,9 +1653,6 @@ BackgroundRequestChildBase::AssertIsOnOwningThread() const
BackgroundFactoryChild::BackgroundFactoryChild(IDBFactory* aFactory)
: mFactory(aFactory)
#ifdef DEBUG
, mOwningThread(NS_GetCurrentThread())
#endif
{
AssertIsOnOwningThread();
MOZ_ASSERT(aFactory);
@ -1684,27 +1666,6 @@ BackgroundFactoryChild::~BackgroundFactoryChild()
MOZ_COUNT_DTOR(indexedDB::BackgroundFactoryChild);
}
#ifdef DEBUG
void
BackgroundFactoryChild::AssertIsOnOwningThread() const
{
MOZ_ASSERT(mOwningThread);
bool current;
MOZ_ASSERT(NS_SUCCEEDED(mOwningThread->IsOnCurrentThread(&current)));
MOZ_ASSERT(current);
}
nsIEventTarget*
BackgroundFactoryChild::OwningThread() const
{
MOZ_ASSERT(mOwningThread);
return mOwningThread;
}
#endif // DEBUG
void
BackgroundFactoryChild::SendDeleteMeInternal()
{
@ -2086,6 +2047,16 @@ BackgroundDatabaseChild::~BackgroundDatabaseChild()
MOZ_COUNT_DTOR(indexedDB::BackgroundDatabaseChild);
}
#ifdef DEBUG
void
BackgroundDatabaseChild::AssertIsOnOwningThread() const
{
static_cast<BackgroundFactoryChild*>(Manager())->AssertIsOnOwningThread();
}
#endif // DEBUG
void
BackgroundDatabaseChild::SendDeleteMeInternal()
{
@ -3724,11 +3695,6 @@ BackgroundCursorChild::BackgroundCursorChild(IDBRequest* aRequest,
MOZ_ASSERT(mTransaction);
MOZ_COUNT_CTOR(indexedDB::BackgroundCursorChild);
#ifdef DEBUG
mOwningThread = PR_GetCurrentThread();
MOZ_ASSERT(mOwningThread);
#endif
}
BackgroundCursorChild::BackgroundCursorChild(IDBRequest* aRequest,
@ -3747,11 +3713,6 @@ BackgroundCursorChild::BackgroundCursorChild(IDBRequest* aRequest,
MOZ_ASSERT(mTransaction);
MOZ_COUNT_CTOR(indexedDB::BackgroundCursorChild);
#ifdef DEBUG
mOwningThread = PR_GetCurrentThread();
MOZ_ASSERT(mOwningThread);
#endif
}
BackgroundCursorChild::~BackgroundCursorChild()
@ -3759,16 +3720,6 @@ BackgroundCursorChild::~BackgroundCursorChild()
MOZ_COUNT_DTOR(indexedDB::BackgroundCursorChild);
}
#ifdef DEBUG
void
BackgroundCursorChild::AssertIsOnOwningThread() const
{
MOZ_ASSERT(mOwningThread == PR_GetCurrentThread());
}
#endif // DEBUG
void
BackgroundCursorChild::SendContinueInternal(const CursorRequestParams& aParams)
{
@ -4394,9 +4345,6 @@ BackgroundFileRequestChild::RecvProgress(const uint64_t& aProgress,
BackgroundUtilsChild::BackgroundUtilsChild(IndexedDatabaseManager* aManager)
: mManager(aManager)
#ifdef DEBUG
, mOwningThread(NS_GetCurrentThread())
#endif
{
AssertIsOnOwningThread();
MOZ_ASSERT(aManager);
@ -4409,20 +4357,6 @@ BackgroundUtilsChild::~BackgroundUtilsChild()
MOZ_COUNT_DTOR(indexedDB::BackgroundUtilsChild);
}
#ifdef DEBUG
void
BackgroundUtilsChild::AssertIsOnOwningThread() const
{
MOZ_ASSERT(mOwningThread);
bool current;
MOZ_ASSERT(NS_SUCCEEDED(mOwningThread->IsOnCurrentThread(&current)));
MOZ_ASSERT(current);
}
#endif // DEBUG
void
BackgroundUtilsChild::SendDeleteMeInternal()
{

Просмотреть файл

@ -29,7 +29,6 @@
class nsIEventTarget;
struct nsID;
struct PRThread;
namespace JS {
struct WasmModule;
@ -70,18 +69,14 @@ class ThreadLocal
IDBTransaction* mCurrentTransaction;
nsCString mLoggingIdString;
#ifdef DEBUG
PRThread* mOwningThread;
#endif
NS_DECL_OWNINGTHREAD
public:
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(ThreadLocal);
}
const LoggingInfo&
GetLoggingInfo() const
@ -163,22 +158,14 @@ class BackgroundFactoryChild final
IDBFactory* mFactory;
#ifdef DEBUG
nsCOMPtr<nsIEventTarget> mOwningThread;
#endif
NS_DECL_OWNINGTHREAD
public:
#ifdef DEBUG
void
AssertIsOnOwningThread() const;
nsIEventTarget*
OwningThread() const;
#else
void
AssertIsOnOwningThread() const
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(BackgroundFactoryChild);
}
IDBFactory*
GetDOMObject() const
@ -321,16 +308,10 @@ class BackgroundDatabaseChild final
public:
void
AssertIsOnOwningThread() const
{
static_cast<BackgroundFactoryChild*>(Manager())->AssertIsOnOwningThread();
}
#ifdef DEBUG
nsIEventTarget*
OwningThread() const
{
return static_cast<BackgroundFactoryChild*>(Manager())->OwningThread();
}
;
#else
{ }
#endif
const DatabaseSpec*
@ -781,9 +762,7 @@ class BackgroundCursorChild final
Direction mDirection;
#ifdef DEBUG
PRThread* mOwningThread;
#endif
NS_DECL_OWNINGTHREAD
public:
BackgroundCursorChild(IDBRequest* aRequest,
@ -796,11 +775,9 @@ public:
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(BackgroundCursorChild);
}
void
SendContinueInternal(const CursorRequestParams& aParams);
@ -997,18 +974,14 @@ class BackgroundUtilsChild final
IndexedDatabaseManager* mManager;
#ifdef DEBUG
nsCOMPtr<nsIEventTarget> mOwningThread;
#endif
NS_DECL_OWNINGTHREAD
public:
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(BackgroundUtilsChild);
}
private:
// Only created by IndexedDatabaseManager.

Просмотреть файл

@ -5129,15 +5129,15 @@ private:
#ifdef DEBUG
uint32_t mDEBUGSavepointCount;
PRThread* mDEBUGThread;
#endif
NS_DECL_OWNINGTHREAD
public:
void
AssertIsOnConnectionThread() const
{
MOZ_ASSERT(mDEBUGThread);
MOZ_ASSERT(PR_GetCurrentThread() == mDEBUGThread);
NS_ASSERT_OWNINGTHREAD(DatabaseConnection);
}
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DatabaseConnection)
@ -5470,20 +5470,14 @@ private:
bool mShutdownRequested;
bool mShutdownComplete;
#ifdef DEBUG
PRThread* mDEBUGOwningThread;
#endif
public:
ConnectionPool();
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(ConnectionPool);
}
nsresult
GetOrCreateConnection(const Database* aDatabase,
@ -5663,7 +5657,7 @@ struct ConnectionPool::DatabaseInfo final
AssertIsOnConnectionThread() const
{
MOZ_ASSERT(mDEBUGConnectionThread);
MOZ_ASSERT(PR_GetCurrentThread() == mDEBUGConnectionThread);
MOZ_ASSERT(GetCurrentPhysicalThread() == mDEBUGConnectionThread);
}
uint64_t
@ -10646,7 +10640,6 @@ DatabaseConnection::DatabaseConnection(
, mInWriteTransaction(false)
#ifdef DEBUG
, mDEBUGSavepointCount(0)
, mDEBUGThread(PR_GetCurrentThread())
#endif
{
AssertIsOnConnectionThread();
@ -12126,9 +12119,6 @@ ConnectionPool::ConnectionPool()
, mTotalThreadCount(0)
, mShutdownRequested(false)
, mShutdownComplete(false)
#ifdef DEBUG
, mDEBUGOwningThread(PR_GetCurrentThread())
#endif
{
AssertIsOnOwningThread();
AssertIsOnBackgroundThread();
@ -12151,17 +12141,6 @@ ConnectionPool::~ConnectionPool()
MOZ_ASSERT(mShutdownComplete);
}
#ifdef DEBUG
void
ConnectionPool::AssertIsOnOwningThread() const
{
MOZ_ASSERT(mDEBUGOwningThread);
MOZ_ASSERT(PR_GetCurrentThread() == mDEBUGOwningThread);
}
#endif // DEBUG
// static
void
ConnectionPool::IdleTimerCallback(nsITimer* aTimer, void* aClosure)
@ -12278,7 +12257,7 @@ ConnectionPool::GetOrCreateConnection(const Database* aDatabase,
NS_ConvertUTF16toUTF8(aDatabase->FilePath()).get()));
#ifdef DEBUG
dbInfo->mDEBUGConnectionThread = PR_GetCurrentThread();
dbInfo->mDEBUGConnectionThread = GetCurrentPhysicalThread();
#endif
}

Просмотреть файл

@ -251,13 +251,6 @@ IDBDatabase::AssertIsOnOwningThread() const
mFactory->AssertIsOnOwningThread();
}
PRThread*
IDBDatabase::OwningThread() const
{
MOZ_ASSERT(mFactory);
return mFactory->OwningThread();
}
#endif // DEBUG
nsIEventTarget*

Просмотреть файл

@ -94,15 +94,11 @@ public:
indexedDB::BackgroundDatabaseChild* aActor,
DatabaseSpec* aSpec);
#ifdef DEBUG
void
AssertIsOnOwningThread() const;
PRThread*
OwningThread() const;
#else
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif

Просмотреть файл

@ -101,9 +101,6 @@ IDBFactory::IDBFactory()
, mBackgroundActorFailed(false)
, mPrivateBrowsingMode(false)
{
#ifdef DEBUG
mOwningThread = PR_GetCurrentThread();
#endif
AssertIsOnOwningThread();
}
@ -420,24 +417,6 @@ IDBFactory::AllowedForPrincipal(nsIPrincipal* aPrincipal,
return true;
}
#ifdef DEBUG
void
IDBFactory::AssertIsOnOwningThread() const
{
MOZ_ASSERT(mOwningThread);
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
}
PRThread*
IDBFactory::OwningThread() const
{
MOZ_ASSERT(mOwningThread);
return mOwningThread;
}
#endif // DEBUG
bool
IDBFactory::IsChrome() const
{

Просмотреть файл

@ -21,7 +21,6 @@
class nsIEventTarget;
class nsIPrincipal;
class nsPIDOMWindowInner;
struct PRThread;
namespace mozilla {
@ -79,10 +78,6 @@ class IDBFactory final
// NS_GetCurrentThread() off main thread.
nsCOMPtr<nsIEventTarget> mEventTarget;
#ifdef DEBUG
PRThread* mOwningThread;
#endif
uint64_t mInnerWindowID;
bool mBackgroundActorFailed;
@ -112,17 +107,11 @@ public:
AllowedForPrincipal(nsIPrincipal* aPrincipal,
bool* aIsSystemPrincipal = nullptr);
#ifdef DEBUG
void
AssertIsOnOwningThread() const;
PRThread*
OwningThread() const;
#else
void
AssertIsOnOwningThread() const
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(IDBFactory);
}
nsIEventTarget*
EventTarget() const

Просмотреть файл

@ -28,9 +28,6 @@ IDBFileRequest::IDBFileRequest(IDBFileHandle* aFileHandle,
bool aWrapAsDOMRequest)
: DOMRequest(aFileHandle->GetOwner())
, mFileHandle(aFileHandle)
#ifdef DEBUG
, mOwningThread(PR_GetCurrentThread())
#endif
, mWrapAsDOMRequest(aWrapAsDOMRequest)
, mHasEncoding(false)
{
@ -43,17 +40,6 @@ IDBFileRequest::~IDBFileRequest()
AssertIsOnOwningThread();
}
#ifdef DEBUG
void
IDBFileRequest::AssertIsOnOwningThread() const
{
MOZ_ASSERT(mOwningThread);
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
}
#endif // DEBUG
// static
already_AddRefed<IDBFileRequest>
IDBFileRequest::Create(IDBFileHandle* aFileHandle,

Просмотреть файл

@ -14,7 +14,6 @@
#include "nsString.h"
template <class> struct already_AddRefed;
struct PRThread;
namespace mozilla {
@ -29,10 +28,6 @@ class IDBFileRequest final
{
RefPtr<IDBFileHandle> mFileHandle;
#ifdef DEBUG
PRThread* mOwningThread;
#endif
nsString mEncoding;
bool mWrapAsDOMRequest;
@ -89,11 +84,9 @@ public:
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(IDBFileRequest);
}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBFileRequest, DOMRequest)

Просмотреть файл

@ -53,9 +53,6 @@ IDBKeyRange::IDBKeyRange(nsISupports* aGlobal,
, mHaveCachedUpperVal(false)
, mRooted(false)
{
#ifdef DEBUG
mOwningThread = PR_GetCurrentThread();
#endif
AssertIsOnOwningThread();
}
@ -70,9 +67,6 @@ IDBLocaleAwareKeyRange::IDBLocaleAwareKeyRange(nsISupports* aGlobal,
bool aIsOnly)
: IDBKeyRange(aGlobal, aLowerOpen, aUpperOpen, aIsOnly)
{
#ifdef DEBUG
mOwningThread = PR_GetCurrentThread();
#endif
AssertIsOnOwningThread();
}
@ -81,17 +75,6 @@ IDBLocaleAwareKeyRange::~IDBLocaleAwareKeyRange()
DropJSObjects();
}
#ifdef DEBUG
void
IDBKeyRange::AssertIsOnOwningThread() const
{
MOZ_ASSERT(mOwningThread);
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
}
#endif // DEBUG
// static
nsresult
IDBKeyRange::FromJSVal(JSContext* aCx,

Просмотреть файл

@ -18,7 +18,6 @@
#include "nsString.h"
class mozIStorageStatement;
struct PRThread;
namespace mozilla {
@ -49,10 +48,6 @@ protected:
bool mHaveCachedUpperVal : 1;
bool mRooted : 1;
#ifdef DEBUG
PRThread* mOwningThread;
#endif
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBKeyRange)
@ -93,11 +88,9 @@ public:
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(IDBKeyRange);
}
void
ToSerialized(indexedDB::SerializedKeyRange& aKeyRange) const;

Просмотреть файл

@ -51,9 +51,6 @@ NS_DEFINE_IID(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
IDBRequest::IDBRequest(IDBDatabase* aDatabase)
: IDBWrapperCache(aDatabase)
#ifdef DEBUG
, mOwningThread(nullptr)
#endif
, mLoggingSerialNumber(0)
, mLineNo(0)
, mColumn(0)
@ -67,9 +64,6 @@ IDBRequest::IDBRequest(IDBDatabase* aDatabase)
IDBRequest::IDBRequest(nsPIDOMWindowInner* aOwner)
: IDBWrapperCache(aOwner)
#ifdef DEBUG
, mOwningThread(nullptr)
#endif
, mLoggingSerialNumber(0)
, mLineNo(0)
, mColumn(0)
@ -83,23 +77,9 @@ IDBRequest::~IDBRequest()
AssertIsOnOwningThread();
}
#ifdef DEBUG
void
IDBRequest::AssertIsOnOwningThread() const
{
MOZ_ASSERT(mOwningThread);
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
}
#endif // DEBUG
void
IDBRequest::InitMembers()
{
#ifdef DEBUG
mOwningThread = PR_GetCurrentThread();
#endif
AssertIsOnOwningThread();
mResultVal.setUndefined();

Просмотреть файл

@ -19,7 +19,6 @@
{0xe68901e5, 0x1d50, 0x4ee9, {0xaf, 0x49, 0x90, 0x99, 0x4a, 0xff, 0xc8, 0x39}}
class nsPIDOMWindowInner;
struct PRThread;
namespace mozilla {
@ -49,10 +48,6 @@ protected:
RefPtr<IDBTransaction> mTransaction;
#ifdef DEBUG
PRThread* mOwningThread;
#endif
JS::Heap<JS::Value> mResultVal;
RefPtr<DOMError> mError;
@ -186,11 +181,9 @@ public:
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif
{
NS_ASSERT_OWNINGTHREAD(IDBRequest);
}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(IDBRequest,