PathUtils::CreateUniquePath was doing main thread IO, so we're moving it to
IOUtils to use its event loop to do the IO.
Additionally, we're adding IOUtils::CreateUniqueDirectory which is the same as
::CreateUniqueFile, but for directories.
Differential Revision: https://phabricator.services.mozilla.com/D133841
PathUtils::CreateUniquePath was doing main thread IO, so we're moving it to
IOUtils to use its event loop to do the IO.
Additionally, we're adding IOUtils::CreateUniqueDirectory which is the same as
::CreateUniqueFile, but for directories.
Differential Revision: https://phabricator.services.mozilla.com/D133841
PathUtils::CreateUniquePath was doing main thread IO, so we're moving it to
IOUtils to use its event loop to do the IO.
Additionally, we're adding IOUtils::CreateUniqueDirectory which is the same as
::CreateUniqueFile, but for directories.
Differential Revision: https://phabricator.services.mozilla.com/D133841
Previously, if you attempted to read a file greater than INT32_MAX in size, we
would either fail to read the file (on release) or crash (on debug). This is
due to the implementation of _PR_MD_READ accepting an int32_t of bytes to read
instead of a uint32_t, which nsFileStream::Read accepts and passes on.
Differential Revision: https://phabricator.services.mozilla.com/D131161
Presently, if IOUtils encounters an error that it does not know how to map to
a DOMException (via RejectJSPromise), it will only include the nsresult error
code if the IOError was constructed without a message. This hides the root
cause of errors.
Now we always include the error code when rejecting with an UnknownError.
Differential Revision: https://phabricator.services.mozilla.com/D131160
CLOSED TREE
Backed out changeset 55165cf4b7bb (bug 1736175)
Backed out changeset 492f5ca3b592 (bug 1723082)
Backed out changeset ce199e98a0c5 (bug 1741247)
Previously, if you attempted to read a file greater than INT32_MAX in size, we
would either fail to read the file (on release) or crash (on debug). This is
due to the implementation of _PR_MD_READ accepting an int32_t of bytes to read
instead of a uint32_t, which nsFileStream::Read accepts and passes on.
Differential Revision: https://phabricator.services.mozilla.com/D131161
Presently, if IOUtils encounters an error that it does not know how to map to
a DOMException (via RejectJSPromise), it will only include the nsresult error
code if the IOError was constructed without a message. This hides the root
cause of errors.
Now we always include the error code when rejecting with an UnknownError.
Differential Revision: https://phabricator.services.mozilla.com/D131160
This exposes synchronous file reading to workers. It's intended to be used
by profiler symbolication.
The API only supports reading into an existing Uint8Array. This avoids
creating garbage, and minimizes copies.
It also keeps the file open so that it doesn't need to be reopened for
each read.
The implementation uses nsFileStream.
I first tried an implementation which used mmap + memcpy rather than read,
but it didn't work for files larger than 2GiB due to limitations in NSPR's
mmap support, and the profiler needs to read >2GiB files.
Specifically, the profiler sometimes needs to read
/System/Library/dyld/dyld_shared_cache_arm64e , which is 2.2GiB big on
macOS 11.5.
Differential Revision: https://phabricator.services.mozilla.com/D124207
Win32 errors ERROR_DEVICE_HARDWARE_ERROR, ERROR_DEVICE_NOT_CONNECTED, ERROR_DISK_FULL need a mapping.
NS_ERROR_FILE_DISK_FULL is duplicate to NS_ERROR_FILE_NO_DEVICE_SPACE
Drive by: RejectJSPromise lacked some NS_ERROR_* mappings
Differential Revision: https://phabricator.services.mozilla.com/D113974
IOUtils.write{,UTF8,JSON} now support multiple writing modes:
* overwrite, where the contents of the file will be overwritten and a new file
will be created if it does not exist (the old default),
* create, where the file cannot exist and it will be created during the
operation; and
* append, where the file will be appended to.
(Append is not currently supported for writeJSON because appending JSON blobs
together doesn't make sense most of the time.)
Differential Revision: https://phabricator.services.mozilla.com/D113450
IOUtils now provides a shutdown client for clients to register IO jobs with
that need to run before shutdown finishes. This allows IO jobs to run during
the profileBeforeChange phase.
IOUtils' event queuing has been refactored into a singleton EventQueue class,
which is responsible for running tasks and setting up shutdown blockers. It is
now guarded behind a StaticDataMutex so that is more explicitly clear what is
and is not re-entrant. (The atomic sShutdownFinished cannot be placed behind
the mutex because we need to keep track of that state even when we do not have
an EventQueue.)
Differential Revision: https://phabricator.services.mozilla.com/D103973
IOUtils now provides a shutdown client for clients to register IO jobs with
that need to run before shutdown finishes. This allows IO jobs to run during
the profileBeforeChange phase.
IOUtils' event queuing has been refactored into a singleton EventQueue class,
which is responsible for running tasks and setting up shutdown blockers. It is
now guarded behind a StaticDataMutex so that is more explicitly clear what is
and is not re-entrant. (The atomic sShutdownFinished cannot be placed behind
the mutex because we need to keep track of that state even when we do not have
an EventQueue.)
Differential Revision: https://phabricator.services.mozilla.com/D103973