Bug 1360538 - convert SimpleBuffer to use NS_DECL_OWNINGTHREAD; r=hurley

The pattern we're using here has a name, so let's use that instead.
This commit is contained in:
Nathan Froyd 2017-05-02 12:46:36 -04:00
parent 9a7b7937e6
commit 0a713b4ab2
2 changed files with 6 additions and 6 deletions

View File

@ -14,12 +14,11 @@ SimpleBuffer::SimpleBuffer()
: mStatus(NS_OK)
, mAvailable(0)
{
mOwningThread = PR_GetCurrentThread();
}
nsresult SimpleBuffer::Write(char *src, size_t len)
{
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
NS_ASSERT_OWNINGTHREAD(SimpleBuffer);
if (NS_FAILED(mStatus)) {
return mStatus;
}
@ -51,7 +50,7 @@ nsresult SimpleBuffer::Write(char *src, size_t len)
size_t SimpleBuffer::Read(char *dest, size_t maxLen)
{
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
NS_ASSERT_OWNINGTHREAD(SimpleBuffer);
if (NS_FAILED(mStatus)) {
return 0;
}
@ -77,13 +76,13 @@ size_t SimpleBuffer::Read(char *dest, size_t maxLen)
size_t SimpleBuffer::Available()
{
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
NS_ASSERT_OWNINGTHREAD(SimpleBuffer);
return NS_SUCCEEDED(mStatus) ? mAvailable : 0;
}
void SimpleBuffer::Clear()
{
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
NS_ASSERT_OWNINGTHREAD(SimpleBuffer);
SimpleBufferPage *p;
while ((p = mBufferList.popFirst())) {
delete p;

View File

@ -45,7 +45,8 @@ public:
void Clear();
private:
PRThread *mOwningThread;
NS_DECL_OWNINGTHREAD
nsresult mStatus;
AutoCleanLinkedList<SimpleBufferPage> mBufferList;
size_t mAvailable;