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
Родитель c7cc4bc5c8
Коммит c60e0ca4b5
2 изменённых файлов: 19 добавлений и 0 удалений

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

@ -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);

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

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