Bug 1046109: Add |SocketIOBase|, r=kyle

|SocketIOBase| is a base class for Socket I/O classes. It's not a
requirement, but provides a number of helpful methods for common
I/O operations on the I/O thread.
This commit is contained in:
Thomas Zimmermann
2014-07-31 09:29:19 +02:00
parent 6b1f295c66
commit 244cf70323
3 changed files with 166 additions and 94 deletions

View File

@@ -122,5 +122,34 @@ SocketConsumerBase::SetConnectionStatus(
mConnectionStatus = aConnectionStatus;
}
//
// SocketIOBase
//
SocketIOBase::~SocketIOBase()
{ }
void
SocketIOBase::EnqueueData(UnixSocketRawData* aData)
{
if (!aData->mSize) {
delete aData; // delete empty data immediately
return;
}
mOutgoingQ.AppendElement(aData);
}
bool
SocketIOBase::HasPendingData() const
{
return !mOutgoingQ.IsEmpty();
}
SocketIOBase::SocketIOBase(size_t aMaxReadSize)
: mMaxReadSize(aMaxReadSize)
{
MOZ_ASSERT(mMaxReadSize);
}
}
}