gecko-dev/xpcom/io/FileDescriptorFile.h
Haik Aftandilian c3cf53a7ef Bug 1334550 - Part 1 - Proxy moz-extension protocol requests to the parent process; r=jimm,mayhemer
Changes ExtensionProtocolHandler to use remote streams for
moz-extension loads of file and JAR URI's to allow for
filesystem read-access sandboxing.

Adds messaging to PNecko to allow child processes to
request an input stream or file descriptor for moz-extension
URI's.

Add ExtensionProtocolHandler singleton so that NeckoParent can
call methods directly and ExtensionProtocolHandler::NewFD
can use a new member variable |mFileOpenerThread| to open files.

Adds FileDescriptorFile, a limited implementation of nsIFile
that wraps a file descriptor, to be sideloaded into
nsJARChannels so that extension JAR files can be read
using a file descriptor without accessing the filesystem
directly.

MozReview-Commit-ID: 1pcnIpjz2yR

--HG--
extra : rebase_source : 9d7334778fc81837b11b98d4e32603f7e5eb3a27
2017-06-23 17:10:54 -07:00

53 lines
1.5 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _FileDescriptorFile_h
#define _FileDescriptorFile_h
#include "mozilla/Attributes.h"
#include "mozilla/ipc/FileDescriptor.h"
#include "nsIFile.h"
#include "nsIFileURL.h"
#include "nsIURI.h"
#include "private/pprio.h"
namespace mozilla {
namespace net {
/**
* A limited implementation of nsIFile that wraps a FileDescriptor object
* allowing the file to be read from. Added to allow a child process to use
* an nsIFile object for a file it does not have access to on the filesystem
* but has been provided a FileDescriptor for from the parent. Many nsIFile
* methods are not implemented and this is not intended to be a general
* purpose file implementation.
*/
class FileDescriptorFile final : public nsIFile
{
typedef mozilla::ipc::FileDescriptor FileDescriptor;
public:
FileDescriptorFile(const FileDescriptor& aFD, nsIFile* aFile);
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIFILE
private:
~FileDescriptorFile()
{}
FileDescriptorFile(const FileDescriptorFile& other);
// regular nsIFile object, that we forward most calls to.
nsCOMPtr<nsIFile> mFile;
FileDescriptor mFD;
};
} // namespace net
} // namespace mozilla
#endif // _FileDescriptorFile_h