mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1440511 - Part 4: Add an IPDLParamTraits implementation for FileDescriptor, r=froydnj
MozReview-Commit-ID: R1CiT5IvAi
This commit is contained in:
parent
36059eb187
commit
896117c019
@ -29,7 +29,8 @@
|
||||
|
||||
#endif // XP_WIN
|
||||
|
||||
using mozilla::ipc::FileDescriptor;
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
FileDescriptor::FileDescriptor()
|
||||
: mHandle(INVALID_HANDLE)
|
||||
@ -224,3 +225,35 @@ FileDescriptor::PlatformHandleDeleter::operator()(FileDescriptor::PlatformHandle
|
||||
{
|
||||
FileDescriptor::Close(aHelper);
|
||||
}
|
||||
|
||||
void
|
||||
IPDLParamTraits<FileDescriptor>::Write(IPC::Message* aMsg,
|
||||
IProtocol* aActor,
|
||||
const FileDescriptor& aParam)
|
||||
{
|
||||
FileDescriptor::PickleType pfd =
|
||||
aParam.ShareTo(FileDescriptor::IPDLPrivate(), aActor->OtherPid());
|
||||
WriteIPDLParam(aMsg, aActor, pfd);
|
||||
}
|
||||
|
||||
bool
|
||||
IPDLParamTraits<FileDescriptor>::Read(const IPC::Message* aMsg,
|
||||
PickleIterator* aIter,
|
||||
IProtocol* aActor,
|
||||
FileDescriptor* aResult)
|
||||
{
|
||||
FileDescriptor::PickleType pfd;
|
||||
if (!ReadIPDLParam(aMsg, aIter, aActor, &pfd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*aResult = FileDescriptor(FileDescriptor::IPDLPrivate(), pfd);
|
||||
if (!aResult->IsValid()) {
|
||||
printf_stderr("IPDL protocol Error: [%s] Received an invalid file descriptor\n",
|
||||
aActor->ProtocolName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "base/process.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/ipc/IPDLParamTraits.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Need the HANDLE typedef.
|
||||
@ -135,6 +137,14 @@ private:
|
||||
PlatformHandleType mHandle;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct IPDLParamTraits<FileDescriptor> {
|
||||
typedef FileDescriptor paramType;
|
||||
|
||||
static void Write(IPC::Message* aMsg, IProtocol* aActor, const paramType& aParam);
|
||||
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor, paramType* aResult);
|
||||
};
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user