Bug 1221547 - part 1 - enable UnixSocketRawData to take ownership of a passed-in-buffer; r=tzimmerman

This commit is contained in:
Nathan Froyd 2015-11-02 16:13:10 -05:00
parent 9d28d00120
commit 2dbc1d274a
2 changed files with 19 additions and 0 deletions

View File

@ -125,6 +125,15 @@ UnixSocketRawData::UnixSocketRawData(const void* aData, size_t aSize)
0, aSize, aSize);
}
UnixSocketRawData::UnixSocketRawData(UniquePtr<uint8_t[]> aData, size_t aSize)
{
MOZ_ASSERT(aData || !aSize);
MOZ_COUNT_CTOR_INHERITED(UnixSocketRawData, UnixSocketIOBuffer);
ResetBuffer(aData.release(), 0, aSize, aSize);
}
UnixSocketRawData::UnixSocketRawData(size_t aSize)
{
MOZ_COUNT_CTOR_INHERITED(UnixSocketRawData, UnixSocketIOBuffer);

View File

@ -11,6 +11,7 @@
#include "base/message_loop.h"
#include "nsAutoPtr.h"
#include "mozilla/UniquePtr.h"
namespace mozilla {
namespace ipc {
@ -230,6 +231,15 @@ public:
*/
UnixSocketRawData(const void* aData, size_t aSize);
/**
* This constructor takes ownership of the data in aData. The
* data is assumed to be aSize bytes in length.
*
* @param aData The buffer to take ownership of.
* @param aSize The number of bytes in |aData|.
*/
UnixSocketRawData(UniquePtr<uint8_t[]> aData, size_t aSize);
/**
* This constructor reserves aSize bytes of space. Currently
* it's only possible to fill this buffer by calling |Receive|.