Exemplo n.º 1
0
void
nsFileInputStream::Serialize(InputStreamParams& aParams,
                             FileDescriptorArray& aFileDescriptors)
{
    FileInputStreamParams params;

    if (mFD) {
        FileHandleType fd = FileHandleType(PR_FileDesc2NativeHandle(mFD));
        NS_ASSERTION(fd, "This should never be null!");

        DebugOnly<FileDescriptor*> dbgFD = aFileDescriptors.AppendElement(fd);
        NS_ASSERTION(dbgFD->IsValid(), "Sending an invalid file descriptor!");

        params.fileDescriptorIndex() = aFileDescriptors.Length() - 1;

        Close();
    } else {
        NS_WARNING("This file has not been opened (or could not be opened). "
                   "Sending an invalid file descriptor to the other process!");

        params.fileDescriptorIndex() = UINT32_MAX;
    }

    int32_t behaviorFlags = mBehaviorFlags;

    // The receiving process (or thread) is going to have an open file
    // descriptor automatically so transferring this flag is meaningless.
    behaviorFlags &= ~nsIFileInputStream::DEFER_OPEN;

    params.behaviorFlags() = behaviorFlags;
    params.ioFlags() = mIOFlags;

    aParams = params;
}
Exemplo n.º 2
0
void
nsFileInputStream::Serialize(InputStreamParams& aParams)
{
    FileInputStreamParams params;

    if (mFD) {
        FileHandleType fd = FileHandleType(PR_FileDesc2NativeHandle(mFD));
        NS_ASSERTION(fd, "This should never be null!");

        params.file() = FileDescriptor(fd);
        NS_ASSERTION(params.file().IsValid(),
                     "Sending an invalid file descriptor!");
    } else {
        NS_WARNING("This file has not been opened (or could not be opened). "
                   "Sending an invalid file descriptor to the other process!");
    }

    int32_t behaviorFlags = mBehaviorFlags;

    // The other process shouldn't close when it reads the end because it will
    // not be able to reopen the file later.
    behaviorFlags &= ~nsIFileInputStream::CLOSE_ON_EOF;

    // The other process will not be able to reopen the file so transferring
    // this flag is meaningless.
    behaviorFlags &= ~nsIFileInputStream::REOPEN_ON_REWIND;

    // The other process is going to have an open file descriptor automatically
    // so transferring this flag is meaningless.
    behaviorFlags &= ~nsIFileInputStream::DEFER_OPEN;

    params.behaviorFlags() = behaviorFlags;
    params.ioFlags() = mIOFlags;

    aParams = params;
}